Skip to content

Commit

Permalink
[NetworkBrowser]
Browse files Browse the repository at this point in the history
* This fixes a hostname issue if using a remote DNS, nmap can resolve hostnames if it has access to the local DNS.
  • Loading branch information
m4dhouse committed Dec 8, 2024
1 parent d6d841a commit 07f8d1b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions networkbrowser/src/NetworkBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,17 @@ def setStatus(self, status=None):
def makeStrIP(self):
self.IP = iNetwork.getAdapterAttribute(self.iface, "ip")
self.netmask = iNetwork.getAdapterAttribute(self.iface, "netmask")
if self.IP and self.netmask and len(self.IP) == 4 and len(self.netmask) == 4 and sum(self.IP) and sum(self.netmask):
self.gateway = iNetwork.getAdapterAttribute(self.iface, "gateway")
if (
self.IP and self.netmask and self.gateway
and len(self.IP) == 4 and len(self.netmask) == 4 and len(self.gateway) == 4
and sum(self.IP) and sum(self.netmask) and sum(self.gateway)
):
strCIDR = str(sum((bin(x).count('1') for x in self.netmask)))
strIP = '.'.join((str(ip & mask) for ip, mask in zip(self.IP, self.netmask))) + "/" + strCIDR
return strIP
return None
strGateway = ".".join(map(str, self.gateway))
return strGateway, strIP
return None, None

def process_NetworkIPs(self):
self.inv_cache = 0
Expand All @@ -265,9 +271,9 @@ def process_NetworkIPs(self):
print('[Networkbrowser] Getting fresh network list')
self.networklist = self.getNetworkIPs()
if fileExists("/usr/bin/nmap"):
strIP = self.makeStrIP()
if strIP:
self.Console.ePopen("nmap -oX - " + strIP + ' -sP 2>/dev/null', self.Stage1SettingsComplete)
strGateway, strIP = self.makeStrIP()
if strGateway and strIP:
self.Console.ePopen("nmap --dns-servers " + strGateway + " -oX - " + strIP + ' -sP 2>/dev/null', self.Stage1SettingsComplete)
else:
self.session.open(MessageBox, _("Your network interface %s is not properly configured, so a network scan cannot be done.\nPlease configure the interface and try again.") % self.iface, type=MessageBox.TYPE_ERROR)
self.setStatus('error')
Expand All @@ -287,8 +293,8 @@ def process_NetworkIPs(self):

def getNetworkIPs(self):
nwlist = []
strIP = self.makeStrIP()
if strIP:
strGateway, strIP = self.makeStrIP()
if strGateway and strIP:
try:
nwlist = netscan.netzInfo(strIP)
except:
Expand Down

0 comments on commit 07f8d1b

Please sign in to comment.