Seay源代码审计

1、Seay的介绍

Seay这是基于C#语言开发的一款针对PHP代码安全性审计的系统,主要运行于Windows系统上。这款软件能够发现SQL注入、代码执行、命令执行、文件包含、文件上传、绕过转义防护、拒绝服务、XSS跨站、信息泄露、任意URL跳转等漏洞,基本上覆盖常见PHP漏洞。另外,在功能上,它支持一键审计、代码调试、函数定位、插件扩展、自定义规则配置、代码高亮、编码调试转换、数据库执行监控等数十项强大功能。

Seay源代码审计系统主要特点如下:

(1)一键自动化白盒审计,新建项目后,在菜单栏中打开“自动审计”即可看到自动审计界面。点击“开始”按钮即可开始自动化审计。当发现可疑漏洞后,则会在下方列表框显示漏洞信息,双击漏洞项即可打开文件跳转到漏洞代码行并高亮显示漏洞代码行

(2)代码调试,代码调试功能极大地方便了审计师在审计过程中测试代码。可以在编辑器中选中代码,然后点击右键选择“调试选中”即可将代码在调试界面打开。

(3)正则编码,Seay源代码审计系统集成了实时正则调试功能,考虑到特殊字符无法直接在编辑框进行输入,在实时正则调试功能中还支持对字符串实时解码后调试。另外,支持MD5、URl、Base64、Hex、ASCII、Unicode等多种编码解码转换功能。

(4)自定义插件及规则,Seay源代码审计系统支持插件扩展,并且插件的开发非常简单,只需要将插件的dll文件放入到安装目录下的plugins文件夹内即可自动加载插件。目前自带插件包括黑盒+白盒的信息泄露审计以及MySQL数据库执行监控。

除了上述功能外,它还支持自定义审计规则,在规则配置界面中即可添加或修改以及禁用、删除规则,还可针对审计过程做很多审计习惯优化,使得程序简单容易上手。

2、Seay源代码审计系统的安装

将网上下载好的Seay源代码审计系统解压到想放的文件夹,然后创建快捷方式到桌面

image-20230417163127431

image-20230417163136013

打开运行,界面如下,image-20230417163202973

安装完成,我们进行以 DVWA 靶场为例进行分析

3、基本使用教程以及案例

3.1 基本使用教程

1、新建项目image-20230417164947585

2、选择相应的文件打开,自动审计,然后开始image-20230417194823298

3、扫描结束,发现有59个可疑漏洞image-20230417195002076

4、点击生成报告image-20230417195703480

5、选择报告保存位置

image-20230417195749543

6、生成报告成功,并在桌面生成报告

image-20230417195807454

image-20230417195915780

7、打开报告image-20230417195950061

8、结果如下

审计结果:发现可疑漏洞总数:59个

ID漏洞描述文件路径漏洞详细
1读取文件函数中存在变量,可能存在任意文件读取漏洞/instructions.php i n s t r u c t i o n s = f i l e g e t c o n t e n t s ( D V W A W E B P A G E T O R O O T . instructions = file_get_contents( DVWA_WEB_PAGE_TO_ROOT. instructions=filegetcontents(DVWAWEBPAGETOROOT.readFile );
2phpinfo()函数,可能存在敏感信息泄露漏洞/phpinfo.phpphpinfo();
3call_user_func函数参数包含变量,可能存在代码执行漏洞/dvwa/includes/Parsedown.php E l e m e n t = c a l l u s e r f u n c ( Element = call_user_func( Element=calluserfunc(closure, $Element);
4文件操作函数中存在变量,可能存在任意文件读取/删除/修改/写入等漏洞/dvwa/includes/DBMS/MySQL.php@copy($conf, $bakconf);
5读取文件函数中存在变量,可能存在任意文件读取漏洞/external/recaptcha/recaptchalib.php r e s u l t = f i l e g e t c o n t e n t s ( result = file_get_contents( result=filegetcontents(url, false, $context);
6读取文件函数中存在变量,可能存在任意文件读取漏洞/vulnerabilities/view_source_all.phpKaTeX parse error: Expected '}', got 'EOF' at end of input: …t_contents("./{id}/source/impossible.php");
7读取文件函数中存在变量,可能存在任意文件读取漏洞/vulnerabilities/view_source_all.phpKaTeX parse error: Expected '}', got 'EOF' at end of input: …t_contents("./{id}/source/high.php");
8读取文件函数中存在变量,可能存在任意文件读取漏洞/vulnerabilities/view_source_all.phpKaTeX parse error: Expected '}', got 'EOF' at end of input: …t_contents("./{id}/source/medium.php");
9读取文件函数中存在变量,可能存在任意文件读取漏洞/vulnerabilities/view_source_all.phpKaTeX parse error: Expected '}', got 'EOF' at end of input: …t_contents("./{id}/source/low.php");
10SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/authbypass/change_user_details.php$query = “UPDATE users SET first_name = '” . $data->first_name . “', last_name = '” . $data->surname . "’ where user_id = " . $data->id . “”;
11文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/authbypass/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/authbypass/source/{$vulnerabilityFile}”;
12文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/brute/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/brute/source/{$vulnerabilityFile}”;
13文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/captcha/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/captcha/source/{$vulnerabilityFile}”;
14SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/captcha/source/high.php i n s e r t = " U P D A T E ‘ u s e r s ‘ S E T p a s s w o r d = ′ insert = "UPDATE `users` SET password = ' insert="UPDATEusersSETpassword=pass_new’ WHERE user = ‘" . dvwaCurrentUser() . "’ LIMIT 1;";
15SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/captcha/source/low.php i n s e r t = " U P D A T E ‘ u s e r s ‘ S E T p a s s w o r d = ′ insert = "UPDATE `users` SET password = ' insert="UPDATEusersSETpassword=pass_new’ WHERE user = ‘" . dvwaCurrentUser() . "’;";
16SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/captcha/source/medium.php i n s e r t = " U P D A T E ‘ u s e r s ‘ S E T p a s s w o r d = ′ insert = "UPDATE `users` SET password = ' insert="UPDATEusersSETpassword=pass_new’ WHERE user = ‘" . dvwaCurrentUser() . "’;";
17文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/csp/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/csp/source/{$vulnerabilityFile}”;
18文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/csrf/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/csrf/source/{$vulnerabilityFile}”;
19SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/csrf/source/high.php$insert = “UPDATE users SET password = '” . $pass_new . “’ WHERE user = '” . dvwaCurrentUser() . “';”;
20SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/csrf/source/low.php i n s e r t = " U P D A T E ‘ u s e r s ‘ S E T p a s s w o r d = ′ insert = "UPDATE `users` SET password = ' insert="UPDATEusersSETpassword=pass_new’ WHERE user = ‘" . dvwaCurrentUser() . "’;";
21获取IP地址方式可伪造,HTTP_REFERER可伪造,常见引发SQL注入等漏洞/vulnerabilities/csrf/source/medium.phpif( stripos( S E R V E R [ ′ H T T P R E F E R E R ′ ] , _SERVER[ 'HTTP_REFERER' ] , SERVER[HTTPREFERER],_SERVER[ ‘SERVER_NAME’ ]) !== false ) {
22SQL语句delete中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/csrf/source/medium.php i n s e r t = " U P D A T E ‘ u s e r s ‘ S E T p a s s w o r d = ′ insert = "UPDATE `users` SET password = ' insert="UPDATEusersSETpassword=pass_new’ WHERE user = ‘" . dvwaCurrentUser() . "’;";
23文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/exec/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/exec/source/{$vulnerabilityFile}”;
24命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/high.php$cmd = shell_exec( 'ping -c 4 ’ . $target );
25命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/high.php$cmd = shell_exec( 'ping ’ . $target );
26命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/impossible.php$cmd = shell_exec( 'ping -c 4 ’ . $target );
27命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/impossible.php$cmd = shell_exec( 'ping ’ . $target );
28命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/low.php$cmd = shell_exec( 'ping -c 4 ’ . $target );
29命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/low.php$cmd = shell_exec( 'ping ’ . $target );
30命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/medium.php$cmd = shell_exec( 'ping -c 4 ’ . $target );
31命令执行函数中存在变量,可能存在任意命令执行漏洞/vulnerabilities/exec/source/medium.php$cmd = shell_exec( 'ping ’ . $target );
32获取IP地址方式可伪造,HTTP_REFERER可伪造,常见引发SQL注入等漏洞/vulnerabilities/fi/file3.phpKaTeX parse error: Expected '}', got 'EOF' at end of input: …ame from: <em>{_SERVER[ ‘HTTP_REFERER’ ]}
";
33获取IP地址方式可伪造,HTTP_REFERER可伪造,常见引发SQL注入等漏洞/vulnerabilities/fi/file3.php$page[ ‘body’ ] .= “Forwarded for: ” . $_SERVER[ ‘HTTP_X_FORWARDED_FOR’ ];
34文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/fi/index.phpinclude( $file );
35文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/fi/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/fi/source/{$vulnerabilityFile}”;
36文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/javascript/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/javascript/source/{$vulnerabilityFile}”;
37header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/open_redirect/source/high.phpheader ("location: " . $_GET[‘redirect’]);
38header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/open_redirect/source/low.phpheader ("location: " . $_GET[‘redirect’]);
39header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/open_redirect/source/medium.phpheader ("location: " . $_GET[‘redirect’]);
40文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/sqli/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/sqli/source/{$vulnerabilityFile}”;
41SQL语句select中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/sqli/source/medium.php$query = “SELECT first_name, last_name FROM users WHERE user_id = $id;”;
42文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/sqli_blind/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/sqli_blind/source/{$vulnerabilityFile}”;
43header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/sqli_blind/source/high.phpheader( $_SERVER[ ‘SERVER_PROTOCOL’ ] . ’ 404 Not Found’ );
44header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/sqli_blind/source/impossible.phpheader( $_SERVER[ ‘SERVER_PROTOCOL’ ] . ’ 404 Not Found’ );
45header函数或者js location有可控参数,存在任意跳转或http头污染漏洞/vulnerabilities/sqli_blind/source/low.phpheader( $_SERVER[ ‘SERVER_PROTOCOL’ ] . ’ 404 Not Found’ );
46SQL语句select中条件变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/sqli_blind/source/medium.php$query = “SELECT first_name, last_name FROM users WHERE user_id = $id;”;
47文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/upload/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/upload/source/{$vulnerabilityFile}”;
48phpinfo()函数,可能存在敏感信息泄露漏洞/vulnerabilities/upload/help/help.php

Execute any PHP function of your choosing on the target system (such as <?php echo dvwaExternalLinkUrlGet( 'https://secure.php.net/manual/en/function.phpinfo.php', 'phpinfo()' ); ?>

49存在文件上传,注意上传类型是否可控/vulnerabilities/upload/source/high.phpif( !move_uploaded_file( $uploaded_tmp, $target_path ) ) {
50文件操作函数中存在变量,可能存在任意文件读取/删除/修改/写入等漏洞/vulnerabilities/upload/source/impossible.phpunlink( $temp_file );
51存在文件上传,注意上传类型是否可控/vulnerabilities/upload/source/low.phpif( !move_uploaded_file( $_FILES[ ‘uploaded’ ][ ‘tmp_name’ ], $target_path ) ) {
52存在文件上传,注意上传类型是否可控/vulnerabilities/upload/source/medium.phpif( !move_uploaded_file( $_FILES[ ‘uploaded’ ][ ‘tmp_name’ ], $target_path ) ) {
53文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/weak_id/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/weak_id/source/{$vulnerabilityFile}”;
54文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/xss_d/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/xss_d/source/{$vulnerabilityFile}”;
55文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/xss_r/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/xss_r/source/{$vulnerabilityFile}”;
56文件包含函数中存在变量,可能存在文件包含漏洞/vulnerabilities/xss_s/index.phprequire_once DVWA_WEB_PAGE_TO_ROOT . “vulnerabilities/xss_s/source/{$vulnerabilityFile}”;
57SQL语句insert中插入变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/xss_s/source/high.php q u e r y = " I N S E R T I N T O g u e s t b o o k ( c o m m e n t , n a m e ) V A L U E S ( ′ query = "INSERT INTO guestbook ( comment, name ) VALUES ( ' query="INSERTINTOguestbook(comment,name)VALUES(message’, ‘$name’ );";
58SQL语句insert中插入变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/xss_s/source/low.php q u e r y = " I N S E R T I N T O g u e s t b o o k ( c o m m e n t , n a m e ) V A L U E S ( ′ query = "INSERT INTO guestbook ( comment, name ) VALUES ( ' query="INSERTINTOguestbook(comment,name)VALUES(message’, ‘$name’ );";
59SQL语句insert中插入变量无单引号保护,可能存在SQL注入漏洞/vulnerabilities/xss_s/source/medium.php q u e r y = " I N S E R T I N T O g u e s t b o o k ( c o m m e n t , n a m e ) V A L U E S ( ′ query = "INSERT INTO guestbook ( comment, name ) VALUES ( ' query="INSERTINTOguestbook(comment,name)VALUES(message’, ‘$name’ );";

3.2 漏洞分析–暴力破解漏洞

1、找到 low.php

image-20230417201410593

2、注入绕过

admin’ or ‘1’='1

admin’ or '1

3.3 sql注入

1、选中相关的漏洞,双击漏洞信息,以sql注入为例image-20230417204119020

2、点击View Source按钮生成源码,定位代码中可能存在漏洞的部分

image-20230417204152878

3、打开生成的报告,报告包含漏洞描述、文件路径和漏洞详细,选择163行,命令执行漏洞进行测试。首先,会将输入ip给了target,然后第十九行会ping一下target。

image-20230417204255458

4、根据以上使用Seay系统对sql注入漏洞的分析,可知如果存在漏洞,就会Ping一下这个ip。我这里选的Ip为127.0.0.1,在靶场中输入

image-20230417204359928

5、点击View Source生成源码,并对源码进行分析。image-20230417204441953

6、与Seay分析的结果进行比较,发现一样。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐