2016-10-21 16:21:54 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
unset WINEARCH WINEPREFIX
|
|
|
|
|
2016-10-22 15:40:11 +00:00
|
|
|
set -xe
|
2016-10-21 16:21:54 +00:00
|
|
|
|
|
|
|
SELF=`readlink -f $0`
|
|
|
|
CWD=`dirname $0`
|
|
|
|
SOURCES=`readlink -f $CWD/../../`
|
|
|
|
|
2017-01-08 04:58:09 +00:00
|
|
|
PYTHON64="https://www.python.org/ftp/python/2.7.13/python-2.7.13.amd64.msi"
|
|
|
|
PYTHON32="https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi"
|
2016-10-21 16:21:54 +00:00
|
|
|
PYTHONVC="https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi"
|
2017-04-26 20:34:42 +00:00
|
|
|
WINETRICKS="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
|
|
|
|
|
2017-01-08 04:58:09 +00:00
|
|
|
# PYCRYPTO32="http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win32-py2.7.exe"
|
|
|
|
# PYCRYPTO64="http://www.voidspace.org.uk/downloads/pycrypto26/pycrypto-2.6.win-amd64-py2.7.exe"
|
2017-01-10 20:45:49 +00:00
|
|
|
# PYWIN32="http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20220/pywin32-220.win32-py2.7.exe"
|
|
|
|
# PYWIN64="http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20220/pywin32-220.win-amd64-py2.7.exe"
|
2016-10-21 16:21:54 +00:00
|
|
|
|
2017-04-24 04:40:27 +00:00
|
|
|
PACKAGES="rpyc rsa pefile rsa netaddr win_inet_pton netaddr tinyec pypiwin32"
|
2017-05-31 20:00:39 +00:00
|
|
|
PACKAGES_BUILD="pycryptodome cryptography netifaces"
|
|
|
|
PACKAGES="$PACKAGES mss pyaudio https://github.com/secdev/scapy/archive/master.zip impacket pyOpenSSL colorama pyuv"
|
2016-10-21 16:21:54 +00:00
|
|
|
|
|
|
|
BUILDENV=${1:-`pwd`/buildenv}
|
|
|
|
|
|
|
|
if [ -f $BUILDENV/.ready ]; then
|
|
|
|
echo "Buildenv at $BUILDENV already prepared"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-01-10 20:45:49 +00:00
|
|
|
exec < /dev/null
|
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
WINE=${WINE:-wine}
|
|
|
|
WINE32="$BUILDENV/win32"
|
|
|
|
WINE64="$BUILDENV/win64"
|
|
|
|
DOWNLOADS="$BUILDENV/downloads"
|
|
|
|
|
2017-03-04 13:55:19 +00:00
|
|
|
MINGW64=${MINGW64:-x86_64-w64-mingw32-g++}
|
|
|
|
MINGW32=${MINGW32:-i686-w64-mingw32-g++}
|
|
|
|
|
|
|
|
WINPTY=../../pupy/external/winpty
|
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
mkdir -p "$BUILDENV"
|
|
|
|
mkdir -p "$DOWNLOADS"
|
|
|
|
|
|
|
|
WINEARCH=win32 WINEPREFIX=$WINE32 wineboot
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "apt-get install wine32"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
WINEARCH=win64 WINEPREFIX=$WINE64 wineboot
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "apt-get install wine64"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
for dist in $PYTHON32 $PYTHON64 $PYTHONVC $WINETRICKS; do
|
2017-03-10 20:26:10 +00:00
|
|
|
wget -qcP $DOWNLOADS $dist
|
2016-10-21 16:21:54 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for prefix in $WINE32 $WINE64; do
|
2016-10-21 20:19:14 +00:00
|
|
|
rm -f $prefix/dosdevices/y:
|
|
|
|
rm -f $prefix/dosdevices/x:
|
|
|
|
ln -s ../../downloads $prefix/dosdevices/y:
|
|
|
|
ln -s $SOURCES $prefix/dosdevices/x:
|
2016-10-21 16:21:54 +00:00
|
|
|
done
|
|
|
|
|
2017-01-10 20:45:49 +00:00
|
|
|
WINEPREFIX=$WINE32 wineserver -k || true
|
2016-10-21 16:21:54 +00:00
|
|
|
|
|
|
|
[ ! -f $WINE32/drive_c/.python ] && \
|
2017-01-08 04:58:09 +00:00
|
|
|
WINEPREFIX=$WINE32 msiexec /i Y:\\python-2.7.13.msi /q && \
|
2016-10-21 16:21:54 +00:00
|
|
|
touch $WINE32/drive_c/.python
|
|
|
|
|
2016-10-21 20:19:14 +00:00
|
|
|
WINEPREFIX=$WINE32 wineboot -r
|
2017-01-10 20:45:49 +00:00
|
|
|
WINEPREFIX=$WINE32 wineserver -k || true
|
2016-10-21 20:19:14 +00:00
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
[ ! -f $WINE64/drive_c/.python ] && \
|
2017-01-08 04:58:09 +00:00
|
|
|
WINEPREFIX=$WINE64 msiexec /i Y:\\python-2.7.13.amd64.msi /q && \
|
2016-10-21 16:21:54 +00:00
|
|
|
touch $WINE64/drive_c/.python
|
|
|
|
|
2016-10-21 20:19:14 +00:00
|
|
|
WINEPREFIX=$WINE64 wineboot -r
|
2017-01-10 20:45:49 +00:00
|
|
|
WINEPREFIX=$WINE64 wineserver -k || true
|
2016-10-21 20:19:14 +00:00
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
for prefix in $WINE32 $WINE64; do
|
2016-10-21 20:19:14 +00:00
|
|
|
[ ! -f $prefix/drive_c/.vc ] && \
|
|
|
|
WINEPREFIX=$prefix msiexec /i Y:\\VCForPython27.msi /q && \
|
|
|
|
touch $prefix/drive_c/.vc
|
|
|
|
done
|
|
|
|
|
2017-04-26 20:34:42 +00:00
|
|
|
WINEPREFIX=$WINE32 sh $DOWNLOADS/winetricks winxp
|
|
|
|
WINEPREFIX=$WINE64 sh $DOWNLOADS/winetricks win7
|
2017-04-24 04:40:27 +00:00
|
|
|
|
2017-05-06 17:09:15 +00:00
|
|
|
WINEPREFIX=$WINE32 wine reg add 'HKCU\Software\Wine\DllOverrides' /t REG_SZ /v dbghelp /d '' /f
|
2017-04-24 04:40:27 +00:00
|
|
|
|
2017-03-14 06:47:30 +00:00
|
|
|
export WINEPREFIX=$WINE64
|
|
|
|
|
2017-04-10 08:42:16 +00:00
|
|
|
mkdir -p $WINE64/drive_c/windows/Microsoft.NET/Framework
|
|
|
|
mkdir -p $WINE64/drive_c/windows/Microsoft.NET/Framework64
|
|
|
|
|
|
|
|
touch $WINE64/drive_c/windows/Microsoft.NET/Framework/empty.txt
|
|
|
|
touch $WINE64/drive_c/windows/Microsoft.NET/Framework64/empty.txt
|
|
|
|
|
2017-05-06 17:09:15 +00:00
|
|
|
wine reg add 'HKCU\Software\Wine\DllOverrides' /t REG_SZ /v dbghelp /d '' /f
|
2017-03-14 06:47:30 +00:00
|
|
|
|
|
|
|
wine reg add \
|
|
|
|
'HKCU\Software\Microsoft\DevDiv\VCForPython\9.0' \
|
|
|
|
/t REG_SZ /v installdir \
|
|
|
|
/d 'C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0' \
|
|
|
|
/f
|
|
|
|
|
|
|
|
wineboot -fr
|
|
|
|
wineserver -k || true
|
|
|
|
|
|
|
|
unset WINEPREFIX
|
2016-12-03 06:11:56 +00:00
|
|
|
|
2016-10-21 20:19:14 +00:00
|
|
|
for prefix in $WINE32 $WINE64; do
|
2017-04-10 08:42:16 +00:00
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -OO -m pip install -q --upgrade pip
|
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -OO -m pip install -q --upgrade setuptools
|
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -OO -m pip install -q --upgrade $PACKAGES
|
2017-04-24 04:40:27 +00:00
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -OO -m pip install -q --upgrade --no-binary :all: $PACKAGES_BUILD
|
2017-04-26 20:55:00 +00:00
|
|
|
done
|
|
|
|
|
2017-04-27 08:27:06 +00:00
|
|
|
WINEPREFIX=$WINE32 wine C:\\Python27\\python -OO -m pip install -q --upgrade --no-binary :all: psutil==4.3.1
|
2017-04-26 20:55:00 +00:00
|
|
|
WINEPREFIX=$WINE64 wine C:\\Python27\\python -OO -m pip install -q --upgrade --no-binary :all: psutil
|
|
|
|
|
|
|
|
for prefix in $WINE32 $WINE64; do
|
2017-03-14 22:06:46 +00:00
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -m compileall -q C:\\Python27\\Lib || true
|
2017-03-21 20:25:22 +00:00
|
|
|
WINEPREFIX=$prefix wine C:\\Python27\\python -OO -m compileall -q C:\\Python27\\Lib || true
|
2016-10-21 16:21:54 +00:00
|
|
|
done
|
|
|
|
|
2017-01-10 20:45:49 +00:00
|
|
|
# WINEPREFIX=$WINE32 wine C:\\Python27\\python.exe -m easy_install -Z $PYWIN32
|
|
|
|
# WINEPREFIX=$WINE64 wine C:\\Python27\\python.exe -m easy_install -Z $PYWIN64
|
2016-10-21 16:21:54 +00:00
|
|
|
|
|
|
|
cat >$WINE32/python.sh <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
unset WINEARCH
|
|
|
|
export WINEPREFIX=$WINE32
|
2017-04-24 04:40:27 +00:00
|
|
|
export LINK="/NXCOMPAT:NO /LTCG"
|
|
|
|
export CL="/O1 /GL /GS-"
|
2017-03-21 20:25:22 +00:00
|
|
|
exec wine C:\\\\Python27\\\\python.exe -OO "\$@"
|
2016-10-21 16:21:54 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $WINE32/python.sh
|
|
|
|
|
|
|
|
cat >$WINE32/cl.sh <<EOF
|
|
|
|
#!/bin/sh
|
2016-10-21 20:19:14 +00:00
|
|
|
unset WINEARCH
|
2016-10-21 16:21:54 +00:00
|
|
|
export WINEPREFIX=$WINE32
|
|
|
|
export VCINSTALLDIR="C:\\\\Program Files\\\\Common Files\\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\VC"
|
|
|
|
export WindowsSdkDir="C:\\\\Program Files\\\\Common Files\\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\WinSDK"
|
|
|
|
export INCLUDE="\$VCINSTALLDIR\\\\Include;\$WindowsSdkDir\\\\Include"
|
|
|
|
export LIB="\$VCINSTALLDIR\\\\Lib;\$WindowsSdkDir\\\\Lib"
|
|
|
|
export LIBPATH="\$VCINSTALLDIR\\\\Lib;\$WindowsSdkDir\\\\Lib"
|
2017-04-24 04:40:27 +00:00
|
|
|
export LINK="/NXCOMPAT:NO /LTCG"
|
|
|
|
export CL="/GL /GS-"
|
2016-10-21 16:21:54 +00:00
|
|
|
exec wine "\$VCINSTALLDIR\\\\bin\\\\cl.exe" "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $WINE32/cl.sh
|
|
|
|
|
|
|
|
cat >$WINE64/python.sh <<EOF
|
2016-10-21 20:19:14 +00:00
|
|
|
#!/bin/sh
|
2016-10-21 16:21:54 +00:00
|
|
|
unset WINEARCH
|
|
|
|
export WINEPREFIX=$WINE64
|
2017-04-24 04:40:27 +00:00
|
|
|
export LINK="/NXCOMPAT:NO /LTCG"
|
|
|
|
export CL="/O1 /GL /GS-"
|
2017-03-21 20:25:22 +00:00
|
|
|
exec wine C:\\\\Python27\\\\python.exe -OO "\$@"
|
2016-10-21 16:21:54 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $WINE64/python.sh
|
|
|
|
|
|
|
|
cat >$WINE64/cl.sh <<EOF
|
2016-10-21 20:19:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
unset WINEARCH
|
2016-10-21 16:21:54 +00:00
|
|
|
export WINEPREFIX=$WINE64
|
|
|
|
export VCINSTALLDIR="C:\\\\Program Files (x86)\\\\Common Files\\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\VC"
|
|
|
|
export WindowsSdkDir="C:\\\\Program Files (x86)\\\\Common Files\\\\Microsoft\\\\Visual C++ for Python\\\\9.0\\\\WinSDK"
|
|
|
|
export INCLUDE="\$VCINSTALLDIR\\\\Include;\$WindowsSdkDir\\\\Include"
|
|
|
|
export LIB="\$VCINSTALLDIR\\\\Lib\\\\amd64;\$WindowsSdkDir\\\\Lib\\\\x64"
|
2016-10-21 20:19:14 +00:00
|
|
|
export LIBPATH="\$VCINSTALLDIR\\\\Lib\\\\amd64;\$WindowsSdkDir\\\\Lib\\\\x64"
|
2017-04-24 04:40:27 +00:00
|
|
|
export LINK="/NXCOMPAT:NO /LTCG"
|
|
|
|
export CL="/GL /GS-"
|
2016-10-21 16:21:54 +00:00
|
|
|
exec wine "\$VCINSTALLDIR\\\\bin\\\\amd64\\\\cl.exe" "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $WINE64/cl.sh
|
|
|
|
|
2017-03-04 13:55:19 +00:00
|
|
|
$WINE32/cl.sh \
|
|
|
|
../../pupy/packages/src/pupymemexec/pupymemexec.c \
|
|
|
|
/LD /D_WIN32 /IC:\\Python27\\Include \
|
|
|
|
C:\\Python27\\libs\\python27.lib advapi32.lib \
|
|
|
|
/FeC:\\Python27\\Lib\\site-packages\\pupymemexec.pyd
|
|
|
|
|
|
|
|
$WINE64/cl.sh \
|
|
|
|
../../pupy/packages/src/pupymemexec/pupymemexec.c \
|
|
|
|
/LD /D_WIN64 /IC:\\Python27\\Include \
|
|
|
|
C:\\Python27\\libs\\python27.lib advapi32.lib \
|
|
|
|
/FeC:\\Python27\\Lib\\site-packages\\pupymemexec.pyd
|
|
|
|
|
2017-04-24 04:40:27 +00:00
|
|
|
make -C ${WINPTY} clean
|
|
|
|
make -C ${WINPTY} MINGW_CXX="${MINGW32} -Os -s" build/winpty.dll
|
|
|
|
mv $WINPTY/build/winpty.dll ${BUILDENV}/win32/drive_c/Python27/DLLs/
|
2017-03-04 13:55:19 +00:00
|
|
|
|
2017-04-24 04:40:27 +00:00
|
|
|
make -C ${WINPTY} clean
|
|
|
|
make -C ${WINPTY} MINGW_CXX="${MINGW64} -Os -s" build/winpty.dll
|
|
|
|
mv ${WINPTY}/build/winpty.dll ${BUILDENV}/win64/drive_c/Python27/DLLs/
|
2017-03-04 13:55:19 +00:00
|
|
|
|
2017-01-10 06:50:32 +00:00
|
|
|
echo "[+] Creating bundles"
|
|
|
|
|
|
|
|
TEMPLATES=`readlink -f ../../pupy/payload_templates`
|
|
|
|
|
2017-01-10 20:45:49 +00:00
|
|
|
OPWD=`pwd`
|
|
|
|
|
2017-03-04 13:55:19 +00:00
|
|
|
cd $WINE32/drive_c/Python27
|
2017-01-10 20:45:49 +00:00
|
|
|
rm -f ${TEMPLATES}/windows-x86.zip
|
|
|
|
for dir in Lib DLLs; do
|
|
|
|
cd $dir
|
2017-03-10 20:26:10 +00:00
|
|
|
zip -q -y \
|
2017-03-21 20:25:22 +00:00
|
|
|
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyc" -x "*.chm" \
|
2017-03-14 11:42:38 +00:00
|
|
|
-x "*test/*" -x "*tests/*" -x "*examples/*" -x "pythonwin/*" \
|
|
|
|
-x "idlelib/*" -x "lib-tk/*" -x "tk*" -x "tcl*" \
|
|
|
|
-x "*.egg-info/*" -x "*.dist-info/*" -x "*.exe" \
|
2017-01-10 20:45:49 +00:00
|
|
|
-r9 ${TEMPLATES}/windows-x86.zip .
|
|
|
|
cd -
|
|
|
|
done
|
|
|
|
|
2017-03-04 13:55:19 +00:00
|
|
|
cd $WINE64/drive_c/Python27
|
2017-01-10 20:45:49 +00:00
|
|
|
rm -f ${TEMPLATES}/windows-amd64.zip
|
|
|
|
|
|
|
|
for dir in Lib DLLs; do
|
|
|
|
cd $dir
|
2017-03-10 20:26:10 +00:00
|
|
|
zip -q -y \
|
2017-03-21 20:25:22 +00:00
|
|
|
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyc" -x "*.chm" \
|
2017-03-14 11:42:38 +00:00
|
|
|
-x "*test/*" -x "*tests/*" -x "*examples/*" -x "pythonwin/*" \
|
|
|
|
-x "idlelib/*" -x "lib-tk/*" -x "tk*" -x "tcl*" \
|
|
|
|
-x "*.egg-info/*" -x "*.dist-info/*" -x "*.exe" \
|
2017-01-10 20:45:49 +00:00
|
|
|
-r9 ${TEMPLATES}/windows-amd64.zip .
|
|
|
|
cd -
|
|
|
|
done
|
|
|
|
|
2016-10-21 16:21:54 +00:00
|
|
|
touch $BUILDENV/.ready
|