[Python] Python port scanner only port 80 open

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    When I run my python port scanner I only ever see port 80 open, regardless of the IP or website. I tested the code on testphp.vulnweb.com so I expected more than just port 80 open.

    import socket
    from IPy import IP

    def scan(target):
    converted_ip = check_ip(target)
    print('\n' + '[-_0 Scanning Target] ' + str(target))
    for port in range(1, 100):
    scan_port(converted_ip, port)

    def get_banner(s):
    return s.recv(1024)

    def check_ip(ip):
    try:
    IP(ip)
    return(ip)
    except ValueError:
    return socket.gethostbyname(ip)

    def scan_port(ipaddress, port):
    try:
    ## define a socket descriptor
    sock = socket.socket()
    sock.settimeout(0.5) ## in order to scan target faster, lose accuracy but gain time
    sock.connect((ipaddress, port))
    try:
    banner = get_banner(sock)
    print('[+] Open port' + str(port) + ' : ' + str(banner))
    except:
    print('[+] Open Port ' + str(port))
    except:
    pass


    targets = input('[+] Enter Target/s To Scan (split multiple targets with ,): ')
    if ',' in targets:
    for ip_add in targets.split(','):
    scan(ip_add.strip(' '))
    else:
    scan(targets)

    Continue reading...

Compartilhe esta Página