LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2015, 06:51 PM   #1
Bettlar
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Rep: Reputation: Disabled
Extracting Data from XML


G'day All,

Apologies for the newbie question and this is my first post. I am new to Linux and a little stuck with an issue.

I need to extract data from fields contained within a Nessus scan file(xml).

<?xml version="1.0"?>
<NessusClientData_v2>
<Report name="Local Disabled Users" xmlns:cm="http://www.nessus.org/cm">
<ReportHost name="192.168.201.195">
<HostProperties>
<tag name="host-fqdn">hostname.local</tag>
<tag name="netbios-name">hostname</tag>
</HostProperties>
<ReportItem port="0" svc_name="general" protocol="tcp" severity="0" pluginID="10913" pluginName="Microsoft Windows - Local Users Information : Disabled accounts" pluginFamily="Windows : User management">
<plugin_output>The following local user accounts have been disabled : - Administrator - Guest Note that, in addition to the Administrator and Guest accounts, Nessus has only checked for local users with UIDs between 1000 and 1200. To use a different range, edit the scan policy and change the 'Start UID' and/or 'End UID' preferences for 'SMB use host SID to enumerate local users' setting, and then re-run the scan.</plugin_output>
</ReportItem>
</ReportHost>
<ReportHost name="192.168.201.196">
<HostProperties>
<tag name="host-fqdn">WIN-MASS9PPBQKA.local</tag>
<tag name="netbios-name">WIN-MASS9PPBQKA</tag>
</HostProperties>
<ReportItem port="0" svc_name="general" protocol="tcp" severity="0" pluginID="10913" pluginName="Microsoft Windows - Local Users Information : Disabled accounts" pluginFamily="Windows : User management">
<plugin_output>The following local user accounts have been disabled : - Guest - TestCharlie - TestDelta Note that, in addition to the Administrator and Guest accounts, Nessus has only checked for local users with UIDs between 1000 and 1200. To use a different range, edit the scan policy and change the 'Start UID' and/or 'End UID' preferences for 'SMB use host SID to enumerate local users' setting, and then re-run the scan.</plugin_output>
</ReportItem>
</ReportHost>
</Report>
</NessusClientData_v2>


what do I need help with??.... well....

I am after capturing a list of local disabled users from within the scan file (unfortunately, this scan is all I have to work with)

I also need to capture select text from within the plugin_output tag - I have highlighted in blue the text required, this text can also vary depending on which server the scan has touched, I also need to extract the data in the NetBIOS-NAME and HOST-FQDN which I do not think is the difficult part?? - or is it?.

I also need output the data to csv in the format similar to....

HOST-FQDN NETBIOS-NAME PLUGIN_OUTPUT
hostname.local hostname Guest
WIN-MASS9PPBQKA.local WIN-MASS9PPBQKA TestCharlie


many thanks in advance

Bettlar
 
Old 10-19-2015, 07:25 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,818

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
start with posting the start of the script you are using

some documentation
http://www.tldp.org/LDP/abs/html/
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
 
Old 10-19-2015, 07:48 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Whilst its possible to extract that info from the xml file using bash tools, unless its always going to look exactly like that, I'd use Perl with the http://search.cpan.org/~grantm/XML-S.../XML/Simple.pm module which is much more flexible.
 
Old 10-19-2015, 08:04 PM   #4
Bettlar
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Many Thanks Guys, I'll read through your suggestions and see what I can come up with.

Unfortunately, I am not using any scripts at this stage, I have spent the past week researching tools that I have no experience with and this was my last resort. Apologies

I have found several articles from this forum that use sed and awk to achieve similar, however, as I said I do not have the understanding of these tools.

I will persevere and get an answer.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL to XML including data, DTD and XML Schema rm_-rf_windows Linux - General 3 07-06-2015 08:43 AM
extracting cache data from FF 4.0 entz Linux - Software 7 06-01-2011 06:36 PM
Extracting Data with Gawk iframe Linux - Software 8 05-13-2010 08:25 AM
extracting data from xml file using c in linux karthikmca Linux - Newbie 6 02-16-2010 01:24 AM
Data Parsing/Extracting anrchist007 Linux - Software 2 04-02-2009 07:12 AM


All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration