SpareNet Servers Advertising & Link Exchange

اطلاعیه

بستن
هیچ اطلاعیه ای هنوز ایجاد نشده است .

basic port scanner

بستن
X
 
  • فیلتر
  • زمان
  • نمایش
پاک کردن همه
نوشته‌های جدید

  • basic port scanner

    سلام بچه ها براتون ی پورت اسکنر خوب گذاشتم.در عین حال ساده.حالشو ببرید [img]images/smilies/Smileys/10.gif[/img]
    کد:
    #! /usr/bin/env python
    # PortScanner.py
    
    from socket import *
    HostName = raw_input("Host Name: ")
    try:
        # gethostbyname(HostName) returns the IPv4 address of a website
        IPaddress = gethostbyname(HostName)
    except:
        print "[-] Could not find host."
        quit()
    portstring = raw_input("Ports (separated by commas):")
    ports = portstring.split(",")
    print "\n[*] Scan results for "+HostName+" ("+IPaddress+"):"
    # setdefaulttimeout(1) sets the waiting time for website response to 1 seconds. This may result in closed port even though the port may be open if it takes more than 1 second.
    setdefaulttimeout(1)
    for port in ports:
        try:
            connection = socket(AF_INET,SOCK_STREAM)
            # socket.connect((IP,PORT)) connect to the IP at given port.
            connection.connect((IPaddress,int(port)))
            connection.send('hello\r\n')
            # socket.recv(BUFFER_SIZE) receives the server response
            data = connection.recv(8)
            # If we have reached this far that means the port is open.
            print "\t[+] "+port+"/tcp open"
        except:
            print "\t[-] "+port+"/tcp closed"
        finally:
            connection.close()
صبر کنید ..
X