Saturday, 9 July 2011

If you for any reason have the need to merge / combine a few Nessus scans into a single *.nessus file, you can do so using this simple Python script. Since *.nessus files are basically just XML files with a different extension, what this script does is it finds all the *.nessus files in the current folder, finds all the “ReportHost” XML nodes accumulating them into a single report.nessus file which is then exported to nss_report folder.
Note that scans must be of the same type (same plugins must be used), but they can be from different subnets or different parts of the same subnet.
How to use it? – Put the script and all your *.nessus files into a same folder, run the script, import nss_report/report.nessus into Nessus – and there you have it, all the hosts are in one place..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #! /usr/bin/env python3.2
import xml.etree.ElementTree as etree
import shutil
import os
first = 1
for fileName in os.listdir("."):
if ".nessus" in fileName:
print(":: Parsing", fileName)
if first:
mainTree = etree.parse(fileName)
report = mainTree.find('Report')
first = 0
else:
tree = etree.parse(fileName)
for element in tree.findall('.//ReportHost'):
report.append(element)
print(":: => done.")
if "nss_report" in os.listdir("."):
shutil.rmtree("nss_report")
os.mkdir("nss_report")
mainTree.write("nss_report/report.nessus", encoding="utf-8", xml_declaration=True) |
If you have any questions, just drop a comment bellow..
Tags: nessus, python, reports
Posted in security | 1 Comment »
Thursday, 7 July 2011

Let’s say you need to filter a Python list and remove all elements that match a given criteria. If you wanted to remove a single element, you could just use ‘del list[i]‘ (example). But if you wanted to remove multiple elements this might be a problem since you would be modifying and iterating over the list at the same time (keeping track of list indexes can become very confusing, very fast).
A simple solution to this problem would be to keep record of all list elements (indexes) that need to be removed, and to remove tham afterwards. Also, one other thing to be wary about is that the removal process should be done in reverse because otherwise you would shift all the elements to the ‘left’ every time you removed an element from a list and you would (again) have to keep track of list indexes.
A simple function example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| matchingFilter = ['criteria1', 'criteria2']
def criteriaFiltering(aList, matchingFilter):
deletionIndexes = []
i = 0
for listLine in aList:
for match in matchingFilter:
if match in str(listLine):
continue
else:
deletionIndexes.append(i)
break
i += 1
for number in reversed(deletionIndexes):
del listLines[number]
return aList |
This might not be the fastest ‘algorithm’ to do the job, but it works well enough for me..
Tags: elements, list, python, removal
Posted in programming, tips & tricks | No Comments »
Friday, 4 March 2011

Turning on History plugin in Pidgin will insert the last conversation into your current conversation. All this lastsaid entries can be found somewhere inside of blist.xml file which is located in your Pidgin conf directory (/home/username/.purple directory in GNU/Linux (not sure about where it is in MS Windows though)).
This is convinient if you want to view what was written before you accidentialy closed the chat window or if you forgot what were you last talking about with someone and if you want that information quickly. But, it is not convinient at all if you want to wipe it along with chat logs since lastsaid entries are at a different location and are not the only entries that can be found in blist.xml so you can’t just remove that file either. If you use a couple of protocols and have more than just a few buddies, removing lastsaid lines from blist.xml manually would probably prove to be pain in the ass.
So, what every curious programmer does in case he doesn’t have a feature he wants/needs? – He just makes it. :D Since I started playing with Python, I decided to create a small py3k script I could use every once in a while to completely wipe both lastsaid history and chat logs from Pidgin.
What you need to do to make this script work is – you need to put it into your Pidgin conf directory (just put it into a file called something.py) and after that just run the script (you need to have python installed on your machine to run this script).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #! /usr/bin/env python3
import xml.etree.ElementTree as etree
import shutil
import os
# deletes 'lastsaid' blist.xml entries
if os.path.exists("blist.xml"):
tree = etree.parse("blist.xml")
buddies = tree.findall(".//buddy")
for buddy in buddies:
nodes = buddy.findall("setting")
for node in nodes:
if node.attrib == {"type": "string","name": "lastsaid"}:
buddy.remove(node)
tree.write("blist.xml")
# deletes chat log files if they exist
if os.path.exists("logs"):
shutil.rmtree("logs") |
I hope this helps. Also, if you have any questions/problems with the script, feel free to drop a comment..
Tags: history, logs, pidgin, python, removal, script
Posted in tips & tricks | No Comments »
Wednesday, 22 December 2010
(19:05:53) perovodokotlić: evo opet se dogodilo to
(19:05:57) perovodokotlić: ono kad ti padne nešto na pod ispod tebe
(19:05:58) perovodokotlić: i nestane
(19:06:04) perovodokotlić: trzalica
(19:06:06) perovodokotlić: nema je
(19:06:08) pootzko: :D
(19:06:10) perovodokotlić: pala mi je pod noge i nema je niiigdje
(19:06:12) pootzko: trzalice pogotovo
(19:06:16) pootzko: one kad padnu
(19:06:24) pootzko: otvore neki procjep u prostorno vremenskom kontinuumu
(19:06:31) pootzko: i odu u neki paralelni svemir
(19:06:34) pootzko: never to be found again
(19:06:39) perovodokotlić: hahaha
(19:07:59) pootzko: i šarafi isto
(19:08:00) pootzko: i neposlušne nikadprobavljene kokice
spontani red guglanja…

…i red slučajnog dalekointernetskog očitoistomišljenika

~ragetoons + ~mylifecomics
Tags: fffuuu, trzalice
Posted in music, web.log | 2 Comments »
Saturday, 18 December 2010

This one might just spare you about 2-3 hours of your time doing SVN+SSH kdesvn googling. One would think it would work out-of-the-box, but it doesn’t. To get kdesvn to work with SSH, there is one small undocumented trick – using an environment variable (as if you were using command line SVN+SSH). To do that, put the following line into your .bashrc:
1
| export SVN_SSH="ssh -l <your_remote_ssh_username>" |
If you try using SVN+SSH without it, kdesvn will try to login to remote server using your current username (the one you are using on your local machine). Of course, each time unsuccessfully because it’s not the right username. After that, go to Subversion->General->Checkout a repository, and enter:
1
| svn+ssh://path_to_your_svn_repository |
…in the URL field. Also, choose the target directory and check any other desired options. After that, just bookmark the connection and you’re all set up.
Tags: kdesvn, ssh, svn
Posted in linux, tips & tricks | No Comments »