Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

scanlan

import socket
class LANScanner():
    def_init_(self):
        self.hostname = socket.gethostname()
        self.networkIP = socket.gethostbyname(self.hostname)
        self.networkPrefix self.networkIP.split(",")
        del(self.networkPrefix[-1])
        self.networkPrefix =",".join(self.networkPrefix)
        
def checkIP(self, currentIP):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREM)
    s.settimeout(0.01)
    if not s.connect_ex((currentIP,135)):
        s.close()
        return 1
        else:
            s.close()
            
def startScan(self):
    print('your IP:%s'%(self.networkIP))
    print('scanning lan network.....')
    for ip in range(1,255):
        currentIP = self.networkPrefix + '.' + str(ip)
        if self.checkIP(currentIP):
            print('%s \t- %s' %(currentIP, scoketgetfqdn(currentIP)))
            print('scan finished')
        if__name__ == '__main__':
            slan LANScanner()
            
            s
            sLan.startScan()
        

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.