Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import socket
- import threading
- import time
- import string
- from threading import *
- import random
- from random import shuffle
- class scanports(threading.Thread):
- def __init__(self,address,port,gotit,ports,servs):
- threading.Thread.__init__(self)
- self.address=address
- self.port=port
- self.ports=ports
- self.servs=servs
- def run(self):
- global gotit
- try:
- conn=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- conn.settimeout(3)
- conn.connect((self.address,self.port))
- conn.close()
- gotit='y'
- # prt=self.ports.index(self.port)
- sys.stdout.write("\r")
- sys.stdout.flush()
- print '--> '+self.address,str(self.port)+' '+str(self.servs[self.ports.index(self.port)])+' '*30
- except:
- pass
- def main(address):
- abcd=[]
- abcd=map(int,address.split("."))
- global gotit
- gotit='n'
- print "scan what?"
- print "1 default"
- print "2 Microsoft"
- print "3 Cisco"
- print "4 IBM"
- print "5 Apple"
- print "6 VMs"
- print "7 All previous"
- print "8 1->1023"
- scanwhat=raw_input('choose: ')
- scanwhat=scanwhat.strip()
- print # just graphics
- try:
- if int(scanwhat)<1 or int(scanwhat)>8:
- scanwhat=1
- except:
- scanwhat=1
- if int(scanwhat)==1: # default
- # ports=[53]
- # servs=['dns']
- ports=[1,7,21,22,23,25,53,80,135,139,512,513,514,1050,5900,5901,5902,5903,5904,5905,5906,5907]
- servs=['global','icmp','ftp','ssh','telnet','smtp','dns','http','smb','netbios','rexec','rlogin','shell','javasrv','vnc','vnc','vnc','vnc','vnc','vnc','vnc','vnc']
- if int(scanwhat)==2: # Microsoft
- ports=[135,137,138,139,445,593,808,987,1026,1029,1270,1433,1434,1512,1533,1688,1723,1755,1801,1863,3268,3269,3389,4125,4502,5555,6600,6601,6602,9001]
- servs=['wins','netbios','netbios','netbios','win-share','exchange-srv','.Net sharing','SBS sharepoint','DCOM','DCOM','SCOM/MOM','MSSQL','MSSQL','wins','MSSQL','key service','PPTP','MMS','Message queue','MSNP','LDAP global catalog','LDAP global catalog','RDP','remote web workplace','Silverlight','dynamcs CRM','hyper-V','threat management gateway','WSS comm','Sharepoint']
- if int(scanwhat)==3: # Cisco
- ports=[465,711,1645,1546,1994,1998,2000,4224,5070,7010,8002,9001,16384,16482,2001,4001,6001]
- servs=['URL rendezvous','TAG Distribution','Radius auth','Radius auth','STUN-SDLC tunneling','X25overTCP','SCCP/skinny','Audio tunneling','CUPS','AON-AMC console','call manager intercluster','remote conf','RTP min','RTP max','Cisco','Cisco','Cisco']
- if int(scanwhat)==4: # IBM
- ports=[175,657,888,1058,1059,1352,1414,1500,1501,1533,1580,1581,1920,2105,2809,3900,4035,5010,5011,5104,5412,5495,5656,8008,8801,9300]
- servs=['IBMz-VM','RMC','endpoint manager','NIM','NIMreg','Lotus RPC','Websphere','Tivoli manager','Tivoli manager','Sametime IM','Tivoli manager','Tivoli manager','Tivoli console','Minipay','Websphere bootstrap','Unidata','Rational for SystemZ','telepath','telepath','Tivoli HTTP','Rational Synergy','IBM Cognos TM1','Lotus p2p','HTTP-srv','Websphere','Cognos8']
- if int(scanwhat)==5: # Apple
- ports=[123,201,311,387,548,626,660,687,2195,2196,2336,3031,3283,3659,3689,4100,4488,5223,5988,16080,27015]
- servs=['time','appletalk','OSX Appleshare','Appletalk routing','filing-share','ASIA-share','Server ADMIN','Server ADMIN','Push notify','Push notify service','Mobile SYNC','Remote events','Remote desktop','OSX password server','DAAP iTunes','Watchguard','Wide area connectivity','Apple push notify','Remote http-Desktop','OSX server Web','Mobile service']
- if int(scanwhat)==6: # VMs
- ports=[657,901,902,903,2179,5480,8222,8333,8887,8888,9443,5900]
- servs=['IBM RMC','VMWare client','VMware Server','VMware remote control','VMware srv alternate','VMConnect to Hyper-V hosts','Vmware VAMI','VMware srv mngmt','VMware srv mngt','HyperVM HTTP','HyperVM HTTPS','VMware Vcenter mngmt']
- if int(scanwhat)==7: # ALL previous
- ports=[1,21,22,23,25,53,80,135,139,512,513,514,1050,5900,5901,5902,5903,5904,5905,5906,5907,135,137,138,139,445,593,808,987,1026,1029,1270,1433,1434,1512,1533,1688,1723,1755,1801,1863,3268,3269,3389,4125,4502,5555,6600,6601,6602,9001,465,711,1645,1546,1994,1998,2000,4224,5070,7010,8002,9001,16384,16482,175,657,888,1058,1059,1352,1414,1500,1501,1533,1580,1581,1920,2105,2809,3900,4035,5010,5011,5104,5412,5495,5656,8008,8801,9300,123,201,311,387,548,626,660,687,2195,2196,2336,3031,3283,3659,3689,4100,4488,5223,5988,16080,27015,657,901,902,903,2179,5480,8222,8333,8887,8888,9443,5900,2001,4001,6001]
- servs=['global','ftp','ssh','telnet','smtp','dns','http','smb','netbios','rexec','rlogin','shell','javasrv','vnc','vnc','vnc,','vnc','vnc','vnc','vnc','vnc','wins','netbios','netbios','netbios','win-share','exchange-srv','.Net sharing','SBS sharepoint','DCOM','DCOM','SCOM/MOM','MSSQL','MSSQL','wins','MSSQL','key service','PPTP','MMS','Message queue','MSNP','LDAP global catalog','LDAP global catalog','RDP','remote web workplace','Silverlight','dynamcs CRM','hyper-V','threat management gateway','WSS comm','Sharepoint','URL rendezvous','TAG Distribution','Radius auth','Radius auth','STUN-SDLC tunneling','X25overTCP','SCCP/skinny','Audio tunneling','CUPS','AON-AMC console','call manager intercluster','remote conf','RTP min','RTP max','IBMz-VM','RMC','endpoint manager','NIM','NIMreg','Lotus RPC','Websphere','Tivoli manager','Tivoli manager','Sametime IM','Tivoli manager','Tivoli manager','Tivoli console','Minipay','Websphere bootstrap','Unidata','Rational for SystemZ','telepath','telepath','Tivoli HTTP','Rational Synergy','IBM Cognos TM1','Lotus p2p','HTTP-srv','Websphere','Cognos8','time','appletalk','OSX Appleshare','Appletalk routing','filing-share','ASIA-share','Server ADMIN','Server ADMIN','Push notify','Push notify service','Mobile SYNC','Remote events','Remote desktop','OSX password server','DAAP iTunes','Watchguard','Wide area connectivity','Apple push notify','Remote http-Desktop','OSX server Web','Mobile service','IBM RMC','VMWare client','VMware Server','VMware remote control','VMware srv alternate','VMConnect to Hyper-V hosts','Vmware VAMI','VMware srv mngmt','VMware srv mngt','HyperVM HTTP','HyperVM HTTPS','VMware Vcenter mngmt','Cisco','Cisco','Cisco']
- if int(scanwhat)==8: # 1->1024
- ports=range(1,1024)
- servs=range(1,1024) # TODO
- try:
- while True:
- addr=str(abcd[0])+'.'+str(abcd[1])+'.'+str(abcd[2])+'.'+str(abcd[3])
- for port in ports:
- sys.stdout.write('\r'+' '*87)
- sys.stdout.flush()
- sys.stdout.write("\r"+addr+" - scanning port: "+str(port)+' '+str(servs[ports.index(port)])+' ')
- sys.stdout.flush()
- launchscanports=scanports(addr,port,gotit,ports,servs)
- launchscanports.start()
- while threading.activeCount()>256:
- time.sleep(0.0001)
- time.sleep(0.000976563) # 1sec/1024th
- abcd[3]+=1
- if abcd[3]==256:
- if gotit=='y':
- gotit='n'
- while threading.activeCount()>1:
- time.sleep(0.0001)
- sys.stdout.write('\r'+' '*87)
- sys.stdout.flush()
- sys.stdout.write('\r')
- sys.stdout.flush()
- tocont=raw_input('continue [Y|n]: ')
- tocont=tocont.strip()
- if tocont=='n':
- raise KeyboardInterrupt
- print # only graphics
- abcd[3]=0
- abcd[2]+=1
- if abcd[2]==256:
- abcd[2]=0
- abcd[1]+=1
- if abcd[1]==256:
- abcd[0]=0
- abcd[0]+=1
- if abcd[0]==256:
- raise KeyboardInterrupt
- except KeyboardInterrupt:
- sys.stdout.write('\r'+' '*87)
- sys.stdout.flush()
- while threading.activeCount()>1:
- sys.stdout.write('\rwaiting threads to terminate: '+str(threading.activeCount())+' ')
- sys.stdout.flush()
- time.sleep(0.0001)
- sys.stdout.write('\r'+' '*37)
- sys.stdout.flush()
- print '\neop'
- sys.exit()
- if __name__ == "__main__":
- print "type ctrl-c to exit\n"
- address=sys.argv[1]
- main(address)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement