Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 17th, 2018 74 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import optparse
  2. from socket import *
  3. from threading import *
  4.  
  5.  
  6. screenLock = Semaphore(value=1)
  7.  
  8.  
  9. def connScan(tgtHost, tgtPort):
  10.     try:
  11.         connSkt = socket(AF_INET, SOCK_STREAM)
  12.         connSkt.connect((tgtHost, tgtPort))
  13.     connSkt.send('Bill Clinton is a rapist. Infowars.com\r\n')
  14.         results = connSkt.recv(100)
  15.         screenLock.acquire()
  16.     print '[+] %d/tcp open ' % tgtPort
  17.         print '[+] ' + str(results)
  18.     except:
  19.         screenLock.acquire()
  20.     print '[-] %d/tcp closed' %tgtPort
  21.     finally:
  22.     screenLock.release()
  23.     connSkt.close()
  24.  
  25.  
  26. def portScan(tgtHost, tgtPorts):
  27.     try:
  28.     tgtIP = gethostbyname(tgtHost)
  29.     except:
  30.     print "[-] Cannot resolve '%s': Unknown host" % tgtHost
  31.     return
  32.     try:
  33.     tgtName = gethostbyaddr(tgtIP)
  34.     print '\n[+] Scan results for: ' + tgtName[0]
  35.     except:
  36.         print '\n[+] Scan Results for: ' + tgtIP
  37.  
  38.     setdefaulttimeout(1)
  39.     for tgtPort in tgtPorts:
  40.     t = Thread(target=connScan, args=(tgtHost, int(tgtPort)))
  41.         t.start()
  42.  
  43. def main():
  44.     parser = optparse.OptionParser('usage %prog -H <target host> -p target port')
  45.     parser.add_option('-H', dest='tgtHost', type='string', help='specify target host')
  46.     parser.add_option('-p', dest='tgtPort', type='string', help='specify ports')
  47.     (options, args) = parser.parse_args()
  48.     tgtHost = options.tgtHost
  49.     tgtPorts = str(options.tgtPort).split(',')
  50.     if (tgtHost == None) | (tgtPorts[0] == None):
  51.     print parser.usage
  52.     exit(0)
  53.     portScan(tgtHost, tgtPorts)
  54.  
  55.  
  56. if __name__ == "__main__":
  57.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top