I am hoping someone might be able to get me on the right track here. I need to parse nmap output with Python. I think using regex is going to be the right method for this, but I have never worked with regex. Here is a sample of the text I need to parse --> http://pastebin.com/QhG86D7D
What I need to do with this file is:
- I need the IP addresses.
- I need the open ports.
The trick is I need to obviously keep the IP and ports tied together as I will be importing them into a database that will show what ports are open for each IP.
I am also thinking I should write the logic into a function so I can parse different files with larger numbers of hosts.
I do know how to read the file into my script and put the data into my database. Where I am stuck is with the regex to parse out the data I need. Can someone help me out?
Thanks in advance!