Advertisement
Guest User

Untitled

a guest
Sep 13th, 2014
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.62 KB | None | 0 0
  1. import sys
  2. import socket
  3. import threading
  4. import time
  5. import string
  6. from threading import *
  7. import random
  8. from random import shuffle
  9.  
  10. class scanports(threading.Thread):
  11. def __init__(self,address,port,gotit,ports,servs):
  12. threading.Thread.__init__(self)
  13. self.address=address
  14. self.port=port
  15. self.ports=ports
  16. self.servs=servs
  17. def run(self):
  18. global gotit
  19. try:
  20. conn=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  21. conn.settimeout(3)
  22. conn.connect((self.address,self.port))
  23. conn.close()
  24. gotit='y'
  25. # prt=self.ports.index(self.port)
  26. sys.stdout.write("\r")
  27. sys.stdout.flush()
  28. print '--> '+self.address,str(self.port)+' '+str(self.servs[self.ports.index(self.port)])+' '*30
  29. except:
  30. pass
  31.  
  32. def main(address):
  33. abcd=[]
  34. abcd=map(int,address.split("."))
  35. global gotit
  36. gotit='n'
  37.  
  38. print "scan what?"
  39. print "1 default"
  40. print "2 Microsoft"
  41. print "3 Cisco"
  42. print "4 IBM"
  43. print "5 Apple"
  44. print "6 VMs"
  45. print "7 All previous"
  46. print "8 1->1023"
  47. scanwhat=raw_input('choose: ')
  48. scanwhat=scanwhat.strip()
  49. print # just graphics
  50. try:
  51. if int(scanwhat)<1 or int(scanwhat)>8:
  52. scanwhat=1
  53. except:
  54. scanwhat=1
  55.  
  56. if int(scanwhat)==1: # default
  57. # ports=[53]
  58. # servs=['dns']
  59. ports=[1,7,21,22,23,25,53,80,135,139,512,513,514,1050,5900,5901,5902,5903,5904,5905,5906,5907]
  60. servs=['global','icmp','ftp','ssh','telnet','smtp','dns','http','smb','netbios','rexec','rlogin','shell','javasrv','vnc','vnc','vnc','vnc','vnc','vnc','vnc','vnc']
  61. if int(scanwhat)==2: # Microsoft
  62. 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]
  63. 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']
  64. if int(scanwhat)==3: # Cisco
  65. ports=[465,711,1645,1546,1994,1998,2000,4224,5070,7010,8002,9001,16384,16482,2001,4001,6001]
  66. 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']
  67. if int(scanwhat)==4: # IBM
  68. 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]
  69. 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']
  70. if int(scanwhat)==5: # Apple
  71. ports=[123,201,311,387,548,626,660,687,2195,2196,2336,3031,3283,3659,3689,4100,4488,5223,5988,16080,27015]
  72. 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']
  73. if int(scanwhat)==6: # VMs
  74. ports=[657,901,902,903,2179,5480,8222,8333,8887,8888,9443,5900]
  75. 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']
  76. if int(scanwhat)==7: # ALL previous
  77. 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]
  78. 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']
  79. if int(scanwhat)==8: # 1->1024
  80. ports=range(1,1024)
  81. servs=range(1,1024) # TODO
  82.  
  83. try:
  84. while True:
  85. addr=str(abcd[0])+'.'+str(abcd[1])+'.'+str(abcd[2])+'.'+str(abcd[3])
  86. for port in ports:
  87. sys.stdout.write('\r'+' '*87)
  88. sys.stdout.flush()
  89. sys.stdout.write("\r"+addr+" - scanning port: "+str(port)+' '+str(servs[ports.index(port)])+' ')
  90. sys.stdout.flush()
  91. launchscanports=scanports(addr,port,gotit,ports,servs)
  92. launchscanports.start()
  93.  
  94. while threading.activeCount()>256:
  95. time.sleep(0.0001)
  96. time.sleep(0.000976563) # 1sec/1024th
  97.  
  98. abcd[3]+=1
  99. if abcd[3]==256:
  100. if gotit=='y':
  101. gotit='n'
  102.  
  103. while threading.activeCount()>1:
  104. time.sleep(0.0001)
  105.  
  106. sys.stdout.write('\r'+' '*87)
  107. sys.stdout.flush()
  108. sys.stdout.write('\r')
  109. sys.stdout.flush()
  110. tocont=raw_input('continue [Y|n]: ')
  111. tocont=tocont.strip()
  112. if tocont=='n':
  113. raise KeyboardInterrupt
  114. print # only graphics
  115. abcd[3]=0
  116. abcd[2]+=1
  117.  
  118. if abcd[2]==256:
  119. abcd[2]=0
  120. abcd[1]+=1
  121.  
  122. if abcd[1]==256:
  123. abcd[0]=0
  124. abcd[0]+=1
  125.  
  126. if abcd[0]==256:
  127. raise KeyboardInterrupt
  128.  
  129. except KeyboardInterrupt:
  130. sys.stdout.write('\r'+' '*87)
  131. sys.stdout.flush()
  132. while threading.activeCount()>1:
  133. sys.stdout.write('\rwaiting threads to terminate: '+str(threading.activeCount())+' ')
  134. sys.stdout.flush()
  135. time.sleep(0.0001)
  136. sys.stdout.write('\r'+' '*37)
  137. sys.stdout.flush()
  138. print '\neop'
  139. sys.exit()
  140.  
  141.  
  142. if __name__ == "__main__":
  143. print "type ctrl-c to exit\n"
  144. address=sys.argv[1]
  145. main(address)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement