Skip to content

Commit a1d6a40

Browse files
IlyesbdlalaJ12934
authored andcommitted
#519 Added references attribute to wpscan findings
also added finding parsing for vulnerablites in plugins Signed-off-by: Ilyes Ben Dlala <ilyes.bendlala@iteratec.com>
1 parent 15b25cf commit a1d6a40

2 files changed

Lines changed: 124 additions & 17 deletions

File tree

‎scanners/wpscan/parser/parser.js‎

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Convert the WPScan file / json into secureCodeBox Findings
77
*/
88
async function parse(scanResults) {
9-
if (typeof(scanResults) === "string") // empty file
9+
if (typeof (scanResults) === "string") // empty file
1010
return [];
1111

1212
const wpscanVersion = scanResults.banner.version;
@@ -15,7 +15,7 @@ async function parse(scanResults) {
1515
const targetUrl = scanResults.target_url;
1616
const targetIp = scanResults.target_ip;
1717
// convert unix timestamp to ISO date string, multiply by 1000 because JS uses milliseconds
18-
const identified_at = new Date(scanResults.stop_time * 1000).toISOString();
18+
const identified_at = new Date(scanResults.stop_time * 1000).toISOString();
1919

2020
const findings = [];
2121

@@ -28,7 +28,7 @@ async function parse(scanResults) {
2828
location: targetUrl,
2929
osi_layer: "APPLICATION",
3030
severity: "INFORMATIONAL",
31-
reference: {},
31+
references: null,
3232
confidence: scanResults.version?.confidence,
3333
attributes: {
3434
hostname: targetUrl,
@@ -47,7 +47,17 @@ async function parse(scanResults) {
4747

4848
// add all interesting findings as INFORMATIONAL
4949
for (const interestingFinding of scanResults.interesting_findings) {
50-
//console.log(interestingFinding);
50+
let references = [];
51+
if (Object.keys(interestingFinding.references).length > 0) {
52+
for (const key in interestingFinding.references) {
53+
for (const element of interestingFinding.references[key]) {
54+
references.push({
55+
"type": key.toUpperCase(),
56+
"value": element
57+
});
58+
}
59+
}
60+
}
5161
findings.push({
5262
name: "WordPress finding '" + interestingFinding.type + "'",
5363
description: interestingFinding.to_s,
@@ -56,7 +66,7 @@ async function parse(scanResults) {
5666
osi_layer: "APPLICATION",
5767
severity: "INFORMATIONAL",
5868
confidence: interestingFinding.confidence,
59-
reference: {},
69+
references: references.length > 0 ? references : null,
6070
attributes: {
6171
hostname: targetUrl,
6272
wp_interesting_entries: interestingFinding.interesting_entries,
@@ -66,6 +76,40 @@ async function parse(scanResults) {
6676
});
6777
}
6878

79+
// add plugin vulnerabilities as HIGH
80+
Object.values(scanResults.plugins).forEach(plugin => {
81+
plugin.vulnerabilities.forEach(vulnerability => {
82+
let references = [];
83+
// check if references are available
84+
if (Object.keys(vulnerability.references).length > 0){
85+
for (const key in vulnerability.references) {
86+
for (const element of vulnerability.references[key]) {
87+
references.push({
88+
"type": key.toUpperCase(),
89+
"value": element
90+
});
91+
}
92+
}
93+
}
94+
findings.push({
95+
name: "WordPress finding: vulnerability in '" + plugin['slug'] + "'",
96+
description: vulnerability['title'],
97+
category: "WordPress Plugin",
98+
location: plugin['location'],
99+
osi_layer: "APPLICATION",
100+
severity: "HIGH",
101+
references: references.length > 0 ? references : null,
102+
attributes: {
103+
hostname: targetUrl,
104+
confidence: plugin['confidence'],
105+
wp_interesting_entries: plugin['interesting_entries'],
106+
wp_found_by: plugin['found_by'],
107+
wp_confirmed_by: plugin['confirmed_by'],
108+
},
109+
});
110+
})
111+
});
112+
69113
return findings;
70114
}
71115

‎scanners/wpscan/parser/parser.test.js‎

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test("WPScan parser parses a successfully scan result with at least one informat
4848
"location": "https://www.example.com/",
4949
"name": "WordPress Service",
5050
"osi_layer": "APPLICATION",
51-
"reference": {},
51+
"references": null,
5252
"severity": "INFORMATIONAL",
5353
},
5454
{
@@ -66,7 +66,7 @@ test("WPScan parser parses a successfully scan result with at least one informat
6666
"location": "https://www.example.com/",
6767
"name": "WordPress finding 'headers'",
6868
"osi_layer": "APPLICATION",
69-
"reference": {},
69+
"references": null,
7070
"severity": "INFORMATIONAL",
7171
},
7272
{
@@ -85,7 +85,7 @@ test("WPScan parser parses a successfully scan result with at least one informat
8585
"location": "https://www.example.com/robots.txt",
8686
"name": "WordPress finding 'robots_txt'",
8787
"osi_layer": "APPLICATION",
88-
"reference": {},
88+
"references": null,
8989
"severity": "INFORMATIONAL",
9090
},
9191
{
@@ -101,7 +101,7 @@ test("WPScan parser parses a successfully scan result with at least one informat
101101
"location": "https://www.example.com/readme.html",
102102
"name": "WordPress finding 'readme'",
103103
"osi_layer": "APPLICATION",
104-
"reference": {},
104+
"references": null,
105105
"severity": "INFORMATIONAL",
106106
},
107107
{
@@ -117,7 +117,12 @@ test("WPScan parser parses a successfully scan result with at least one informat
117117
"location": "https://www.example.com/wp-content/mu-plugins/",
118118
"name": "WordPress finding 'mu_plugins'",
119119
"osi_layer": "APPLICATION",
120-
"reference": {},
120+
"references": [
121+
{
122+
"type": "URL",
123+
"value": "http://codex.wordpress.org/Must_Use_Plugins",
124+
},
125+
],
121126
"severity": "INFORMATIONAL",
122127
},
123128
{
@@ -133,9 +138,53 @@ test("WPScan parser parses a successfully scan result with at least one informat
133138
"location": "https://www.example.com/wp-cron.php",
134139
"name": "WordPress finding 'wp_cron'",
135140
"osi_layer": "APPLICATION",
136-
"reference": {},
141+
"references": [
142+
{
143+
"type": "URL",
144+
"value": "https://www.iplocation.net/defend-wordpress-from-ddos",
145+
},
146+
{
147+
"type": "URL",
148+
"value": "https://github.com/wpscanteam/wpscan/issues/1299",
149+
},
150+
],
137151
"severity": "INFORMATIONAL",
138152
},
153+
{
154+
"attributes": {
155+
"confidence": 80,
156+
"hostname": "https://www.example.com/",
157+
"wp_confirmed_by": {},
158+
"wp_found_by": "Known Locations (Aggressive Detection)",
159+
"wp_interesting_entries": [
160+
"https://www.example.com/wp-content/plugins/akismet/, status: 403",
161+
],
162+
},
163+
"category": "WordPress Plugin",
164+
"description": "Akismet 2.5.0-3.1.4 - Unauthenticated Stored Cross-Site Scripting (XSS)",
165+
"location": "https://www.example.com/wp-content/plugins/akismet/",
166+
"name": "WordPress finding: vulnerability in 'akismet'",
167+
"osi_layer": "APPLICATION",
168+
"references": [
169+
{
170+
"type": "CVE",
171+
"value": "2015-9357",
172+
},
173+
{
174+
"type": "URL",
175+
"value": "http://blog.akismet.com/2015/10/13/akismet-3-1-5-wordpress/",
176+
},
177+
{
178+
"type": "URL",
179+
"value": "https://blog.sucuri.net/2015/10/security-advisory-stored-xss-in-akismet-wordpress-plugin.html",
180+
},
181+
{
182+
"type": "WPVULNDB",
183+
"value": "8215",
184+
},
185+
],
186+
"severity": "HIGH",
187+
},
139188
]
140189
`);
141190
});
@@ -172,7 +221,7 @@ test("WPScan parser parses a scan result file without a detected wp version corr
172221
"location": "https://wp.example.com/",
173222
"name": "WordPress Service",
174223
"osi_layer": "APPLICATION",
175-
"reference": {},
224+
"references": null,
176225
"severity": "INFORMATIONAL",
177226
},
178227
{
@@ -191,7 +240,7 @@ test("WPScan parser parses a scan result file without a detected wp version corr
191240
"location": "https://wp.example.com/",
192241
"name": "WordPress finding 'headers'",
193242
"osi_layer": "APPLICATION",
194-
"reference": {},
243+
"references": null,
195244
"severity": "INFORMATIONAL",
196245
},
197246
{
@@ -210,7 +259,7 @@ test("WPScan parser parses a scan result file without a detected wp version corr
210259
"location": "https://wp.example.com/robots.txt",
211260
"name": "WordPress finding 'robots_txt'",
212261
"osi_layer": "APPLICATION",
213-
"reference": {},
262+
"references": null,
214263
"severity": "INFORMATIONAL",
215264
},
216265
{
@@ -226,7 +275,7 @@ test("WPScan parser parses a scan result file without a detected wp version corr
226275
"location": "https://wp.example.com/readme.html",
227276
"name": "WordPress finding 'readme'",
228277
"osi_layer": "APPLICATION",
229-
"reference": {},
278+
"references": null,
230279
"severity": "INFORMATIONAL",
231280
},
232281
{
@@ -242,7 +291,12 @@ test("WPScan parser parses a scan result file without a detected wp version corr
242291
"location": "https://wp.example.com/wp-content/mu-plugins/",
243292
"name": "WordPress finding 'mu_plugins'",
244293
"osi_layer": "APPLICATION",
245-
"reference": {},
294+
"references": [
295+
{
296+
"type": "URL",
297+
"value": "http://codex.wordpress.org/Must_Use_Plugins",
298+
},
299+
],
246300
"severity": "INFORMATIONAL",
247301
},
248302
{
@@ -258,7 +312,16 @@ test("WPScan parser parses a scan result file without a detected wp version corr
258312
"location": "https://wp.example.com/wp-cron.php",
259313
"name": "WordPress finding 'wp_cron'",
260314
"osi_layer": "APPLICATION",
261-
"reference": {},
315+
"references": [
316+
{
317+
"type": "URL",
318+
"value": "https://www.iplocation.net/defend-wordpress-from-ddos",
319+
},
320+
{
321+
"type": "URL",
322+
"value": "https://github.com/wpscanteam/wpscan/issues/1299",
323+
},
324+
],
262325
"severity": "INFORMATIONAL",
263326
},
264327
]

0 commit comments

Comments
 (0)