(self)
ARPing the local network
ARPing the local network
ARPing the local network
def scan_block(self):
        """ ARPing the local network
        """
        net_mask = self.config['net_mask'].value
        conf.verb = 0
        print '[!] Beginning host scan with netmask %s...' % (net_mask)
        try:
            start = datetime.now()
            (ans, unans) = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=net_mask),timeout=1, inter=0.1,multi=True)
            elapsed = (datetime.now() - start).seconds
            print '[!] Scan of %s completed in %s seconds with %d hosts responding.'%(net_mask,elapsed,len(ans))
            for s, r in ans:
                ip = r[ARP].getfieldval('psrc')
                mac = r[ARP].getfieldval('hwsrc')
                if self.config['fingerprint'].value:
                    host = ''
                    try:
                        if hasattr(socket, 'setdefaulttimeout'):
                            socket.setdefaulttimeout(3)
                        host = socket.gethostbyaddr(ip)[0]
                    except:
                        host = ''
                    print "\t%s : %s (%s)" % (mac, ip, host)
                    self._dbhost(mac, ip, host)
                else:
                    print '\t%s : %s' % (mac, ip)
                    self._dbhost(mac, ip, '')
                self.available_hosts[mac] = ip
        except Exception:
            Error('Error with net mask.  Cannot scan given block.')
            return
        print '\n'
def scan_block ( self ) : net_mask = self . config [ 'net_mask' ] . value conf . verb = 0 print '[!] Beginning host scan with netmask %s...' % ( net_mask ) try : start = datetime . now ( ) ( ans , unans ) = srp ( Ether ( dst = "ff:ff:ff:ff:ff:ff" ) / ARP ( pdst = net_mask ) , timeout = 1 , inter = 0.1 , multi = True ) elapsed = ( datetime . now ( ) - start ) . seconds print '[!] Scan of %s completed in %s seconds with %d hosts responding.' % ( net_mask , elapsed , len ( ans ) ) for s , r in ans : ip = r [ ARP ] . getfieldval ( 'psrc' ) mac = r [ ARP ] . getfieldval ( 'hwsrc' ) if self . config [ 'fingerprint' ] . value : host = '' try : if hasattr ( socket , 'setdefaulttimeout' ) : socket . setdefaulttimeout ( 3 ) host = socket . gethostbyaddr ( ip ) [ 0 ] except : host = '' print "\t%s : %s (%s)" % ( mac , ip , host ) self . _dbhost ( mac , ip , host ) else : print '\t%s : %s' % ( mac , ip ) self . _dbhost ( mac , ip , '' ) self . available_hosts [ mac ] = ip except Exception : Error ( 'Error with net mask.  Cannot scan given block.' ) return print '\n'