Advertisement
skip420

Host

Sep 29th, 2022
1,210
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # python host.py
  2. # skip420@skip420:~/Desktop$ python host.py
  3. # Enter the host to be scanned: "www.yahoo.com"
  4. # ('Starting scan on host: ', '202.165.107.49')
  5.  
  6.  
  7. from socket import *
  8. import time
  9. startTime = time.time()
  10.  
  11. if __name__ == '__main__':
  12.    target = input('Enter the host to be scanned: ')
  13.    t_IP = gethostbyname(target)
  14.    print ('Starting scan on host: ', t_IP)
  15.    
  16.    for i in range(50, 500):
  17.       s = socket(AF_INET, SOCK_STREAM)
  18.      
  19.       conn = s.connect_ex((t_IP, i))
  20.       if(conn == 0) :
  21.          print ('Port %d: OPEN' % (i,))
  22.       s.close()
  23. print('Time taken:', time.time() - startTime)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement