forked from hatRiot/zarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·133 lines (121 loc) · 3.85 KB
/
setup.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
#
# Setup script for Zarp.
#
# retrieve and install Scapy
function install(){
echo '[+] Fetching latest Scapy...'
wget scapy.net
mv ./index.html ./scapy.zip
unzip scapy.zip
cd scapy-*
sudo python setup.py install
echo '[!] Cleaning up...'
cd ../
rm -fr ./scapy*
}
# patch scapy with modified classes
function patch(){
echo '[+] Patching scapy...'
if [ -d '/usr/local/lib/python2.7/site-packages/scapy/' ]; then
# patch sendrecv.py
SCAPY_INSTALL='/usr/local/lib/python2.7/site-packages/scapy'
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
elif [ -d '/usr/local/lib/python2.6/dist-packages/scapy/' ]; then
# patch sendrecv.py
SCAPY_INSTALL='/usr/local/lib/python2.6/dist-packages/scapy'
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
else
# TODO: find and replace automatically
echo -n '[!] Enter scapy install directory: '
read SCAPY_INSTALL
if [ -d $SCAPY_INSTALL ]; then
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
else
echo '[-] $SCAPY_INSTALL does not exist or is incorrect. Exiting...'
exit 1
fi
fi
# remove the byte-compiled version
rm -f $SCAPY_INSTALL/sendrecv.pyc
}
# we need privs to move stuff around
if [ "$(id -u)" != '0' ]; then
echo '[-] Script needs to be run as root.'
exit 1
fi
# check for python
PYTHON=`which python`
if [ ! -f $PYTHON ]; then
echo '[-] Python not found!'
exit 1
fi
# check version
PY_VER=`$PYTHON -c 'import sys
print (sys.version_info >= (2,6) and "1" or "0")'`
if [ "$PY_VER" = '0' ]; then
echo '[-] Zarp requires Python 2.6 or later.'
exit 1
fi
# test if Scapy is correctly installed
echo '[!] Checking for Scapy...'
SCAPY_EXISTS=`$PYTHON -c 'try:
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
except ImportError:
print 0
else:
print 1'`
if [ "SCAPY_EXISTS" = '0' ]; then
echo '[-] Scapy must first be installed.'
exit 1
fi
# copy the patched sendrecv.py file
echo '[!] Patching Scapy...'
if [ -d '/usr/local/lib/python2.7/site-packages/scapy/' ]; then
# patch sendrecv.py
SCAPY_INSTALL='/usr/local/lib/python2.7/site-packages/scapy'
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
rm -f $SCAPY_INSTALL/sendrecv.pyc
elif [ -d '/usr/local/lib/python2.6/dist-packages/scapy' ]; then
# patch sendrecv.py
SCAPY_INSTALL='/usr/local/lib/python2.6/dist-packages/scapy'
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
rm -f $SCAPY_INSTALL/sendrecv.pyc
else
echo '[-] Default scapy path not found. Should be around /usr/local/lib/python2.[6|7]/site-packages/scapy'
echo -n '[-] Specify scapy install location: '
read SCAPY_INSTALL
if [ -d "$SCAPY_INSTALL" ]; then
mv $SCAPY_INSTALL/sendrecv.py $SCAPY_INSTALL/sendrecv_backup.py 2>/dev/null
cp ./install/sendrecv.py $SCAPY_INSTALL/sendrecv.py
rm -f $SCAPY_INSTALL/sendrecv.pyc
else
echo -n '[-] Scapy install not found. Enter "y" to download and install, or "n" to exit: '
read TMP
if [ "$TMP" == 'n' ]; then
exit 1
else
install
patch
fi
fi
fi
# check for airodump-ng, but dont install
AD= `which airodump-ng`
if [ $AD == '' ]; then
echo '[-] Airodump-ng not found. This is required for any wireless modules.'
fi
# check IP forwarding
FORWARDING=`cat /proc/sys/net/ipv4/ip_forward`
if [ $FORWARDING == '0' ]; then
echo '[-] IPv4 forwarding is disabled. Enabling...'
sudo sh -c 'echo "1" > /proc/sys/net/ipv4/ip_forward'
fi
echo -e "[+] Zarp install complete. Run with:\n\tsudo python zarp.py"