mirror of https://github.com/n1nj4sec/pupy.git
new library.zip generation script
This commit is contained in:
parent
3c51f3c65c
commit
d2dad1eff7
|
@ -1,85 +0,0 @@
|
||||||
import sys
|
|
||||||
from distutils.core import setup
|
|
||||||
import py2exe
|
|
||||||
import os
|
|
||||||
from glob import glob
|
|
||||||
import zipfile
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
"""
|
|
||||||
This setup is not meant to build pupy stubs, but only to generate an adequate library.zip to embed in the real exe/dll stub
|
|
||||||
please don't use this if you don't want to recompile from sources
|
|
||||||
|
|
||||||
NOTE: I had to manually change pyreadline/console/console.py to console2.py and edit __init__.py to change the import because I had a conflict
|
|
||||||
|
|
||||||
"""
|
|
||||||
print "NOTE: you must install the following packages before proceeding: "
|
|
||||||
print """
|
|
||||||
-pywin32
|
|
||||||
-pycrypto
|
|
||||||
-pyaml (scramblesuit dependency)
|
|
||||||
"""
|
|
||||||
if not (len(sys.argv)==3 and sys.argv[1]=="genzip"):
|
|
||||||
exit("This setup is not meant to build pupy stubs, but only to generate an adequate library.zip to embed in the real exe/dll stub\nplease don't use this if you don't want to recompile from sources")
|
|
||||||
if sys.argv[2] == 'x86':
|
|
||||||
outname = 'x86'
|
|
||||||
platform = '32'
|
|
||||||
elif sys.argv[2] == 'x64':
|
|
||||||
outname = 'x64'
|
|
||||||
platform = '-amd64'
|
|
||||||
else:
|
|
||||||
exit('unsupported platform')
|
|
||||||
sys.argv=[sys.argv[0],"py2exe"]
|
|
||||||
|
|
||||||
|
|
||||||
# put necessary library patches/includes/whatever in this directory
|
|
||||||
sys.path.insert(0, os.path.join("sources","resources","library_patches"))
|
|
||||||
sys.path.insert(0, os.path.join("..","pupy"))
|
|
||||||
|
|
||||||
setup(
|
|
||||||
#data_files = [(".", glob(r'.\RESOURCES_x86\msvcr90.dll'))],
|
|
||||||
console=['..\\pupy\\pp.py'],
|
|
||||||
#windows=['reverse_ssl.py'],
|
|
||||||
#zipfile=None,
|
|
||||||
options={ "py2exe" : {
|
|
||||||
"packages":['additional_imports', 'Crypto'],
|
|
||||||
"compressed" : True,
|
|
||||||
"bundle_files" : 3, #3 = don't bundle (default) 2 = bundle everything but the Python interpreter 1 = bundle everything
|
|
||||||
"excludes": ["Tkinter", "pyreadline", "IPython","readline"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
excluded_files = [
|
|
||||||
'crypt32.dll',
|
|
||||||
'library.zip',
|
|
||||||
'mswsock.dll',
|
|
||||||
'python27.dll',
|
|
||||||
'pp.exe',
|
|
||||||
'w9xpopen.exe',
|
|
||||||
]
|
|
||||||
|
|
||||||
def zwalk(path, zf):
|
|
||||||
for root, dirs, files in os.walk(path):
|
|
||||||
for file in files:
|
|
||||||
if file.lower() in excluded_files:
|
|
||||||
pass
|
|
||||||
elif file.endswith('.pyd') and "." in file.rsplit(".",1)[0]:
|
|
||||||
arch_path="/".join(file.rsplit(".",1)[0].split('.'))
|
|
||||||
zf.write(os.path.join(root,file),arcname=arch_path+".pyd")
|
|
||||||
else:
|
|
||||||
zf.write(os.path.join(root, file))
|
|
||||||
|
|
||||||
|
|
||||||
with zipfile.ZipFile('sources/resources/library%s.zip' % outname, 'w', zipfile.ZIP_DEFLATED) as zf:
|
|
||||||
root = os.getcwd()
|
|
||||||
os.chdir('build/bdist.win%s/winexe/collect-2.7' % platform)
|
|
||||||
zwalk('.', zf)
|
|
||||||
os.chdir('%s/dist' % root)
|
|
||||||
zwalk('.', zf)
|
|
||||||
|
|
||||||
print 'cleaning up'
|
|
||||||
os.chdir(root)
|
|
||||||
shutil.rmtree('build')
|
|
||||||
shutil.rmtree('dist')
|
|
||||||
|
|
|
@ -20,13 +20,13 @@ if sys.argv[1]=="x86":
|
||||||
elif sys.argv[1]=="x64":
|
elif sys.argv[1]=="x64":
|
||||||
arch="x64"
|
arch="x64"
|
||||||
print "copying installed python version to sources\\resources\\python27_x64.dll"
|
print "copying installed python version to sources\\resources\\python27_x64.dll"
|
||||||
shutil.copy("C:\\Windows\SysNative\python27.dll", "sources\\resources\\python27_x64.dll")
|
shutil.copy("C:\\Windows\system32\python27.dll", "sources\\resources\\python27_x64.dll")
|
||||||
else:
|
else:
|
||||||
exit("usage: python %s (x86|x64)"%sys.argv[0])
|
exit("usage: python %s (x86|x64)"%sys.argv[0])
|
||||||
|
|
||||||
|
|
||||||
all_dependencies=list(set([x.split(".")[0] for x in sys.modules.iterkeys()]))
|
all_dependencies=list(set([x.split(".")[0] for x in sys.modules.iterkeys()]))
|
||||||
all_dependencies.extend(["win32file", "win32pipe", "Crypto", "yaml", "_yaml"])
|
all_dependencies.extend(["win32file", "win32pipe", "Crypto", "yaml", "_yaml", "rpyc"])
|
||||||
all_dependencies=list(set(all_dependencies))
|
all_dependencies=list(set(all_dependencies))
|
||||||
|
|
||||||
zf = zipfile.ZipFile(os.path.join("sources","resources","library%s.zip"%arch), mode='w', compression=zipfile.ZIP_DEFLATED)
|
zf = zipfile.ZipFile(os.path.join("sources","resources","library%s.zip"%arch), mode='w', compression=zipfile.ZIP_DEFLATED)
|
||||||
|
@ -36,7 +36,7 @@ try:
|
||||||
zf.write("C:\\Windows\\SysWOW64\\pywintypes27.dll", "pywintypes27.dll")
|
zf.write("C:\\Windows\\SysWOW64\\pywintypes27.dll", "pywintypes27.dll")
|
||||||
else:
|
else:
|
||||||
print("adding pywintypes.dll")
|
print("adding pywintypes.dll")
|
||||||
zf.write("C:\\Windows\\SysNative\\pywintypes27.dll", "pywintypes27.dll")
|
zf.write("C:\\Windows\\system32\\pywintypes27.dll", "pywintypes27.dll")
|
||||||
for dep in all_dependencies:
|
for dep in all_dependencies:
|
||||||
found=False
|
found=False
|
||||||
for path in sys.path:
|
for path in sys.path:
|
||||||
|
|
Loading…
Reference in New Issue