-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathargs_grabber.php
45 lines (36 loc) · 1.77 KB
/
args_grabber.php
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
<?php
/**
* Граббер для поисковика параметров
*
* @author Beched <Ahack.Ru>
* @copyright Hack4Sec-team <hack4sec.team@gmail.com> 2011
* @link http://hack4sec.blogspot.com/
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
if( $_SERVER[ 'argc' ] != 2 ) die( 'Usage: php args_grabber.php /path/to/dir/with/php/sources' );
function rglob( $dir, $pattern = '*', $flags = 0 ) {
$paths = glob( $dir . DIRECTORY_SEPARATOR . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT );
$files = glob( $dir . DIRECTORY_SEPARATOR . $pattern, $flags );
foreach ( $paths as $path ) {
if( $path != '.' && $path != '..' )
$files = array_merge( $files, rglob( $path, $pattern, $flags ) );
}
return $files;
}
print( "============================\nBrowsing files...\n" );
$files = rglob( $_SERVER[ 'argv' ][ 1 ], '*.php' );
print( "============================\nFound " . count( $files ) . " files.\nNow parsing files to find parameters...\n" );
$params = array();
foreach( $files as $name ) {
preg_match_all( '#(GET|POST|COOKIE)\[(\'|\")?([^\$](\w)*)(\'|\')?\]#Usi', file_get_contents( $name ), $matches );
$params = array_merge( $params, $matches[ 3 ] );
}
print( "============================\nGrabbed " . count( $params ) . " parameters.\n" );
$all = array_map( 'trim', file( './bases/argsbase.txt' ) );
$params = array_unique( array_merge( $all, array_map( function( $val ) {
return trim( $val, ' \'"');
}, $params ) ) );
file_put_contents( './bases/argsbase.txt', '' );
print( "============================\nRemoved duplicates, now " . count( $params ) . " parameters in base.\n" );
foreach( $params as $param)
file_put_contents( './bases/argsbase.txt', trim( $param, ' \'"' ) . "\n", FILE_APPEND );