Shell Script Needed to Parse Results


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Needed to Parse Results
# 1  
Old 08-20-2008
Shell Script Needed to Parse Results

Raw Results:

results|192.168.2|192.168.2.1|general/udp|10287|Security Note|For your information, here is the traceroute from 192.168.2.24 to 192.168.2.1 : \n192.168.2.24\n192.168.2.1\n\n
results|192.168.2|192.168.2.1|ssh (22/tcp)|22964|Security Note|An SSH server is running on this port.\n
results|192.168.2|192.168.2.1|ssh (22/tcp)|10267|Security Note|\nSynopsis :\n\nAn SSH server is listening on this port.\n\nDescription :\n\nIt is possible to obtain information about the remote SSH\nserver by sending an empty authentication request.\n\nRisk factor :\n\nNone\n\nPlugin output :\n\nSSH version : SSH-1.99-Cisco-1.25\n\n
results|192.168.2|192.168.2.1|general/tcp|11936|Security Note|\nRemote operating system : KYOCERA Printer\nConfidence Level : 48\nMethod : SinFP\n\n \nThe remote host is running KYOCERA Printer\n
results|192.168.2|192.168.2.1|general/tcp|19506|Security Note|Information about this scan : \n\nNessus version : 3.2.1\nPlugin feed version : 200806200134\nType of plugin feed : Direct\nScanner IP : 192.168.2.24\nPort scanner(s) : nessus_tcp_scanner \nPort range : default\nThorough tests : no\nExperimental tests : no\nParanoia level : 1\nReport Verbosity : 1\nSafe checks : yes\nOptimize the test : yes\nMax hosts : 20\nMax checks : 5\nRecv timeout : 5\nScan Start Date : 2008/6/25 11:26\nScan duration : 90 sec\n\n
results|192.168.2|192.168.2.1|general/tcp|21745|Security Note|\nSynopsis :\n\nIt was not possible to log into the remote host\n\nDescription :\n\nThe credentials provided for the scan did not allow us to log into the\nremote host.\n\n\nRisk factor : \n\nNone\n\nPlugin output : \n\n- It was not possible to log into the remote host via ssh\n\n


1. I am attempting to grab all lines beginning with results
2. Put the results in a tab format to export to excel
3. Break up into major columns: IP address, Service, VulID number, (Security Note, hole, or Warning),

(column 1)192.168.2.1 (column 2)general/tcp (column 3)21745 (column 4) Synopsis : It was not possible to log into the remote host. Description : The credentials provided for the scan did not allow us to log into the remote host. Risk factor : None Plugin output : It was not possible to log into the remote host via ssh


I have started on a very basic script:

> awk -F "|" '{print $3} | sort | uniq

The fields are not all the same which is posing a problem. Please help
# 2  
Old 08-20-2008
Why are you using sort and uniq? But you didn't mention anything about it?
As you want the fields to be tab delimited then the below comman will be useful :
awk -F "|" '{printf("%s\t%s\t%s\t%s\n", $3, $4,$5,$7}' results_file
# 3  
Old 08-20-2008
Code:
gawk -F"|" '$1 == "results" { gsub(/\\n/,"", $7); printf "%s\t%s\t%s\t%s\n", $3,$4,$5,$7}' file

gives the following output ($7 truncated for ease of viewing)
Code:
192.168.2.1     general/udp     10287   For your information, here is the tra
192.168.2.1     ssh (22/tcp)    22964   An SSH server is running on this port
192.168.2.1     ssh (22/tcp)    10267   Synopsis :An SSH server is listening 
192.168.2.1     general/tcp     11936   Remote operating system : KYOCERA
192.168.2.1     general/tcp     19506   Information about this scan : Nessus

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Emailing results of a pl sql procedure from UNIX shell script

Hello All, I am writing the below unix script to email the result of a small pl sql procedure: #!/bin/bash ORACLE_HOME=/opt/oracle/orcts/product/9.2.0; export ORACLE_HOME SQLPLUS=$ORACLE_HOME/bin/sqlplus sqlplus -s user/pass@Db_instance<<EOF set echo off set feedback off set pages 0... (9 Replies)
Discussion started by: Bunty bedi
9 Replies

2. Shell Programming and Scripting

awk parse snmp results

i run the command snmptable -v2c -c public myIP IF-MIB::ifTable the result look like this : SNMP table: IF-MIB::ifTable ifIndex ifDescr ifType ifMtu ifSpeed ifPhysAddress ifAdminStatus ifOperStatus 1 Unit: 1 Slot: 0 Port: 1... (7 Replies)
Discussion started by: wanttolearn1
7 Replies

3. UNIX for Dummies Questions & Answers

Help to parse csv file with shell script

Hello ! I am very aware that this is not the first time this question is asked here, because I have already read a lot of previous answers, but none of them worked, so... As said in the title, I want to read a csv file with a bash script. Here is a sample of the file: ... (4 Replies)
Discussion started by: Grhyll
4 Replies

4. Shell Programming and Scripting

awk script to parse results from TWO files

I am trying to parse two files and get data that does not match in one of the columns ( column 3 in my case ) Data for two files are as follows A.txt ===== abc 10 5 0 1 16 xyz 16 1 1 0 18 efg 30 8 0 2 40 ijk 22 2 0 1 25 B.txt ===== abc... (6 Replies)
Discussion started by: roger67
6 Replies

5. Shell Programming and Scripting

Shell script compare all parameters in two files and display results

Hi , I am not familiar with shell programming. I have a requirement like i have two files .I need to compare the two files by comparing each parameter and i should produce 2 outputs. 1)i have around 35 parameters say i have one parameter name called db_name=dcap in one file and... (7 Replies)
Discussion started by: muraliinfy04
7 Replies

6. Shell Programming and Scripting

shell script output in HTML or with table like results

Hello, Currently i have a ksh script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html or excel format and send that content as email. Please help me how i can do... (2 Replies)
Discussion started by: kotasateesh
2 Replies

7. Shell Programming and Scripting

Parse for errors shell script

All, I have a shell script which parses the /var/adm/messages file for errors every 15 minutes as a cron job. The script runs at 01, 16, 31, and 46 minutes every hour. The problem is if the error is encountered any time during the beginning of hour I can get paged three times. I would like to... (2 Replies)
Discussion started by: bubba112557
2 Replies

8. Shell Programming and Scripting

search file and print results with shell script

input file 1.<CRMSUB:MSIN=0100004735,BSNBC=TELEPHON-9814060328-TS11&TS21&TS22,NDC=9814,MSCAT=ORDINSUB,SUBRES=ALLPLMN-SPICE,BAOC=OIC,BAPRC=INFO,ACCSUB=BSS,NUMTYP=MULTI;... (3 Replies)
Discussion started by: dodasajan
3 Replies

9. Shell Programming and Scripting

Using Expect results in a Shell script

I am trying to write a shell script that launches an expect script and then use results of the expect script in the rest of the shell script. The expect script is connecting to a remote host and looking up certian user info like UID and home directory. This part is working I then want the... (2 Replies)
Discussion started by: kaltekar
2 Replies

10. UNIX for Dummies Questions & Answers

sql query results in unix shell script

Hi I want to get the a field from a SQL query into unix shell script variable. the whole situation is like this. 1. Opened a cursor to a table in DB2 databse. 2. Fetching individual rows with the help of cursor. 3. Each row has 4 fields. I want each of the field in individual shell... (1 Reply)
Discussion started by: skyineyes
1 Replies
Login or Register to Ask a Question