-
Notifications
You must be signed in to change notification settings - Fork 1
/
nessus-parser.pl
3132 lines (2926 loc) · 189 KB
/
nessus-parser.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/opt/local/bin/perl
use strict;
use XML::TreePP;
use Data::Dumper;
use Math::Round;
use Excel::Writer::XLSX;
use Data::Table;
use Excel::Writer::XLSX::Chart;
use Getopt::Std;
#use Devel::Size qw(size total_size); ############# New module
print "";
## Copyright (C) 2016 Cody Dumont
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## This is a program to parse a series of Nessus XMLv2
## files into a XLSX file. The data from the XML file is placed into a series
## of tabs to for easier review and reporting. New features with this edition
## are better reporting of policy plugin families, user account reporting,
## summary graphs, and a home page with summary data. For more information
## and questions please contact Cody Dumont [email protected]
##
## Version 0.25
our %recast_plugin;
our (@installedSoftware,@portScanner,@vuln_entries,@host_scan_data,@WinWirelessSSID,@cpe_data,@PCIDSS,@ADUsers,@ScanInfo,@MS_Process_Info);
our (@WinUserData,@WinUsers,@WinGuestUserData,@PasswordPolicyData,@WirelessAccessPointDetection,@DeviceType,@EnumLocalGrp);
our $highvuln_cnt = 0;
our $medvuln_cnt = 0;
our $lowvuln_cnt = 0;
our $nonevuln_cnt = 0;
our $PolicySummaryReport_worksheet;
our $PolicySummaryReport_cnt;
our $center_format;
our $center_border6_format;
our $cell_format;
our $wrap_text_format;
our $workbook;
my $is_domain_controller_users_checked = 0;
our %complaince;
our %compliance_summary;
our %audit_result_type;
our %vulnerability_data;
our %ip_vuln_data;
our %ms_process_cnt;
our $home_url;
our $url_format;
my @targets;
my $target_cnt;
our $ip_add_regex = '(25[0-5]|[2][0-4][0-9]|1[0-9]{2}|[\d][\d]|[\d])(\.(25[0-5]|[2][0-4][0-9]|1[0-9]{2}|[\d][\d]|[\d])){3}';
my $dir;
my $target_file;
my @xml_files;
our %cvss_score;
our $port_scan_plugin = '(10335)|(34277)|(11219)|(14272)|(34220)';
our $installed_software_plugin = '(20811)|(58452)|(22869)';
our %total_discovered;
our %vuln_totals;
our @host_data;
my @PolicyCompliance;
my @policy_data;
##################### get arguments from the command
my $help_msg = '
NAME
nessus-parser.pl -- parse nessus v2 XML files into an XLSX file
SYNOPSIS
perl nessus-parser.pl [-vVhH] [-f file] [-d directory] [-r recast_file optional ]
DESCRIPTION
Nessus Parser v0.25 - This is a program to parse a series of Nessus XMLv2
files into a XLSX file. The data from the XML file is placed into a series
of tabs to for easier review and reporting. New features with this edition
are better reporting of policy plugin families, user account reporting,
summary graphs, and a home page with summary data. For more information
and questions please contact Cody Dumont [email protected]
The Nessus parser requires some additional modules, they are:
o XML::TreePP
o Data::Dumper
o Math::Round
o Excel::Writer::XLSX
o Data::Table
o Excel::Writer::XLSX::Chart
o Getopt::Std
The options are as follows:
-o Changes the filename prefix. The default prefix is "nessus_report".
A time stamp is appended onto the prefix. An exmaple of the default
file name is nessus_report_20130409162908.xlsx. if the "-o foobar" is
passed, then the file name will be foobar_20130409162908.xlsx
-d The target directory where the Nessus V2 XML files are located.
This option will search the target directory files that end with
XML, xml, or nessus extentions. Each file found will be check for
Nessus V2 XML format. Each Nessus V2 XML file will be parsed and
will be stored into an XLSX file. This option should not be used
with any other option.
-f The target file is a method to call a single file for parsing.
With this method the XLSX file will be stored in the same folder
as the XML. Please note if the path to file has a "SPACE" use
double quotes around the file path and/or name.
-r The Recast option is a feature request from user KurtW. Kurt wanted
to be able to change the reported value of Nessus Plugin ID. While
this is not recommended in many cases, in some instances the change
may provide the Nessus user with more accurate report.
To use this feature create a CSV file with three fields.
Field 1: Nessus Plugin ID
Field 2: Nessus-assigned Severity
Field 3: Recasted (User-assigned) Severity
Examples
# Recast vulnerability SSL Certificate Cannot Be Trusted (Plugin ID 51192) from Medium(2) to Critical(4)
51192,2,4
# Recast vulnerability MySQL 5.1 < 5.1.63 Multiple Vulnerabilities (Plugin ID 59448) from High(3) to Low(1)
59448,3,1
# Recast vulnerability MS12-067: Vulnerabilities in FAST Search Server 2010 for Sharepoint RCE from High(3) to Critical(4)
62462,3,4
The file would contain 3 lines.
51192,2,4
59448,3,1
62462,3,4
The command used would be passed the -r recast.txt. See examples listed below.
-v Print this help message.
-h Print this help message.
EXAMPLES
The command:
perl /path/to/script/nessus-parser.pl -v
This command will print this help message.
The command:
perl /path/to/script/nessus-parser.pl -h
This command will print this help message.
The command:
perl /path/to/script/nessus-parser.pl -d /foo/bar
This command will seearch the direcoty specified by the "-d" option
for Nessus XML v2 files and parse the files found.
The command:
perl /path/to/script/nessus-parser.pl -f /foo/bar/scan1.nessus
----- or -----
perl /path/to/script/nessus-parser.pl -f /foo/bar/scan1.nessus.xml
This command will seearch the direcoty specified by the "-d" option
for Nessus XML v2 files and parse the files found.
The command:
perl /path/to/script/nessus-parser.pl -f /foo/bar/scan1.nessus -r /path/to/script/recast.txt
';
my $version = $ARGV[0];
my %opt;
getopt('dfro', \%opt);
if($version =~ /-(v|V|h|H)/){
print $help_msg;exit;
}
elsif($opt{"d"} && $opt{"f"}){
print "Please only use a file or directory as a command line argument.\n\n";
print $help_msg;exit;
}
elsif($opt{"d"}){
$dir = $opt{"d"};
print "The target directory is \"$dir\"\.\n";
opendir DIR, $dir;
my @files = readdir(DIR);
closedir DIR;
my @xml = grep {$_ =~ /((xml)|(XML)|(nessus))$/} @files;
#@xml_files = grep {$_ !~ /^\./} @xml_files;
my @verified;
my $eol_marker = $/;
undef $/;
foreach (@xml){
my $f = "$dir/$_";
open FILE, $f;
my $tmp_data = <FILE>;
close FILE;
if($tmp_data =~ /(NessusClientData_v2)/m){print "File $_ is a Valid Nessus Ver2 format and will be parsed.\n\n";push @verified,$f}
else{print "This file \"$_\" is not using the Nessus version 2 format, and will NOT be parsed!!!\n\n";}
}
# end of foreach (@xml)
$/ = $eol_marker;
@xml_files = @verified;
}
elsif($opt{"f"}){
$target_file = $opt{"f"};
print "The target file is \"$target_file\"\.\n";
my $eol_marker = $/;
undef $/;
open FILE, $target_file;
my $tmp_data = <FILE>;
close FILE;
if($tmp_data =~ /(NessusClientData_v2)/m){
print "File $target_file is a Valid Nessus Ver2 format and will be parsed.\n\n";
my @dirs = split /\\|\//,$target_file;
pop @dirs;
if(!@dirs){push @dirs, "."}
$dir = join "/", @dirs;
push @xml_files, $target_file;
print "";
}
else{print "This file \"$target_file\" is not using the Nessus version 2 format, and will NOT be parsed!!!\n\n";exit;}
$/ = $eol_marker;
}
else{
print $help_msg;exit;
}
if($opt{"r"}){
my $recast_file = $opt{"r"};
print "The recast option is selected, the recast definition file is \"$recast_file\"\.\nPlease note all the following Plugin ID's will have thier severity changed accordingly.\n\n";
open FILE, $recast_file or die "Can't open the $recast_file file\n";
my @tmp_data = <FILE>;
close FILE;
chomp @tmp_data;
print "PLUGIN ID\tOLD SEV\tNEW SEV\n";
foreach my $p (@tmp_data){
my @t = split /\,/,$p;
if($t[3]){print "There is a error in your RECAST file, please review the help message using the -h option.\n";exit;}
print "$t[0]\t\t$t[1]\t$t[2]\n";
$recast_plugin{$t[0]}->{old} = $t[1];
$recast_plugin{$t[0]}->{new} = $t[2];
}
}
################## end command arguments
###### Code contributed by Whinston Antion <Whinston.Antion AT mail.wvu.edu>
my $random_number = rand();
my $now_string = localtime;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $report_prefix = "nessus_report";
$opt{"f"} =~s/.nessus//;
if($opt{"o"}){$report_prefix = $opt{"o"}}
elsif($opt{"f"}){$report_prefix = $opt{"f"}}
my $report_file = sprintf("%4d%02d%02d%02d%02d%02d",($year + 1900),($mon+1),$mday,$hour,$min,$sec);
###### end contribution
print "
################################################################################
NESSUS PARSER V0.25
################################################################################
";
############################## START SUBROUTINES
sub vulnerability_plugin_worksheet {
my $vuln_type = $_[0];
my $tmp_worksheet = $_[1];
my $vuln_type_ctr = 2;
$tmp_worksheet->write_url( 'A1', $home_url, $url_format, $_);
$tmp_worksheet->keep_leading_zeros();
$tmp_worksheet->write(1, 0, 'File',$center_border6_format);
$tmp_worksheet->write(1, 1, 'plugin Family',$center_border6_format);
$tmp_worksheet->write(1, 2, 'plugin id',$center_border6_format);
$tmp_worksheet->write(1, 3, 'plugin Name',$center_border6_format);
$tmp_worksheet->write(1, 4, 'count',$center_border6_format);
$tmp_worksheet->write(1, 5, 'Bid',$center_border6_format);
$tmp_worksheet->write(1, 6, 'CVE',$center_border6_format);
$tmp_worksheet->write(1, 7, 'OSVDB',$center_border6_format);
$tmp_worksheet->write(1, 8, 'CVSS Vector',$center_border6_format);
$tmp_worksheet->write(1, 9, 'CVSS Base Score',$center_border6_format);
$tmp_worksheet->write(1, 10, 'CVSS Temporal Score',$center_border6_format);
$tmp_worksheet->write(1, 11, 'Solution',$center_border6_format);
$tmp_worksheet->write(1, 12, 'Description',$center_border6_format);
$tmp_worksheet->write(1, 13, 'Exploitability Ease',$center_border6_format);
$tmp_worksheet->write(1, 14, 'Exploit Available',$center_border6_format);
$tmp_worksheet->write(1, 15, 'Exploit Framework Canvas',$center_border6_format);
$tmp_worksheet->write(1, 16, 'Exploit Framework Metasploit',$center_border6_format);
$tmp_worksheet->write(1, 17, 'Exploit Framework Core',$center_border6_format);
$tmp_worksheet->write(1, 18, 'Metasploit Name',$center_border6_format);
$tmp_worksheet->write(1, 19, 'Canvas Package',$center_border6_format);
$tmp_worksheet->write(1, 20, 'Solution',$center_border6_format);
$tmp_worksheet->write(1, 21, 'Synopsis',$center_border6_format);
$tmp_worksheet->write(1, 22, 'plugin_publication_date',$center_border6_format);
$tmp_worksheet->write(1, 23, 'plugin_modification_date',$center_border6_format);
$tmp_worksheet->write(1, 24, 'patch_publication_date',$center_border6_format);
$tmp_worksheet->write(1, 25, 'vuln_publication_date',$center_border6_format);
$tmp_worksheet->freeze_panes('C3');
$tmp_worksheet->autofilter('A2:Z2');
$tmp_worksheet->set_column('A:A', 20);
$tmp_worksheet->set_column('B:B', 25);
$tmp_worksheet->set_column('C:C', 10);
$tmp_worksheet->set_column('D:D', 35);
$tmp_worksheet->set_column('E:H', 10);
$tmp_worksheet->set_column('I:R', 35);
$tmp_worksheet->set_column('S:S', 60);
$tmp_worksheet->set_column('T:T', 60);
$tmp_worksheet->set_column('U:U', 60);
$tmp_worksheet->set_column('V:V', 60);
$tmp_worksheet->set_column('W:Z', 20);
foreach (@{$vulnerability_data{$vuln_type}}){
my @tmp = split /\,/, $_;
$tmp_worksheet->write($vuln_type_ctr, 0, $tmp[4],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 1, $tmp[5],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 2, $tmp[0],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 3, $tmp[3],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 4, $tmp[2],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 5, $tmp[6],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 6, $tmp[7],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 7, $tmp[8],$wrap_text_format);
$tmp_worksheet->write($vuln_type_ctr, 8, $tmp[19],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 9, $tmp[18],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 10, $tmp[20],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 11, $tmp[9],$wrap_text_format);
$tmp_worksheet->write($vuln_type_ctr, 12, $tmp[10],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 13, $tmp[11],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 14, $tmp[12],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 15, $tmp[13],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 16, $tmp[14],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 17, $tmp[15],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 18, $tmp[16],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 19, $tmp[17],$wrap_text_format);
$tmp_worksheet->write($vuln_type_ctr, 20, $tmp[21],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 21, $tmp[22],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 22, $tmp[23],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 23, $tmp[24],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 24, $tmp[25],$cell_format);
$tmp_worksheet->write($vuln_type_ctr, 25, $tmp[26],$cell_format);
++$vuln_type_ctr;
}
# end foreach (@criticalvuln)
return $tmp_worksheet;
}
# end of sub vulnerability_plugin_worksheet
sub compliance_worksheet {
my $complaince_type = $_[0];
my $complaince_name = $complaince_type;
$complaince_name =~ s/Compliance Checks//;
$complaince_name =~ s/\s//g;
$complaince_name =~ s/[[:punct:]]//g;
my $complaince_name1 = substr ($complaince_name, 0, 23);
$complaince_name = "$complaince_name1 Policy";
my $Compliance_ctr = 2;
my $Compliance_worksheet = $workbook->add_worksheet($complaince_name);
$Compliance_worksheet->write_url( 'A1', $home_url, $url_format, $_);
$Compliance_worksheet->keep_leading_zeros();
$Compliance_worksheet->write(1, 0, 'File',$center_border6_format);
$Compliance_worksheet->write(1, 1, 'IP Address',$center_border6_format);
$Compliance_worksheet->write(1, 2, 'FQDN',$center_border6_format);
$Compliance_worksheet->write(1, 3, 'PluginID',$center_border6_format);
#$Compliance_worksheet->write(1, 4, 'protocol',$center_border6_format);
$Compliance_worksheet->write(1, 4, 'Severity',$center_border6_format);
#$Compliance_worksheet->write(1, 5, 'pluginFamily',$center_border6_format);
$Compliance_worksheet->write(1, 5, 'Audit File',$center_border6_format);
#$Compliance_worksheet->write(1, 6, 'Policy Type',$center_border6_format);
$Compliance_worksheet->write(1, 6, 'Policy Setting',$center_border6_format);
$Compliance_worksheet->write(1, 7, 'Result',$center_border6_format);
$Compliance_worksheet->write(1, 8, 'System Value/Error Messages',$center_border6_format);
$Compliance_worksheet->write(1, 9, 'Compliance Requirement',$center_border6_format);
$Compliance_worksheet->write(1, 10, 'Description of Requirement',$center_border6_format);
# JB Init Changes
# add column for solution
$Compliance_worksheet->write(1, 11, 'Solution',$center_border6_format);
$Compliance_worksheet->write(1, 12, 'Authority Document',$center_border6_format);
$Compliance_worksheet->write(1, 13, 'Cross References',$center_border6_format);
## End Init Changes
$Compliance_worksheet->freeze_panes('C3');
$Compliance_worksheet->autofilter('A2:N2');
$Compliance_worksheet->set_column('A:N', 20);
foreach (@{$complaince{$complaince_type}}){
my @tmp;
my $remote_value;
my @compliance_check_name = split / - /,$_->{vuln}->{'cm:compliance-check-name'};
#foreach my $k (keys %{$_->{vuln}}){$_->{vuln}->{"$k"} =~ s/\n/\|/g;}
#if ($compliance_check_name[1] eq "") {
# my @tmp = split /: /,$_->{vuln}->{'cm:compliance-check-name'};
# $compliance_check_name[0] = "$tmp[0] $tmp[1]";
# $compliance_check_name[1] = "$tmp[2]";
#}
my $compliance_value;
if ($_->{vuln}->{description} =~ /(?<=Remote value:).+?(?=^Policy value:)/ism){$remote_value = substr($_->{vuln}->{description},$-[0],$+[0]-$-[0]);}
if ($_->{vuln}->{description} =~ /(?<=Policy value:).+?\Z/ism){$compliance_value = substr($_->{vuln}->{description},$-[0],$+[0]-$-[0]);}
$remote_value =~ s/ {2,}\|\-|\r\n|\r|\n/ /g;
$compliance_value =~ s/ {2,}\|\-|\r\n|\r|\n/ /g;
$remote_value =~ s/ {2,}/ /g;
$compliance_value =~ s/ {2,}/ /g;
my $description = $_->{vuln}->{description};
$description =~ s/ {2,}\|\-|\r\n|\r|\n/ /g;
$description =~ s/ {2,}/ /g;
$_->{vuln}->{plugin_type} = $compliance_check_name[0];
$Compliance_worksheet->write($Compliance_ctr, 0, $_->{'file'},$cell_format);
$Compliance_worksheet->write($Compliance_ctr, 1, $_->{'name'},$cell_format);
$Compliance_worksheet->write($Compliance_ctr, 2, $_->{'fqdn'},$cell_format);
$Compliance_worksheet->write($Compliance_ctr, 3, $_->{vuln}->{-pluginID},$cell_format);#PluginID
#$Compliance_worksheet->write($Compliance_ctr, 4, $_->{vuln}->{-protocol},$cell_format);#protocol
$Compliance_worksheet->write($Compliance_ctr, 4, $_->{vuln}->{-severity},$cell_format);#severity
#$Compliance_worksheet->write($Compliance_ctr, 5, $_->{vuln}->{-pluginFamily},$cell_format);#pluginFamily
$Compliance_worksheet->write($Compliance_ctr, 5, $_->{vuln}->{"cm:compliance-audit-file"},$cell_format);
#$Compliance_worksheet->write($Compliance_ctr, 6, $compliance_check_name[0],$cell_format); #'Policy Type'
$Compliance_worksheet->write($Compliance_ctr, 6, $_->{vuln}->{"cm:compliance-check-name"},$cell_format);#Check Name
$Compliance_worksheet->write($Compliance_ctr, 7, $_->{vuln}->{'cm:compliance-result'},$wrap_text_format);#Result
if ($_->{vuln}->{'cm:compliance-actual-value'} =~ /\=/) {$Compliance_worksheet->write($Compliance_ctr, 8, "\'$_->{vuln}->{'cm:compliance-actual-value'}",$wrap_text_format);} #System Value
else{$Compliance_worksheet->write($Compliance_ctr, 8, $_->{vuln}->{'cm:compliance-actual-value'},$wrap_text_format);}#System Value
$Compliance_worksheet->write($Compliance_ctr, 9, $_->{vuln}->{"cm:compliance-policy-value"},$cell_format);#Compliance Requirement
$Compliance_worksheet->write($Compliance_ctr, 10, $_->{vuln}->{"cm:compliance-info"},$cell_format);#description of test
## JB Init Changes
# Add write for soluton data
$Compliance_worksheet->write($Compliance_ctr, 11, $_->{vuln}->{'cm:compliance-solution'},$wrap_text_format);#Solution
$Compliance_worksheet->write($Compliance_ctr, 12, $_->{vuln}->{'cm:compliance-see-also'},$wrap_text_format);#See Also
my $references = $_->{vuln}->{'cm:compliance-reference'};
$references =~ s/,/, /g;
$Compliance_worksheet->write($Compliance_ctr, 13, $references,$wrap_text_format);#XRef
## End Init Changes
++$Compliance_ctr;
$_->{vuln}->{'oringnal description'} = $_->{vuln}->{description};
$_->{vuln}->{'Result'} = $_->{vuln}->{'cm:compliance-result'};
$_->{vuln}->{'Policy Setting'} = $compliance_check_name[1];
$_->{vuln}->{'plugin_type'} = $compliance_check_name[0];
$_->{vuln}->{'remote_value'} = $_->{vuln}->{'cm:compliance-actual-value'};
$_->{vuln}->{'compliance_value'} = $compliance_value;
$_->{vuln}->{'description'} = $description;
if ($_->{vuln}->{description} =~ /(?<=^\").+?(?=\")/ism){$_->{vuln}->{'short description'} = substr($_->{vuln}->{description},$-[0],$+[0]-$-[0]);}
$compliance_summary{$_->{vuln}->{-pluginName}}->{$_->{vuln}->{'cm:compliance-check-name'}}->{$_->{vuln}->{"cm:compliance-result"}}++;
$audit_result_type{$_->{vuln}->{"cm:compliance-result"}}++;
}
# end foreach (@Compliance)
return $Compliance_worksheet;
}
# end of sub compliance_worksheet
sub host_summary_data {
my @host_data = @{$_[0]};
my $search_item = $_[1];
my %host_seen_cnt;
my @Host_uniq_cnt;
foreach my $item (@host_data){
if ($search_item =~ /sev/){$host_seen_cnt{$item->{vuln_cnt}->{$search_item}}++}
else{$host_seen_cnt{$item->{$search_item}}++}
}
return %host_seen_cnt;
}
# end of sub host_summary_data
sub get_vuln_cnt{
my @vuln_array = @{$_[0]};
my %vuln_cnt = %{$_[1]};
my $plugin_family = $vuln_array[0]->{-pluginFamily};
if ($plugin_family eq ""){$plugin_family = "PortScan";}
my $sev0 = grep {$_->{-severity} == 0} @vuln_array;
my $sev1 = grep {$_->{-severity} == 1} @vuln_array;
my $sev2 = grep {$_->{-severity} == 2} @vuln_array;
my $sev3 = grep {$_->{-severity} == 3} @vuln_array;
my $sev4 = grep {$_->{-severity} == 4} @vuln_array;
$vuln_cnt{sev0} = $vuln_cnt{sev0} + $sev0;
$vuln_cnt{sev1} = $vuln_cnt{sev1} + $sev1;
$vuln_cnt{sev2} = $vuln_cnt{sev2} + $sev2;
$vuln_cnt{sev3} = $vuln_cnt{sev3} + $sev3;
$vuln_cnt{sev4} = $vuln_cnt{sev4} + $sev4;
my %hash = (
sev0 => $sev0,
sev1 => $sev1,
sev2 => $sev2,
sev3 => $sev3,
sev4 => $sev4
);
my %h2 = %hash;
$vuln_cnt{$plugin_family} = \%h2;
return %vuln_cnt;
}
# end of sub get_vuln_cnt
sub vuln_seperate_by_plugin {
my @plugin_data = @{$_[0]};
my @return_data;
my %seen;
my @uniq;
foreach my $item (@plugin_data){my @tmp = split /\,/, $item;$seen{$tmp[5]}++}
@return_data = keys %seen;
foreach my $e (@return_data){
my %hash;
$hash{$e} = grep {$_ =~ /,$e,/} @plugin_data;
my @temp = grep {$_ =~ /,$e,/} @plugin_data;
my $header = ["plugin id0","Severity1","count2","plugin Name3","File4","plugin Family5","Bid6","CVE7","OSVDB8","Solution9","Description10"];
my $pivot_data = \@temp;
foreach my $p (@{$pivot_data}){
my @tmp = split /\,/,$p;
$p = ["$tmp[0]","$tmp[1]","$tmp[2]","$tmp[3]","$tmp[4]","$tmp[5]","$tmp[6]","$tmp[7]","$tmp[8]","$tmp[9]","$tmp[10]"];
}
my $t = new Data::Table($pivot_data, $header, 0);
$t->sort("count2",0,1,"CVE7",1,0,"OSVDB8",1,0);
my @t = @{$t->{data}};
undef @temp;
@temp = splice @t,0,10;
$hash{'entries'} = \@temp;
$e = \%hash;
}
return @return_data,
}
# end of the seperate_by_plugin
sub store_ad_users{
my $user_list = $_[0];
$user_list =~ s/ {2,}- |\)//g;
$user_list =~ s/ \(/\|/g;
$user_list =~ s/\, /\|/g;
@ADUsers = split /\r\n|\r|\n/, $user_list;
if($ADUsers[0] eq ""){shift @ADUsers}
my $user_list_cnt = @ADUsers;
my $splice_cnt = 0;
if($ADUsers[0] eq ""){shift @ADUsers}
foreach (@ADUsers){if ($_ eq ""){last;}++$splice_cnt;}
splice @ADUsers,$splice_cnt;
foreach (@ADUsers){
my @tmp = split /\|/, $_;
my %hash;
$hash{'name'} = $tmp[0];
$hash{'sid'} = $tmp[1];
if ($tmp[2] eq "Administrator account"){$hash{'type'} = "Domain Administrator account";}
elsif ($tmp[2] eq "Guest account"){$hash{'type'} = "Domain Guest account";}
elsif ($tmp[0] =~ /\$$/){$hash{'type'} = "Computer Account";}
else{$hash{'type'} = "Domain User";}
$_ = \%hash;
}
}
# end of store_ad_users
sub check_if_vuln_present{
my $vuln = $_[0];
my $file = $_[1];
my $plugin = $vuln->{-pluginID};
my $severity = $vuln->{-severity};
my $key = "$plugin\_$file";
my $pluginName = $vuln->{-pluginName};
$pluginName =~ s/\,//g;
$vuln->{solution} =~ s/\,/\|/g;
$vuln->{solution} =~ s/\n|\r/\ /g;
$vuln->{description} =~ s/\,/\|/g;
$vuln->{description} =~ s/\n|\r/\ /g;
my $bid;
if (ref $vuln->{bid} eq "ARRAY"){$bid = join "|", @{$vuln->{bid}}}
elsif (ref $vuln->{bid} eq ""){$bid = $vuln->{bid}}
my $cve;
if (ref $vuln->{cve} eq "ARRAY"){$cve = join "|", @{$vuln->{cve}}}
elsif (ref $vuln->{cve} eq ""){$cve = $vuln->{cve}}
my $xref;
if (ref $vuln->{xref} eq "ARRAY"){$xref = join "|", @{$vuln->{xref}}}
elsif (ref $vuln->{xref} eq ""){$xref = $vuln->{xref}}
my $plugin_cnt = 0;
if ($severity == 0){
# @{$vulnerability_data{nonevuln}}
my $plugin_test = grep /$vuln->{-pluginID}/, @{$vulnerability_data{nonevuln}};
my @found_plugin = grep /$vuln->{-pluginID}/, @{$vulnerability_data{nonevuln}};
if ($plugin_test == 0){
++$plugin_cnt;
$plugin = "$plugin\,$severity\,$plugin_cnt\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{nonevuln}}, $plugin
}
else{
my $found = 0;
foreach (@{$vulnerability_data{nonevuln}}){
my @tmp = split /\,/, $_;
my $entry = "$tmp[0]\_$tmp[4]";
if ($entry eq $key){++$tmp[2];$_ = join(",",@tmp);$found = 1;last;}
}
# end foreach
if ($found == 0){
$plugin = "$plugin\,$severity\,1\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{nonevuln}}, $plugin;
}
# end of if
}
#end else for test
}
elsif ($severity == 1){
# @{$vulnerability_data{lowvuln}}
my $plugin_test = grep /$vuln->{-pluginID}/, @{$vulnerability_data{lowvuln}};
my @found_plugin = grep /$vuln->{-pluginID}/, @{$vulnerability_data{lowvuln}};
if ($plugin_test == 0){
++$plugin_cnt;
$plugin = "$plugin\,$severity\,$plugin_cnt\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{lowvuln}}, $plugin
}
else{
my $found = 0;
foreach (@{$vulnerability_data{lowvuln}}){
my @tmp = split /\,/, $_;
my $entry = "$tmp[0]\_$tmp[4]";
if ($entry eq $key){++$tmp[2];$_ = join(",",@tmp);$found = 1;last;}
}
# end foreach
if ($found == 0){
$plugin = "$plugin\,$severity\,1\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{lowvuln}}, $plugin;
}
# end if
} #end else for test
}
elsif ($severity == 2){
my $plugin_test = grep /$vuln->{-pluginID}/, @{$vulnerability_data{medvuln}};
my @found_plugin = grep /$vuln->{-pluginID}/, @{$vulnerability_data{medvuln}};
if ($plugin_test == 0){
++$plugin_cnt;
$plugin = "$plugin\,$severity\,$plugin_cnt\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{medvuln}}, $plugin
}
else{
my $found = 0;
foreach (@{$vulnerability_data{medvuln}}){
my @tmp = split /\,/, $_;
my $entry = "$tmp[0]\_$tmp[4]";
if ($entry eq $key){++$tmp[2];$_ = join(",",@tmp);$found = 1;last;}
}
# end foreach
if ($found == 0){
$plugin = "$plugin\,$severity\,1\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{medvuln}}, $plugin;
}
# end if
}
#end else for test
}
elsif ($severity == 3){
my $plugin_test = grep /$vuln->{-pluginID}/, @{$vulnerability_data{highvuln}};
my @found_plugin = grep /$vuln->{-pluginID}/, @{$vulnerability_data{highvuln}};
if ($plugin_test == 0){
++$plugin_cnt;
$plugin = "$plugin\,$severity\,$plugin_cnt\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{highvuln}}, $plugin
}
else{
my $found = 0;
foreach (@{$vulnerability_data{highvuln}}){
my @tmp = split /\,/, $_;
my $entry = "$tmp[0]\_$tmp[4]";
if ($entry eq $key){++$tmp[2];$_ = join(",",@tmp);$found = 1;last;}
}
# end foreach
if ($found == 0){
$plugin = "$plugin\,$severity\,1\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{highvuln}}, $plugin;
}
# end if
}
#end else for test
}
elsif ($severity == 4){
my $plugin_test = grep /$vuln->{-pluginID}/, @{$vulnerability_data{criticalvuln}};
my @found_plugin = grep /$vuln->{-pluginID}/, @{$vulnerability_data{criticalvuln}};
if ($plugin_test == 0){
++$plugin_cnt;
$plugin = "$plugin\,$severity\,$plugin_cnt\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{criticalvuln}}, $plugin
}
else{
my $found = 0;
foreach (@{$vulnerability_data{criticalvuln}}){
my @tmp = split /\,/, $_;
my $entry = "$tmp[0]\_$tmp[4]";
if ($entry eq $key){++$tmp[2];$_ = join(",",@tmp);$found = 1;last;}
}
# end foreach
if ($found == 0){
$plugin = "$plugin\,$severity\,1\,$pluginName\,$file\,$vuln->{-pluginFamily},$bid,$cve,$xref,$vuln->{solution},$vuln->{description},$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{solution},$vuln->{synopsis},$vuln->{plugin_publication_date},$vuln->{plugin_modification_date},$vuln->{patch_publication_date},$vuln->{vuln_publication_date}";
push @{$vulnerability_data{criticalvuln}}, $plugin;
}
# the if found statement
}
#end else for test
}
# end Sev 4
# END of Vuln level checks
}
# END OF SUBROUTINE
sub store_vuln{
my @vuln_array = @{$_[0]};
my $file = $_[1];
my $name = $_[2];
my $host_fqdn = $_[3];
my $netbios_name = $_[4];
my $operating_system = $_[5];
my %hash;
$hash{'file'} = $file;
$hash{'name'} = $name;
$hash{'fqdn'} = $host_fqdn;
$hash{'netbios_name'} = $netbios_name;
$hash{'operating_system'} = $operating_system;
print "Storing Vulnerability Data for $name\n";
foreach my $vuln (@vuln_array){
if ($vuln->{-pluginID} == 33929){print "Removing plugin 33929 from High Vulns calculation\n"}
elsif ($vuln->{"cm:compliance-result"}) {"removing from the high vulns calculator\n"}
else {$vuln_totals{$vuln->{-severity}}->{$vuln->{-pluginID}}++;}
if ($vuln->{exploitability_ease} eq ""){$vuln->{exploitability_ease} = "N/A"}
if ($vuln->{exploit_available} eq ""){$vuln->{exploit_available} = "N/A"}
if ($vuln->{exploit_framework_canvas} eq ""){$vuln->{exploit_framework_canvas} = "N/A"}
if ($vuln->{exploit_framework_metasploit} eq ""){$vuln->{exploit_framework_metasploit} = "N/A"}
if ($vuln->{exploit_framework_core} eq ""){$vuln->{exploit_framework_core} = "N/A"}
if ($vuln->{metasploit_name} eq ""){$vuln->{metasploit_name} = "N/A"}
if ($vuln->{canvas_package} eq ""){$vuln->{canvas_package} = "N/A"}
if ($vuln->{cvss_base_score} eq ""){$vuln->{cvss_base_score} = "N/A"}
if ($vuln->{cvss_vector} eq ""){$vuln->{cvss_vector} = "N/A"}
if ($vuln->{cvss_temporal_score} eq ""){$vuln->{cvss_temporal_score} = "N/A"}
if($vuln->{-pluginID} =~ /$port_scan_plugin/){
$hash{'vuln'} = $vuln;
my %h2 = %hash;
push @portScanner,\%h2;
}
elsif($vuln->{-pluginID} =~ /$installed_software_plugin/){
$hash{'vuln'} = $vuln;
my %h2 = %hash;
push @installedSoftware,\%h2;
}
elsif ($vuln->{-pluginID} =~ /(33931)|(33930)|(33929)|(57581)|(56209)|(56208)/) {
#33931 - PCI DSS Compliance: Tests Requirements
#33929 - PCI DSS compliance
#33930 - PCI DSS Compliance: Passed
#57581 - PCI DSS Compliance : Database Reachable from the Internet
#56209 - PCI DSS Compliance : Remote Access Software Has Been Detected
#56208 - PCI DSS Compliance : Insecure Communication Has Been Detected
$hash{'vuln'} = $vuln;
my %h2 = %hash;
push @PCIDSS,\%h2;
#print "33929,33930,33931 - PCI DSS Compliance\n";
}
elsif($vuln->{-pluginFamily} eq "Policy Compliance"){
# REMOVE 21156 - Windows Compliance Checks
# Audit Checks
if($vuln->{-pluginID} !~ /(66759)|(66757)|(66756)|(66758)|(33931)|(60020)|(33929)|(56209)|(56208)/){
$hash{'vuln'} = $vuln;
my %h2 = %hash;
push @{$complaince{$vuln->{-pluginName}}},\%h2;
#print "$vuln->{-pluginID} - $vuln->{-pluginName}\n";
#print "";
}
# end of if($vuln->{-pluginID} !~ /(66759)|(66757)|(66756)|(66758)/)
}
else{
if($vuln->{-pluginFamily} eq "" && $vuln->{-pluginName} eq ""){
$vuln->{-pluginFamily} = "PortScan";
$vuln->{-pluginName} = "$vuln->{-svc_name}";
$vuln->{-pluginID} = "$vuln->{-protocol}\-$vuln->{-port}";
}
check_if_vuln_present($vuln,$file);
}
# end else statement
if ($vuln->{-pluginName} eq "OS Identification"){
my @t1 = split /\n/, $vuln->{description};
my @t2 = split /\:/, $t1[1];
$vuln->{-pluginName} ="$vuln->{-pluginName} - $t2[1]";
}
# end of if ($vuln->{-pluginName} eq "OS Identification")
my $plugin_name = $vuln->{'-pluginName'};
if ($vuln->{plugin_output}) {
$vuln->{plugin_output} =~ s/\n/\|/g;
$vuln->{plugin_output} =~ s/\,/ /g;
}
# end of if ($vuln->{plugin_output})
if($vuln->{-pluginFamily} ne "Policy Compliance"){
if($vuln->{'-pluginID'} eq '33929'){
print "";
}
my $r = "$file,$name,$host_fqdn,$vuln->{'-pluginID'},$vuln->{'-protocol'},$vuln->{'-port'},$vuln->{'-severity'},$vuln->{'-pluginFamily'},$plugin_name,$vuln->{exploitability_ease},$vuln->{exploit_available},$vuln->{exploit_framework_canvas},$vuln->{exploit_framework_metasploit},$vuln->{exploit_framework_core},$vuln->{metasploit_name},$vuln->{canvas_package},$vuln->{cvss_base_score},$vuln->{cvss_vector},$vuln->{cvss_temporal_score},$vuln->{plugin_output}";
push @host_scan_data,$r;
}
# end of if($vuln->{-pluginFamily} ne "Policy Compliance")
}
# end foreach
}
# end of subrooutine
sub normalizeHostData {
my @report_data = @{$_[0]};
foreach my $host (@report_data){
my @HostReport;
my $is_domain_controller = 0;
my $temp_domain_list;
$host->{"DomainController"} = "N";
#### NEW ARRAYS
my @aix_local_security_checks;
my @amazon_linux_local_security_checks;
my @alma_linux_local_security_checks;
my @backdoors;
my @brute_force_attacks;
my @centos_local_security_checks;
my @cgi_abuses;
my @cgi_abuses_xss;
my @cisco;
my @databases;
my @debian_local_security_checks;
my @default_unix_accounts;
my @denial_of_service;
my @dns;
my @f5_networks_local_security_checks;
my @fedora_local_security_checks;
my @finger_abuses;
my @firewalls;
my @freebsd_local_security_checks;
my @ftp;
my @gain_a_shell_remotely;
my @general;
my @gentoo_local_security_checks;
my @hp_ux_local_security_checks;
my @huawei_local_security_checks;
my @junos_local_security_checks;
my @macos_x_local_security_checks;
my @mandriva_local_security_checks;
my @marineros_local_security_checks;
my @misc;
my @mobile_devices;
my @netware;
my @newstart_cgsl_local_security_checks;
my @oracle_linux_local_security_checks;
my @oraclevm_local_security_checks;
my @peer_to_peer_file_sharing;
my @palo_alto_local_security_checks;
my @photonos_local_security_checks;
my @policy_compliance;
my @port_scanners;
my @red_hat_local_security_checks;
my @rocky_linux_local_security_checks;
my @rpc;
my @scada;
my @scientific_linux_local_security_checks;
my @service_detection;
my @settings;
my @slackware_local_security_checks;
my @smtp_problems;
my @snmp;
my @solaris_local_security_checks;
my @suse_local_security_checks;
my @tenable_ot;
my @ubuntu_local_security_checks;
my @vmware_esx_local_security_checks;
my @virtuozzo_local_security_checks;
my @web_servers;
my @windows;
my @windows_microsoft_bulletins;
my @windows_user_management;
my @port_scan;
my @WindowsUserManagement;
my @incident_response;
#### END OF NEW ARRAYS
if(ref ($host->{host_report}) eq "ARRAY"){@HostReport = @{$host->{host_report}};}
elsif(ref ($host->{host_report}) eq "HASH"){push @HostReport,$host->{host_report};}
foreach my $h_report (@HostReport){
### Find the Domain Controller
my $is_domain_controller = 0;
#print "$h_report->{'-pluginID'} \n";
# store data in the %ip_vuln_data hash
$ip_vuln_data{$host->{file}}->{$h_report->{-severity}}->{$h_report->{-pluginID}}->{pluginName} = $h_report->{-pluginName};
if ($host->{'host-ip'} eq "") {$ip_vuln_data{$host->{file}}->{$h_report->{-severity}}->{$h_report->{-pluginID}}->{ip}->{$host->{'name'}}++;}
else{$ip_vuln_data{$host->{file}}->{$h_report->{-severity}}->{$h_report->{-pluginID}}->{ip}->{$host->{'host-ip'}}++;}
# 70329 - process info
if ($h_report->{-pluginID} == 70329){
my %process_info = (
'fqdn' => $host->{"host-fqdn"},
'host-ip' => $host->{"host-ip"},
'file' => $host->{file},
'name' => $host->{name},
'netbios-name' => $host->{"netbios-name"},
);
my $process_info = $h_report->{plugin_output};
$process_info =~ s/^Process Overview : \n//;
$process_info =~ s/^SID: Process \(PID\)\n//;
$process_info =~ s/Process_Information.+process.$//;
$process_info =~ s/\n\n\n$//;
my @tmp_process = split /\n/,$process_info;
foreach my $tp (@tmp_process){
my $tp1 = $tp;
$tp1 =~ s/^\s\d\s:\s+(((\||)((\-\s)|))|)//;
$tp1 =~ s/\s\(\d+\)//;
$ms_process_cnt{$tp1}->{$host->{"host-ip"}}++;
}
# end of foreach my $tp (@tmp_process)
$process_info{processes} = \@tmp_process;
push @MS_Process_Info, \%process_info;
}
# end of 70329 - process info
#Device Type
if ($h_report->{-pluginID} == 54615) {
my %device_hash = (
'fqdn' => $host->{"host-fqdn"},
'host-ip' => $host->{"host-ip"},
'file' => $host->{file},
'name' => $host->{name},
'netbios-name' => $host->{"netbios-name"},
);
my $deviceData = $h_report->{plugin_output};
$deviceData =~ s/\n/ /g;
if ($deviceData =~ /(?<=type : ).*(?=Confidence )/) {$device_hash{type} = substr($deviceData,$-[0],$+[0]-$-[0])}
if ($deviceData =~ /Confidence level : \d+/) {
$device_hash{confidenceLevel} = substr($deviceData,$-[0],$+[0]-$-[0]);
$device_hash{confidenceLevel} =~ s/Confidence level : //;
}
push @DeviceType, \%device_hash;
}
#End of Device Type
# Enumerate Local Group Memberships
if ($h_report->{-pluginID} == 71246){
my %EnumLocalGrp = (
'fqdn' => $host->{"host-fqdn"},
'host-ip' => $host->{"host-ip"},
'file' => $host->{file},
'name' => $host->{name},
'netbios-name' => $host->{"netbios-name"},
);
my $EnumLocalGrp = $h_report->{plugin_output};
$EnumLocalGrp =~ s/\n/;/g;
my @tmp_grp = split ";;",$EnumLocalGrp;
foreach my $g (@tmp_grp){
my $grp = {};
my ($grp_attrib,$members) = split /\;Members/,$g;
my @t2 = split /;/,$grp_attrib;
foreach my $t3 (@t2){
my @t3 = split /\s+:\s/,$t3;
$grp->{$t3[0]} = $t3[1];
}
# end of foreach my $t3 (@t2){
if ($members =~ /^\s+:\s$/) {
my @t3;
push @t3, 'none';
$grp->{members} = \@t3;
}
else{
my @t3 = split /;\s+Name\s+:\s+/,$members;
if ($t3[0] =~ /\s+\:\s/) {shift @t3}
foreach my $t4 (@t3){
my $member = {};
$t4 = "; Name : $t4";
my @t4 = split /;\s+/,$t4;
if ($t4[0] eq '') {shift @t4}
foreach my $t5 (@t4){
my ($k,$v) = split /\s+:\s+/,$t5;
$member->{$k} = $v;
}
# end of foreach my $t5 (@t4)
push @{$grp->{members}},$member
}
# end of foreach my $t4 (@t3)
print "";
}
# end of if $members
print "";
$g = $grp;
}
# end of foreach my $g (@tmp_grp)
$EnumLocalGrp{groups} = \@tmp_grp;