Created
August 11, 2010 17:27
-
-
Save swdunlop/519349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, lxml.etree as et | |
def purge_plugin( tree, id ): | |
print ':: Searching for %s Entries..' % id | |
targets = tree.findall( '//ReportItem[@pluginID="%s"]' % id ) | |
print ' Found %s entries.' % len( targets ) | |
print ':: Excising %s entries..' % id | |
for target in targets: | |
sys.stdout.write( '.' ) | |
sys.stdout.flush( ) | |
target.getparent( ).remove( target ) | |
def nsfix( src_path, dst_path, *plugins ): | |
print ':: Loading source file..' | |
tree = et.parse( src_path ) | |
for plugin in plugins: | |
purge_plugin( tree, plugin ) | |
print ':: Writing output file..' | |
tree.write( dst_path ) | |
print ':: Done.' | |
if __name__ == "__main__": | |
if len( sys.argv ) > 3: | |
nsfix( *sys.argv[1:] ) | |
else: | |
print >>sys.stderr, 'USAGE: nsfix <src.nessus> <dst.nessus> <plugin0> <plugin1> ...' | |
print >>sys.stderr, 'EX: nsfix sample.nessus dest.nessus 19506 11084' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment