| 1 | #VERSION,2.02 |
|---|
| 2 | # $Id: nikto_report_csv.plugin 87 2008-11-11 19:13:19Z deity $ |
|---|
| 3 | ############################################################################### |
|---|
| 4 | # Copyright (C) 2007 CIRT, Inc. |
|---|
| 5 | # |
|---|
| 6 | # This program is free software; you can redistribute it and/or |
|---|
| 7 | # modify it under the terms of the GNU General Public License |
|---|
| 8 | # as published by the Free Software Foundation; version 2 |
|---|
| 9 | # of the License only. |
|---|
| 10 | # |
|---|
| 11 | # This program is distributed in the hope that it will be useful, |
|---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | # GNU General Public License for more details. |
|---|
| 15 | # |
|---|
| 16 | # You should have received a copy of the GNU General Public License |
|---|
| 17 | # along with this program; if not, write to the Free Software |
|---|
| 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | ############################################################################### |
|---|
| 20 | # PURPOSE: |
|---|
| 21 | # Reporting |
|---|
| 22 | ############################################################################### |
|---|
| 23 | sub nikto_report_csv_init |
|---|
| 24 | { |
|---|
| 25 | my $id = |
|---|
| 26 | { |
|---|
| 27 | name => "reports_csv", |
|---|
| 28 | full_name => "CSV reports", |
|---|
| 29 | author => "Deity", |
|---|
| 30 | description => "Produces a CSV report.", |
|---|
| 31 | report_head => \&csv_open, |
|---|
| 32 | report_item => \&csv_item, |
|---|
| 33 | report_format => 'csv', |
|---|
| 34 | copyright => "2008 CIRT Inc." |
|---|
| 35 | }; |
|---|
| 36 | return $id; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | sub csv_open |
|---|
| 40 | { |
|---|
| 41 | my ($file) = @_; |
|---|
| 42 | # Open file and produce header |
|---|
| 43 | open(OUT, ">>$file") || die print STDERR "+ ERROR: Unable to open '$file' for write: $@\n"; |
|---|
| 44 | |
|---|
| 45 | # Write header |
|---|
| 46 | print OUT "\"meta\",\"meta\",\"$NIKTO{name}\",\"v$NIKTO{version}/$NIKTO{core_version}\"\n"; |
|---|
| 47 | return OUT; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | sub csv_item |
|---|
| 51 | { |
|---|
| 52 | my ($handle, $mark, $item) = @_; |
|---|
| 53 | foreach my $uri (split(' ',$item->{uri})) |
|---|
| 54 | { |
|---|
| 55 | my $line; |
|---|
| 56 | $line.="\"$item->{mark}->{hostname}\","; |
|---|
| 57 | $line.="\"$item->{mark}->{port}\","; |
|---|
| 58 | $line.="\""; |
|---|
| 59 | if ($item->{osvdb}) { $line.="OSVDB-$item->{osvdb}: " }; |
|---|
| 60 | if ($item->{method}) { $line.="$item->{method} " }; |
|---|
| 61 | if ($uri) { $line.="${uri}: " }; |
|---|
| 62 | $line.=$item->{message}; |
|---|
| 63 | $line.="\""; |
|---|
| 64 | print $handle "$line\n"; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | 1; |
|---|