Skip to content

Instantly share code, notes, and snippets.

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])
from zenmapGUI.TopologyPage import *
except ImportError:
import sys
from zenmapGUI.TopologyPage import *
t = TopologyPage(NetworkInventory(sys.argv[1]))
pix = int(sys.argv[3])
Copy link

this is a pretty useful script that i used to look for,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 /tmp/1.xml /tmp/2.png 256
/usr/lib/pymodules/python2.6/gtk-2.0/gtk/ GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
File "", line 17, in
t = TopologyPage(NetworkInventory(sys.argv[1]))
File "/usr/local/lib/python2.6/dist-packages/zenmapCore/", line 114, in init
File "/usr/local/lib/python2.6/dist-packages/zenmapCore/", line 284, in open_from_file
parsed = NmapParser(path)
TypeError: nmap_parser_sax() takes no arguments (1 given)

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

how can i slove this problem?
thank you.

Copy link

Receiving the same error. Any update on it?

Copy link

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

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