2018-01-04 21:45:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-06-17 18:52:01 +00:00
|
|
|
PACKAGES="rpyc==3.4.4 rsa pefile rsa netaddr win_inet_pton netaddr tinyec pypiwin32 poster win_inet_pton dnslib"
|
2018-10-16 07:28:59 +00:00
|
|
|
PACKAGES_BUILD="netifaces msgpack-python u-msgpack-python scandir construct bcrypt watchdog"
|
2018-11-29 13:09:39 +00:00
|
|
|
PACKAGES="$PACKAGES pyaudio https://github.com/secdev/scapy/archive/master.zip colorama pyuv pynacl pyaudio"
|
2018-01-04 21:45:40 +00:00
|
|
|
PACKAGES="$PACKAGES https://github.com/CoreSecurity/impacket/archive/master.zip"
|
2018-09-21 19:57:44 +00:00
|
|
|
PACKAGES="$PACKAGES https://github.com/AlessandroZ/pypykatz/archive/master.zip"
|
2018-10-03 20:14:08 +00:00
|
|
|
PACKAGES="$PACKAGES adodbapi"
|
2018-01-04 21:45:40 +00:00
|
|
|
|
|
|
|
SELF=`readlink -f "$0"`
|
|
|
|
SELFPWD=`dirname "$SELF"`
|
|
|
|
SRC=${SELFPWD:-`pwd`}
|
2018-01-11 15:03:24 +00:00
|
|
|
PUPY=`readlink -f ../../pupy`
|
2018-01-04 21:45:40 +00:00
|
|
|
|
|
|
|
cd $SRC
|
|
|
|
|
2018-11-02 07:02:41 +00:00
|
|
|
EXTERNAL=../../pupy/external
|
|
|
|
WINPTY=$EXTERNAL/winpty
|
|
|
|
PYKCP=$EXTERNAL/pykcp
|
|
|
|
PYOPUS=$EXTERNAL/pyopus/src
|
2018-01-04 21:45:40 +00:00
|
|
|
|
|
|
|
echo "[+] Install python packages"
|
|
|
|
for PYTHON in $PYTHON32 $PYTHON64; do
|
2018-01-13 17:54:06 +00:00
|
|
|
$PYTHON -m pip install -q --upgrade pip
|
|
|
|
$PYTHON -m pip install -q --upgrade setuptools
|
2018-11-29 09:30:47 +00:00
|
|
|
$PYTHON -m pip install --upgrade $PACKAGES pycryptodomex==3.7.0
|
2018-02-15 11:58:29 +00:00
|
|
|
$PYTHON -m pip install --upgrade --no-binary :all: $PACKAGES_BUILD
|
2018-11-29 13:09:39 +00:00
|
|
|
$PYTHON -m pip install cryptography==1.7.2 pyOpenSSL==17.5.0 paramiko
|
|
|
|
$PYTHON -m pip install --no-binary :all: pycryptodome==3.6.6
|
|
|
|
$PYTHON -c "from Crypto.Cipher import AES"
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
echo "pycryptodome build failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-08-18 04:06:36 +00:00
|
|
|
|
|
|
|
rm -rf $PYKCP/{kcp.so,kcp.pyd,kcp.dll,build,KCP.egg-info}
|
2018-01-13 17:54:06 +00:00
|
|
|
$PYTHON -m pip install --upgrade --force $PYKCP
|
2018-08-18 04:06:36 +00:00
|
|
|
$PYTHON -c 'import kcp' || exit 1
|
2018-01-04 21:45:40 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "[+] Install psutil"
|
2018-01-13 17:54:06 +00:00
|
|
|
$PYTHON32 -m pip install --no-binary :all: psutil==4.3.1
|
2018-02-15 11:58:29 +00:00
|
|
|
$PYTHON64 -m pip install --upgrade --no-binary :all: psutil
|
|
|
|
|
|
|
|
for PYTHON in $PYTHON32 $PYTHON64; do
|
|
|
|
$PYTHON -m pip install -q --force pycparser==2.17
|
|
|
|
done
|
2018-01-04 21:45:40 +00:00
|
|
|
|
2018-11-02 07:02:41 +00:00
|
|
|
cd $PYOPUS
|
|
|
|
echo "[+] Compile opus /32"
|
|
|
|
git clean -fdx
|
|
|
|
make -f Makefile.msvc CL=$CL32
|
|
|
|
mv opus.pyd ${WINE32}/drive_c/Python27/Lib/site-packages/
|
|
|
|
|
|
|
|
echo "[+] Compile opus /64"
|
|
|
|
git clean -fdx
|
|
|
|
make -f Makefile.msvc CL=$CL64
|
|
|
|
mv -f opus.pyd ${WINE64}/drive_c/Python27/Lib/site-packages/
|
|
|
|
|
|
|
|
cd $SRC
|
2018-01-04 21:45:40 +00:00
|
|
|
echo "[+] Compile pupymemexec /32"
|
|
|
|
$CL32 \
|
|
|
|
../../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
|
|
|
|
|
|
|
|
echo "[+] Compile pupymemexec /64"
|
|
|
|
$CL64 \
|
|
|
|
../../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
|
|
|
|
|
|
|
|
echo "[+] Compile winpty /32"
|
|
|
|
make -C ${WINPTY} clean
|
|
|
|
make -C ${WINPTY} MINGW_CXX="${MINGW32} -Os -s" build/winpty.dll
|
|
|
|
mv $WINPTY/build/winpty.dll ${WINE32}/drive_c/Python27/DLLs/
|
|
|
|
|
|
|
|
echo "[+] Compile winpty /64"
|
|
|
|
make -C ${WINPTY} clean
|
|
|
|
make -C ${WINPTY} MINGW_CXX="${MINGW64} -Os -s" build/winpty.dll
|
|
|
|
mv ${WINPTY}/build/winpty.dll ${WINE64}/drive_c/Python27/DLLs/
|
|
|
|
|
|
|
|
TEMPLATES=`readlink -f ../../pupy/payload_templates`
|
|
|
|
|
|
|
|
echo "[+] Build templates /32"
|
|
|
|
cd $WINE32/drive_c/Python27
|
|
|
|
rm -f ${TEMPLATES}/windows-x86.zip
|
|
|
|
for dir in Lib DLLs; do
|
|
|
|
cd $dir
|
|
|
|
zip -q -y \
|
2018-03-16 12:15:24 +00:00
|
|
|
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.pyo" -x "*.pyc" -x "*.chm" \
|
2018-01-04 21:45:40 +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" \
|
|
|
|
-r9 ${TEMPLATES}/windows-x86.zip .
|
|
|
|
cd -
|
|
|
|
done
|
|
|
|
|
|
|
|
cd $WINE64/drive_c/Python27
|
|
|
|
rm -f ${TEMPLATES}/windows-amd64.zip
|
|
|
|
|
|
|
|
echo "[+] Build templates /64"
|
|
|
|
for dir in Lib DLLs; do
|
|
|
|
cd $dir
|
|
|
|
zip -q -y \
|
2018-03-16 12:15:24 +00:00
|
|
|
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.pyo" -x "*.pyc" -x "*.chm" \
|
2018-01-04 21:45:40 +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" \
|
|
|
|
-r9 ${TEMPLATES}/windows-amd64.zip .
|
|
|
|
cd -
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "[+] Build pupy"
|
|
|
|
|
|
|
|
TARGETS="pupyx64d.dll pupyx64d.exe pupyx64.dll pupyx64d.unc.dll pupyx64d.unc.exe"
|
|
|
|
TARGETS="$TARGETS pupyx64.exe pupyx64.unc.dll pupyx64.unc.exe pupyx86d.dll pupyx86d.exe pupyx86.dll"
|
|
|
|
TARGETS="$TARGETS pupyx86d.unc.dll pupyx86d.unc.exe pupyx86.exe pupyx86.unc.dll pupyx86.unc.exe"
|
|
|
|
|
|
|
|
cd ${SRC}
|
|
|
|
|
|
|
|
for target in $TARGETS; do rm -f $TEMPLATES/$target; done
|
|
|
|
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win32 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win32
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win32 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win32
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win32 UNCOMPRESSED=1 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win32 UNCOMPRESSED=1
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win32 UNCOMPRESSED=1 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win32 UNCOMPRESSED=1
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win64 distclean
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win64
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win64 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win64
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win64 UNCOMPRESSED=1 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win64 UNCOMPRESSED=1
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win64 UNCOMPRESSED=1 clean
|
|
|
|
make -f Makefile -j BUILDENV=/build DEBUG=1 ARCH=win64 UNCOMPRESSED=1
|
|
|
|
make -f Makefile -j BUILDENV=/build ARCH=win64 UNCOMPRESSED=1 distclean
|
|
|
|
|
|
|
|
for object in $TARGETS; do
|
|
|
|
if [ -z "$object" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f $TEMPLATES/$object ]; then
|
|
|
|
echo "[-] $object - failed"
|
|
|
|
FAILED=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$FAILED" ]; then
|
|
|
|
echo "[+] Build complete"
|
|
|
|
else
|
|
|
|
echo "[-] Build failed"
|
|
|
|
exit 1
|
|
|
|
fi
|