noblisnsp / volatility

Automatically exported from code.google.com/p/volatility
GNU General Public License v2.0
0 stars 0 forks source link

netscan crashes on Windows because inet_ntop isn't available #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The Windows builds of Python don't include socket.inet_ntop (see 
http://bugs.python.org/issue7171) and so netscan crashes when you run it from a 
Windows machine. 

We will need to implement our own inet_ntop functionality instead of relying on 
the socket module, in order to get cross-platform support. 

Original issue reported on code.google.com by michael.hale@gmail.com on 5 Feb 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Ok, here's a small file which implements inet_ntop only, and should return the 
same results as socket.inet_ntop on unix.

Best to only use it if necessary, I guess by checking hasattr(socket, 
'inet_ntop')?

Original comment by mike.auty@gmail.com on 5 Feb 2011 at 4:54

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mike.auty@gmail.com on 5 Feb 2011 at 4:55

GoogleCodeExporter commented 9 years ago
This looks good Mike. So here I've attached a patched version of netscan.py 
which imports your inet_ntop if socket.inet_ntop causes an AttributeError. I'm 
not sure if you want to leave inet_ntop.py as a separate file or just copy the 
function into netscan.py - up to you. 

Also, a friend helped me write another platform-independent version of 
inet_ntop so we have some benchmarking tools. 

Run on a Linux/OS X system...

$ python inet_ntop_tests.py 
Test 1 fe80::a7:938d:274:35ea
Test 2 fe80::a7:938d:274:35ea
Test 3 fe80::a7:938d:274:35ea

Test 1 fe80::6c1e:9e5d:acdd:4f95
Test 2 fe80::6c1e:9e5d:acdd:4f95
Test 3 fe80::6c1e:9e5d:acdd:4f95

Test 1 fe80::819:3442:3f57:ef7c
Test 2 fe80::819:3442:3f57:ef7c
Test 3 fe80::819:3442:3f57:ef7c

Test 1 172.16.237.155
Test 2 172.16.237.155
Test 3 172.16.237.155

Test 1 
Test 2 ::
Test 3 ::

In the output, "Test 3" is using the real socket.inet_ntop. "Test 1" is the one 
from my side, and "Test 2" is from your inet_ntop.py. So they all match except 
my output for the last test is "" instead of "::". 

Just attaching it here in case we need to further benchmark things in the 
future.
Test 1 0.0.0.0
Test 2 0.0.0.0
Test 3 0.0.0.0

Original comment by michael.hale@gmail.com on 5 Feb 2011 at 5:32

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r690.

Original comment by mike.auty@gmail.com on 5 Feb 2011 at 6:26

GoogleCodeExporter commented 9 years ago
Thanks, the first half of your implementation looks like glibc's 
implementation, but doesn't match towards the end.  I ended up going with my 
implementation because of the final Test where the results deviated from the 
canon implementation, and I did copy the function into the file, so that when 
windows does support it, we can just ditch the try/except bit.  Hope that's all 
ok?

Original comment by mike.auty@gmail.com on 5 Feb 2011 at 6:41