From 6350ad9ab4bbbc64aecb62c7fcf9bed04d022ea3 Mon Sep 17 00:00:00 2001
From: Oleksii Shevchuk
Date: Tue, 14 Mar 2017 13:42:38 +0200
Subject: [PATCH] Reduce images size
---
client/sources-linux/buildenv.sh | 6 ++++++
client/sources/buildenv.sh | 14 +++++++++-----
pupy/.dockerignore | 2 ++
pupy/Dockerfile | 1 -
pupy/conf/pupyenv.sh | 5 ++++-
5 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/client/sources-linux/buildenv.sh b/client/sources-linux/buildenv.sh
index 73ddfa47..ad286f5c 100755
--- a/client/sources-linux/buildenv.sh
+++ b/client/sources-linux/buildenv.sh
@@ -275,6 +275,7 @@ CFLAGS="-O2 -pipe -DCLOCK_MONOTONIC=1 -UHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC -U
python -O -m pip install pyuv --no-binary :all:
cd /usr/lib/python2.7
+python -O -m compileall -q
python -OO -m compileall -q
find -name "*.so" | while read f; do strip \$f; done
@@ -496,6 +497,7 @@ cd /usr/src/automake-1.15
python -O -m pip install pyuv --no-binary :all:
cd /usr/lib/python2.7
+python -O -m compileall -q
python -OO -m compileall -q
find -name "*.so" | while read f; do strip \$f; done
@@ -526,6 +528,8 @@ cd buildenv/lin64/usr/lib/python2.7
zip -y \
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyo" \
-x "*test/*" -x "*tests/*" -x "*examples/*" \
+ -x "*.egg-info/*" -x "*.dist-info/*" \
+ -x "idlelib/*" -x "lib-tk/*" -x "tk*" -x "tcl*" \
-r9 ${TEMPLATES}/linux-amd64.zip .
cd -
@@ -533,6 +537,8 @@ cd buildenv/lin32/usr/lib/python2.7
zip -y \
-x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyo" \
-x "*test/*" -x "*tests/*" -x "*examples/*" \
+ -x "*.egg-info/*" -x "*.dist-info/*" \
+ -x "idlelib/*" -x "lib-tk/*" -x "tk*" -x "tcl*" -x "*.la" \
-r9 ${TEMPLATES}/linux-x86.zip .
cd -
diff --git a/client/sources/buildenv.sh b/client/sources/buildenv.sh
index 757cd0b3..044c9f5b 100755
--- a/client/sources/buildenv.sh
+++ b/client/sources/buildenv.sh
@@ -16,7 +16,7 @@ PYTHONVC="https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-
# 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"
-PACKAGES="rpyc pyaml rsa pefile image rsa netaddr win_inet_pton netaddr tinyec pycrypto cryptography pypiwin32"
+PACKAGES="rpyc pyaml rsa pefile rsa netaddr win_inet_pton netaddr tinyec pycrypto cryptography pypiwin32"
PACKAGES="$PACKAGES mss pyaudio scapy pyOpenSSL colorama pyuv"
BUILDENV=${1:-`pwd`/buildenv}
@@ -235,8 +235,10 @@ rm -f ${TEMPLATES}/windows-x86.zip
for dir in Lib DLLs; do
cd $dir
zip -q -y \
- -x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" \
- -x "*test/*" -x "*tests/*" -x "*examples/*" \
+ -x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyo" -x "*.chm" \
+ -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
@@ -247,8 +249,10 @@ rm -f ${TEMPLATES}/windows-amd64.zip
for dir in Lib DLLs; do
cd $dir
zip -q -y \
- -x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" \
- -x "*test/*" -x "*tests/*" -x "*examples/*" \
+ -x "*.a" -x "*.o" -x "*.whl" -x "*.txt" -x "*.py" -x "*.pyo" -x "*.chm" \
+ -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
diff --git a/pupy/.dockerignore b/pupy/.dockerignore
index 7bfe8a22..e82e287e 100644
--- a/pupy/.dockerignore
+++ b/pupy/.dockerignore
@@ -11,3 +11,5 @@ external/scapy
**/__pycache__*
**/test?
packages/src
+**/*.pyc
+**/*.pyo
diff --git a/pupy/Dockerfile b/pupy/Dockerfile
index 38a48ca3..6d3437d2 100644
--- a/pupy/Dockerfile
+++ b/pupy/Dockerfile
@@ -28,7 +28,6 @@ COPY requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt --no-binary :all:
COPY . /opt/pupy
-RUN cd /opt/pupy && python -O -m compileall -qf && python -OO -m compileall -qf
ADD https://github.com/gentilkiwi/mimikatz/releases/download/2.1.0-20170305/mimikatz_trunk.zip \
/opt/mimikatz/mimikatz.zip
diff --git a/pupy/conf/pupyenv.sh b/pupy/conf/pupyenv.sh
index b6055a11..19636866 100755
--- a/pupy/conf/pupyenv.sh
+++ b/pupy/conf/pupyenv.sh
@@ -46,7 +46,10 @@ echo "$1" >/home/pupy/.project
cd /opt/pupy
-python -m compileall -q >/dev/null
+find -type f -exec md5sum {} >/projects/integrity.txt
+
+python -O -m compileall -qf
+python -OO -m compileall -qf
echo 'Copy your authorized_keys here!' >/projects/keys/README