def portscantcp (port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
global checklist
con = s.connect((target, port))
try:
m=0
for i in checklist:
if str(port)==checklist[i]['port']:
m=1
x = str(port) + ',,' + str(socket.getservbyport(port, 'tcp')) + ',,' + 'tcp'+",,"+'old'
if(m==0):
x = str(port) + ',,' + str(socket.getservbyport(port, 'tcp')) + ',,' + 'tcp'+",,"+'new'
list.append(x)
except:
n=0
for i in checklist:
if str(port)==checklist[i]['port']:
n=1
x = str(port) + ',,' + 'SERVICE_NOT_FOUND' + ',,' + 'tcp'+",,"+'old'
if n==0:
x = str(port) + ',,' + 'SERVICE_NOT_FOUND' + ',,' + 'tcp'+",,"+'new'
list.append(x)
con.close()
except:
pass
评论列表
文章目录