mirror of
https://github.com/mgeeky/Penetration-Testing-Tools.git
synced 2024-11-22 10:31:38 +01:00
Several fixes in ysoserial-generator.py
This commit is contained in:
parent
228f424d89
commit
cce7499ad3
@ -55,7 +55,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author:
|
# Author:
|
||||||
# Mariusz B., '18 / <mb@binary-offensive.com>
|
# Mariusz B., '18-19 / <mb@binary-offensive.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -67,7 +67,7 @@ import subprocess
|
|||||||
import argparse
|
import argparse
|
||||||
from sys import platform
|
from sys import platform
|
||||||
|
|
||||||
VERSION = '0.2'
|
VERSION = '0.3'
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'verbose' : True,
|
'verbose' : True,
|
||||||
@ -148,6 +148,7 @@ class Logger:
|
|||||||
def ok(x):
|
def ok(x):
|
||||||
Logger._out('[+] ' + x)
|
Logger._out('[+] ' + x)
|
||||||
|
|
||||||
|
|
||||||
def getFileName(name, gadget):
|
def getFileName(name, gadget):
|
||||||
global firstLaunch
|
global firstLaunch
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ def generate(name, cmd):
|
|||||||
gadget = gadget,
|
gadget = gadget,
|
||||||
command = cmd2,
|
command = cmd2,
|
||||||
redir = redir
|
redir = redir
|
||||||
), True)
|
), True, True)
|
||||||
|
|
||||||
if config['base64']:
|
if config['base64']:
|
||||||
out = base64.b64encode(out)
|
out = base64.b64encode(out)
|
||||||
@ -267,7 +268,9 @@ def generate(name, cmd):
|
|||||||
else:
|
else:
|
||||||
Logger.ok('Writing payload to the file: "{}"'.format(filename))
|
Logger.ok('Writing payload to the file: "{}"'.format(filename))
|
||||||
|
|
||||||
open(filename, mode).write(out + '\n')
|
with open(filename, mode) as f:
|
||||||
|
f.write(out + '\n')
|
||||||
|
|
||||||
generated += 1
|
generated += 1
|
||||||
else:
|
else:
|
||||||
Logger.err('Failed generating payload {}-{} for cmd: "{}"'.format(
|
Logger.err('Failed generating payload {}-{} for cmd: "{}"'.format(
|
||||||
@ -295,11 +298,14 @@ def processShellCmd(cmd):
|
|||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
def shell(cmd, noOut = False):
|
def shell(cmd, noOut = False, surpressStderr = False):
|
||||||
cmd = processShellCmd(cmd)
|
cmd = processShellCmd(cmd)
|
||||||
out = ""
|
out = ""
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
|
stderr = subprocess.STDOUT
|
||||||
|
if surpressStderr:
|
||||||
|
stderr = None
|
||||||
|
out = subprocess.check_output(cmd, stderr=stderr, shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if 'Available payload types' in e.output or 'mbechler' in e.output:
|
if 'Available payload types' in e.output or 'mbechler' in e.output:
|
||||||
out = e.output
|
out = e.output
|
||||||
|
Loading…
Reference in New Issue
Block a user