根据文件名就知道是IDS相关的

 1 <?php
 2 
 3 if( !defined( 'DVWA_WEB_PAGE_TO_ROOT' ) ) {
 4     define( 'DVWA System error- WEB_PAGE_TO_ROOT undefined' );
 5     exit;
 6 }
 7 
 8 define( 'DVWA_WEB_ROOT_TO_PHPIDS', 'external/phpids/'.dvwaPhpIdsVersionGet().'/' );
 9 define( 'DVWA_WEB_PAGE_TO_PHPIDS', DVWA_WEB_PAGE_TO_ROOT.DVWA_WEB_ROOT_TO_PHPIDS );
10 
11 // Add PHPIDS to include path
12 set_include_path( get_include_path().PATH_SEPARATOR.DVWA_WEB_PAGE_TO_PHPIDS.'lib/' );
13 
14 require_once 'IDS/Init.php';
15 
16 function dvwaPhpIdsVersionGet() {
17     return '0.6';
18 }

我们先分析前面的18行

3-6行就是一个是否已定义的判断,在前面我们已经分析过了,这里不再复述。

8-9行定义一个新目录变量,这样就可以更方面的包含目录或文件了。

第8行的dvwaPhpIdsVersionGet()函数在16行定义,返回PhpIds的版本号。

第12行的set_include_path表示包含文件路径,这样做的目的是包含文件的时候可以省略文件路径,直接使用文件名。

第14行又包含一个新的文件,这个文件是在set_include_path的基础上包含的。这里我就不继续分析下去了,因为越分析文件会更多。

 

下面是几个函数

我们来第一个函数

 1 // PHPIDS Log parsing function 
 2 function dvwaReadIdsLog() {
 3 
 4     $file_array = file(DVWA_WEB_PAGE_TO_PHPIDS_LOG);
 5     
 6     $data = '';
 7 
 8     foreach ($file_array as $line_number => $line){
 9         $line = explode(",", $line);
10         $line = str_replace("\""," ",$line);
11         
12         $datetime = $line[1];
13         $vulnerability = $line[3];
14         $variable = urldecode($line[4]);
15         $request = urldecode($line[5]);
16         $ip = $line[6];
17         
18         $data .= "<div id=\"idslog\"><b>Date/Time:</b> " . $datetime . "<br /><b>Vulnerability:</b> " . $vulnerability . "<br /><b>Request:</b> " . htmlspecialchars($request) . "<br /><b>Variable:</b> " . htmlspecialchars($variable) . "<br /><b>IP:</b> " . $ip . "</div>";
19     }
20 
21 return $data;
22 }
PHPIDS 日志解析函数

相关文章:

  • 2021-04-12
  • 2021-09-19
  • 2021-05-20
  • 2021-09-10
  • 2019-08-26
  • 2018-06-06
  • 2021-11-27
  • 2021-08-12
猜你喜欢
  • 2021-08-14
  • 2020-07-15
  • 2021-06-28
  • 2021-11-19
  • 2021-04-21
  • 2019-09-09
  • 2018-09-21
  • 2021-10-15
相关资源
相似解决方案