ChuMu博客

程序员安全渗透测试

发布于 / 169 次围观 / 0 条评论 / ChuMu
import socket

def scanhostport():
    for port in range(80, 81):
        conn = socket.socket(2, 1)    # 创建 socket 对象
        try:
            conn.connect(("172.16.104.246", port))          #建立连接
            print('Port %d Is Open' % port)
            conn.close()      # 关闭连接
        except:
            pass

scanhostport()