forked from sergejmueller/wpcheck
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
directory-listing.js
51 lines (35 loc) · 1.09 KB
/
directory-listing.js
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
/**
* wpcheck module directory-listings.js
* Scan /wp-includes for Apache directory listing
*/
/**
* Required modules
*/
const request = require( 'request' ).defaults( { followRedirect: false } )
const fs = require( '../fs' )
const log = require( '../log' )
/**
* Initiator method
*
* @param {Object} data Data object with request values
* @return void
*/
exports.fire = ( data ) => {
const { wpURL, siteURL, userAgent, silentMode } = data
const filterName = fs.fileName( __filename, '.js' )
const logObj = { silentMode, filterName }
const targetURL = `${wpURL}/wp-includes/`
request( {
'url': targetURL,
'method': 'GET',
'headers': { 'User-Agent': userAgent }
}, ( error, response, body ) => {
if ( error || response.statusCode === 404 ) {
return log.info( `${targetURL} is not found`, logObj )
}
if ( body.includes( '.php' ) ) {
return log.warn( `${siteURL} has directory listing on`, logObj )
}
return log.ok( `${siteURL} has directory listing off`, logObj )
} )
}