11const { startSubsequentSecureCodeBoxScan } = require ( "./scan-helpers" ) ;
22
3- async function handle ( { scan, getFindings } ) {
3+ async function handle ( {
4+ scan,
5+ getFindings,
6+ cascadeAmassNmap = process . env [ "CASCADE_AMASS_NMAP" ] ,
7+ cascadeNmapSsl = process . env [ "CASCADE_NMAP_SSL" ] ,
8+ cascadeNmapSsh = process . env [ "CASCADE_NMAP_SSH" ] ,
9+ cascadeNmapNikto = process . env [ "CASCADE_NMAP_NIKTO" ] ,
10+ cascadeNmapSmb = process . env [ "CASCADE_NMAP_SMB" ] ,
11+ cascadeNmapZapBaseline = process . env [ "CASCADE_NMAP_ZAP_BASELINE" ]
12+ } ) {
413 const findings = await getFindings ( ) ;
514
615 console . log ( findings ) ;
16+ console . log ( "cascadeAmassNmap: " + cascadeAmassNmap ) ;
17+ console . log ( "cascadeNmapSsl: " + cascadeNmapSsl ) ;
18+ console . log ( "cascadeNmapSsh: " + cascadeNmapSsh ) ;
19+ console . log ( "cascadeNmapNikto: " + cascadeNmapNikto ) ;
20+ console . log ( "cascadeNmapSmb: " + cascadeNmapSmb ) ;
21+ console . log ( "cascadeNmapZapBaseline: " + cascadeNmapZapBaseline ) ;
722
823 console . log (
924 `Found #${ findings . length } findings... Trying to find identify if these are NMAP specific findings and start possible subsequent security scans.`
@@ -18,29 +33,53 @@ async function handle({ scan, getFindings }) {
1833 const port = finding . attributes . port ;
1934
2035 console . log (
21- "Found NMAP 'Open Port' finding for service: " + finding . attributes . port
36+ "Found NMAP 'Open Port' finding for port: ' " + finding . attributes . port + "' and service: '" + finding . attributes . service + "'"
2237 ) ;
2338
2439 // search for HTTP ports and start subsequent Nikto Scan
25- if ( finding . attributes . service === "http" ) {
40+ if (
41+ cascadeNmapNikto &&
42+ finding . attributes . service === "http"
43+ ) {
2644 await startNiktoScan ( {
2745 parentScan : scan ,
2846 hostname,
2947 port,
3048 } ) ;
3149 }
3250
51+ // search for SMB ports and start subsequent NMAP Scan
52+ if (
53+ cascadeNmapSmb &&
54+ finding . attributes . port === 445 &&
55+ finding . attributes . service === "microsoft-ds"
56+ ) {
57+ await startSMBScan ( {
58+ parentScan : scan ,
59+ hostname,
60+ port,
61+ } ) ;
62+ }
63+
3364 // search for HTTPS ports and start subsequent SSLyze Scan
3465 if (
35- finding . attributes . service === "ssl" ||
36- finding . attributes . service === "https"
66+ cascadeNmapSsl &&
67+ ( finding . attributes . service === "ssl" ||
68+ finding . attributes . service === "https" )
3769 ) {
3870 await startSSLyzeScan ( {
3971 parentScan : scan ,
4072 hostname,
4173 port,
4274 } ) ;
75+ }
4376
77+ // search for HTTPS ports and start subsequent ZAP Baselne Scan
78+ if (
79+ cascadeNmapZapBaseline &&
80+ ( finding . attributes . service === "ssl" ||
81+ finding . attributes . service === "https" )
82+ ) {
4483 await startZAPBaselineScan ( {
4584 parentScan : scan ,
4685 hostname,
@@ -49,7 +88,10 @@ async function handle({ scan, getFindings }) {
4988 }
5089
5190 // search for HTTPS ports and start subsequent SSH Scan
52- if ( finding . attributes . service === "ssh" ) {
91+ if (
92+ cascadeNmapSsh &&
93+ finding . attributes . service === "ssh"
94+ ) {
5395 await startSSHScan ( {
5496 parentScan : scan ,
5597 hostname,
@@ -64,7 +106,12 @@ async function handle({ scan, getFindings }) {
64106 ) ;
65107
66108 for ( const finding of findings ) {
67- if ( finding . category === "Subdomain" && finding . osi_layer === "NETWORK" && finding . description . startsWith ( "Found subdomain" ) ) {
109+ if (
110+ cascadeAmassNmap &&
111+ finding . category === "Subdomain" &&
112+ finding . osi_layer === "NETWORK" &&
113+ finding . description . startsWith ( "Found subdomain"
114+ ) ) {
68115 console . log ( "Found AMASS 'Subdomain' finding: " + finding . location ) ;
69116
70117 const hostname = finding . location ;
@@ -77,6 +124,24 @@ async function handle({ scan, getFindings }) {
77124 }
78125}
79126
127+ /**
128+ * Creates a new subsequent SCB ZAP Scan for the given hostname.
129+ * @param {string } hostname The hostname to start a new subsequent ZAP scan for.
130+ * @param {string } port The port to start a new subsequent ZAP scan for.
131+ */
132+ async function startSMBScan ( { parentScan, hostname} ) {
133+ console . log (
134+ " --> Starting async subsequent NMAP SMB Scan for host: " + hostname
135+ ) ;
136+
137+ await startSubsequentSecureCodeBoxScan ( {
138+ parentScan,
139+ name : `nmap-smb-${ hostname . toLowerCase ( ) } ` ,
140+ scanType : "nmap" ,
141+ parameters : [ "-Pn" , "-p445" , "--script" , "smb-protocols" , hostname ] ,
142+ } ) ;
143+ }
144+
80145/**
81146 * Creates a new subsequent SCB ZAP Scan for the given hostname.
82147 * @param {string } hostname The hostname to start a new subsequent ZAP scan for.
0 commit comments