Skip to content

Instantly share code, notes, and snippets.

@vck
Created December 9, 2014 10:47
Show Gist options
  • Select an option

  • Save vck/14865598fb3aa0f7d8f4 to your computer and use it in GitHub Desktop.

Select an option

Save vck/14865598fb3aa0f7d8f4 to your computer and use it in GitHub Desktop.
# simple port scan module
import socket
import time
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
import string
num_list=list(string.digits)
def scanport(ip):
if ip in num_list:
for port in range(1,1025):
try:
cek=sock.connect_ex((ip ,port))
if cek == 0:
print 'port : '+ str(port) + ' is open'
except Exception:
print 'False'
else:
ipp=socket.gethostbyname(ip)
print '[-] scanning ' + str(ipp)
time.sleep(3)
for port2 in range(1,4000):
try:
check2=sock.connect_ex((ipp, port2))
if check2 == 0:
print 'Port open : ',port2
except Exception:
print 'False'
@vck
Copy link
Author

vck commented Dec 9, 2014

😄 it's pretty primitive !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment