Skip to content

Commit

Permalink
Compensate for changes in 'netstat -rn' output on Vista
Browse files Browse the repository at this point in the history
  • Loading branch information
dloss committed Jul 20, 2009
1 parent d69e515 commit c557b53
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scapy/arch/windows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ def read_routes():
ok = 0
routes = []
ip = '(\d+\.\d+\.\d+\.\d+)\s+'
netstat_line = ip + ip + ip + ip + "(\d+)"
# On Vista and Windows 7 the gateway can be IP or 'on-link'.
# The exact 'on-link' string depends on the locale.
gw_pattern = '([\w\s]+|\d+\.\d+\.\d+\.\d+)\s+'
netstat_line = ip + ip + gw_pattern + ip + "(\d+)"
pattern = re.compile(netstat_line)
f=os.popen("netstat -rn")
for l in f.readlines():
Expand All @@ -246,6 +249,12 @@ def read_routes():

dest = atol(dest)
mask = atol(mask)
# If the gateway is no IP we assume it's on-link
gw_ipmatch = re.search('\d+\.\d+\.\d+\.\d+', gw)
if gw_ipmatch:
gw = gw_ipmatch.group(0)
else:
gw = netif
routes.append((dest,mask,gw, str(intf["name"]), addr))
f.close()
return routes
Expand Down

0 comments on commit c557b53

Please sign in to comment.