forked from ropnop/impacket_static_binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_linux.sh
executable file
·37 lines (27 loc) · 947 Bytes
/
build_linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -euo pipefail
### This script is intended to be run in the rflathers/centos5_python27 Docker image
[[ ! -f /.dockerenv ]] && echo "Do not run this script outside of the docker image! Use the Makefile" && exit 1
# Normalize working dir
ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
cd "${ROOT}"
# Install dependencies
pip install pip==18.1
pip install setuptools==40.6.3
pip install pyinstaller==3.4
# Install impacket
pip install .
# Hardcode UTF-8 in shells
sed -r -i.bak 's/sys\.std(in|out)\.encoding/"UTF-8"/g' examples/*exec.py
# Create standalone executables
for i in examples/*.py
do
pyinstaller --specpath /tmp/spec --workpath /tmp/build --distpath /tmp/out --clean -F $i
done
# Rename binaries and move
mkdir -p dist
ARCH=$(uname -m)
find /tmp/out/ -type f -exec mv {} {}_linux_$ARCH \;
mv /tmp/out/* ./dist/
# Restore backup file
for fn in examples/*.bak; do mv -f "${fn}" "${fn%%.bak}"; done