forked from gwen001/pentest-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract-links.php
More file actions
executable file
·45 lines (36 loc) · 895 Bytes
/
extract-links.php
File metadata and controls
executable file
·45 lines (36 loc) · 895 Bytes
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
#!/usr/bin/php
<?php
function usage( $err=null ) {
echo 'Usage: '.$_SERVER['argv'][0]." <source file>\n";
if( $err ) {
echo 'Error: '.$err."!\n";
}
exit();
}
if( $_SERVER['argc'] != 2 ) {
usage();
}
$src = $_SERVER['argv'][1];
if( !is_file($src) ) {
usage( 'cannot find source file' );
}
$content = file_get_contents( $_SERVER['argv'][1] );
$content = str_replace( '>', ">\n", $content );
$t_attr = [ 'href', 'src', 'data-src', 'data-url' ];
$t_matches = [];
$a = '(href|src|data-src|data-url)';
//foreach( $t_attr as $a )
{
$r = '#<.*'.$a.'=[\'"]+([^"\'>]*)#i';
preg_match_all( $r, $content, $tmp );
//var_dump($tmp);
if( $tmp && is_array($tmp) && isset($tmp[2]) && is_array($tmp[2]) && count($tmp[2]) ) {
$t_matches = array_merge( $tmp[2], $t_matches );
}
}
//var_dump( $t_matches );
foreach( $t_matches as $m ) {
echo $m."\n";
}
exit();
?>