Results 1 to 3 of 3

Thread: nmap xml file grep

  1. #1
    Senior Member
    Join Date
    Jan 2010
    Posts
    173

    Default nmap xml file grep

    Hi All,

    can anyone assist in what im aiming for?

    I need to grep a nmap scan to save and cat the following lines in a xml file for product versions:

    <port protocol="tcp" portid="21"><state state="open" reason="syn-ack" reason_ttl="64"/><service name="ftp" product="vsftpd" version="2.3.4" ostype="Unix" method="probed" conf="10"><cpe>cpe:/a:vsftpd:vsftpd:2.3.4</cpe></service><script id="ftp-anon" output="Anonymous FTP login allowed (FTP code 230)"/></port>


    I would like the following to output to screen:
    portid="21" product="vsftpd" version="2.3.4"

    I eventually want to add it to search exploit db to sort of organise the services running for exploits.

    (ie) VSFTPD v2.3.4 Backdoor Command Execution

    or exploit/unix/ftp/vsftpd_234_backdoor

    so far I get this :

    ><service name="ftp" product="vsftpd" version="2.3.4" ostype="Unix" method="probed" conf="10"><cpe>cpe:
    ><service name="http" product="Apache httpd" version="2.2.8" extrainfo="(Ubuntu) DAV
    ><service name="http" product="Apache Tomcat


    any help is much appreciated...

    Kind regards dee

  2. #2
    Senior Member daedalus1776's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    112

    Default Re: nmap xml file grep

    Is it feasible to use the -oG switch in nmap to output in "Grepable format" for what you want to do?

  3. #3
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default Re: nmap xml file grep

    If daedalus' suggestion doesn't do it for you, grep/awk/sed are going to make it rough, at the guess
    Code:
    grep -iE '(portid|product|version)'
    Will pull out the appropriate lines. Something like
    Code:
    PORTID=$(echo $LINE | sed 's/.*portid="//g; s/".*//g')
    PRODUCT=$(echo $LINE | sed 's/.*product="//g; s/".*//g')
    And so on will get you the right lines and slap them into sub variables. Kind of. While you read line loops. But it's messy.

    I have this idea in the back of my head that you prefer python, which has ElementTree or something similar, perl has XML::Simple, php has a simple XML library, and so on. Use one of those, not bash, far safer and will keep you from pulling your hair out.

    Or use -oG, which is what grepping is designed for.
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

Similar Threads

  1. [nmap] - Erro no Nmap
    By F0K3R in forum Suporte Software
    Replies: 4
    Last Post: 12-08-2010, 09:58 PM
  2. grep the output of airodump
    By B34ST1Y in forum OLD Newbie Area
    Replies: 4
    Last Post: 01-03-2009, 12:15 PM
  3. Replies: 0
    Last Post: 09-03-2008, 08:05 AM
  4. better file info than file/strings
    By kr0m3 in forum OLD General IT Discussion
    Replies: 0
    Last Post: 07-24-2008, 01:25 PM
  5. Tranfert .txt file in Inbox thunderbird file
    By danathane in forum OLD Newbie Area
    Replies: 1
    Last Post: 07-21-2008, 07:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •