关闭

单线程端口扫描

标签: socket线程
198人阅读 评论(0) 收藏 举报
分类:
#_*_coding:utf-8_*_
import sys
from socket import *

host = sys.argv[1]
portstrs = sys.argv[2].split('-')

start_port = int(portstrs[0])
end_port = int(portstrs[1])

target_ip = gethostbyname(host)
opened_ports = []
for port in range(start_port,end_port+1):
    sock = socket(AF_INET,SOCK_STREAM)
    sock.settimeout(10)
    result = sock.connect_ex((target_ip,port))
    if result == 0:
        opened_ports.append(port)
print ("Opened Ports:")
for i in opened_ports:
    print i

python Scan_Ports_01.py host start_port-end_ports

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:21842次
    • 积分:448
    • 等级:
    • 排名:千里之外
    • 原创:22篇
    • 转载:0篇
    • 译文:0篇
    • 评论:1条
    最新评论