4rt1st's 垃圾回收站

Menu

Python 3 指定端口扫描

# coding:utf-8
import socket

ip = '192.168.1.1'

default_ports = [21, 22, 80, 1433, 3306, 3389]


def port_scan(ip, port):
    try:
        socket.setdefaulttimeout(3)
        s = socket.socket()
        s.connect((ip, port))
        print ('[+] port:%d\topen' % port)
        s.close()
    except:
        pass


if __name__ == '__main__':
    for port in default_ports:
        port_scan(ip, port)

如图所示:

 

— 于 共写了290个字
— 文内使用到的标签:

评论已关闭。