Skip to content

Instantly share code, notes, and snippets.

@bonsaiviking
Created December 20, 2013 22:18
Show Gist options
  • Save bonsaiviking/8062547 to your computer and use it in GitHub Desktop.
Save bonsaiviking/8062547 to your computer and use it in GitHub Desktop.
YMMV, but this should export a PNG of a zenmap topology from a Nmap XML file
#!/usr/bin/env python
import sys
if len(sys.argv) != 4:
print """{0} - Output a PNG from Nmap XML
Usage: {0} <scan.xml> <out.png> <width_in_pixels>""".format(sys.argv[0])
sys.exit(1)
try:
from zenmapGUI.TopologyPage import *
except ImportError:
import sys
sys.path.insert(0,"/edit/me/path/to/zenmap")
from zenmapGUI.TopologyPage import *
t = TopologyPage(NetworkInventory(sys.argv[1]))
pix = int(sys.argv[3])
t.radialnet.set_allocation((0,0,pix,pix))
t.update_radialnet()
t.radialnet.save_drawing_to_file(sys.argv[2])
@1990113602
Copy link

this is a pretty useful script that i used to look for everywhere.today,i tired to integrate it with my java application,but it doesn't works ok,even though upgrade my Ubuntu(12.04).

apt-get update
apt-get upgrade
.....

root@bt:/tmp#whereis zenmap
zenmap: /usr/bin/zenmap /usr/bin/X11/zenmap /usr/local/bin/zenmap /usr/share/zenmap /usr/share/man/man1/zenmap.1.gz

root@bt:/tmp# python cli_zenmap_png.py /tmp/1.xml /tmp/2.png 256
/usr/lib/pymodules/python2.6/gtk-2.0/gtk/init.py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
File "cli_zenmap_png.py", line 17, in
t = TopologyPage(NetworkInventory(sys.argv[1]))
File "/usr/local/lib/python2.6/dist-packages/zenmapCore/NetworkInventory.py", line 114, in init
self.open_from_file(filename)
File "/usr/local/lib/python2.6/dist-packages/zenmapCore/NetworkInventory.py", line 284, in open_from_file
parsed = NmapParser(path)
TypeError: nmap_parser_sax() takes no arguments (1 given)
root@bt:/tmp#

i'm a java programmer,not python,forgive my poor python skills

how can i slove this problem?
thank you.

@mousumipaul
Copy link

Receiving the same error. Any update on it?

@mousumipaul
Copy link

It worked for me after replacing the source code of Networkinventry.py of zenmapcore from this link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment