码迷,mamicode.com
首页 > 编程语言 > 详细

python端口扫描

时间:2015-04-22 00:26:13      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

简易版:

#author:Blood_Zero
#coding:utf-8

import socket
import sys

PortList=[21,22,23,25,80,135]
#

host=sys.argv[1]

for i in PortList:
    sock=socket.socket()
    sock.settimeout(2)
    try:
        sock.connect((host,i))
        print "the port %d is open" %i
    except Exception:
        print "the port %d is not open" %i
    sock.close()

执行方法:python port_scan.py www.xx.com

后续还会出很多加强版!

 

python端口扫描

标签:

原文地址:http://www.cnblogs.com/BloodZero/p/4445691.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!