当前位置:网站首页>[SUCTF 2019]EasySQL
[SUCTF 2019]EasySQL
2022-07-23 06:14:00 【Mokapeng】
[SUCTF 2019]EasySQL
Open the page and find a search box ,F12 I didn't find any valuable information , So try conventional injection first , I found that a lot of keywords were filtered .
1;show databases; Burst database
1;show tables; Name of the table
1;show columns from Flag from Filtered
At first, there was a web source code leak , Look at the source :
<?php
session_start();
include_once "config.php";
$post = array();
$get = array();
global $MysqlLink;
//GetPara();
$MysqlLink = mysqli_connect("localhost",$datauser,$datapass);
if(!$MysqlLink){
die("Mysql Connect Error!");
}
$selectDB = mysqli_select_db($MysqlLink,$dataName);
if(!$selectDB){
die("Choose Database Error!");
}
foreach ($_POST as $k=>$v){
if(!empty($v)&&is_string($v)){
$post[$k] = trim(addslashes($v));
}
}
foreach ($_GET as $k=>$v){
}
}
//die();
?>
<html>
<head>
</head>
<body>
<a> Give me your flag, I will tell you if the flag is right. </ a>
<form action="" method="post">
<input type="text" name="query">
<input type="submit">
</form>
</body>
</html>
<?php
if(isset($post['query'])){
$BlackList = "prepare|flag|unhex|xml|drop|create|insert|like|regexp|outfile |readfile|where|from|union|update|delete|if|sleep|extractvalue| updatexml|or|and|&|\"";
//var_dump(preg_match("/{$BlackList}/is",$post['query']));
if(preg_match("/{
$BlackList}/is",$post['query'])){
//echo $post['query'];
die("Nonono.");
}
if(strlen($post['query'])>40){
die("Too long.");
}
$sql = "select ".$post['query']."||flag from Flag";
mysqli_multi_query($MysqlLink,$sql);
do{
if($res = mysqli_store_result($MysqlLink)){
while($row = mysqli_fetch_row($res)){
print_r($row);
}
}
}while(@mysqli_next_result($MysqlLink));
}
?>
It is found that many keywords are indeed filtered , Find the main sql sentence
$sql = "select ".$post['query']."||flag from Flag";
There is a || sentence ,|| Is a logical operator .
|| The specific grammatical rules are :
When both operands are not NULL When the value of , If any of the operands is nonzero , The return value is 1, Otherwise, the result is 0;
When one of the operands is NULL when , If the other operand is nonzero , The return value is 1, Otherwise, the result is NULL;
Suppose both operands are NULL when , The return value is NULL.
So there is this sentence in , Any numeric input will return 1, Because of the operation , Can't get the value of the real query
So the primary goal is to make || Fail or bypass
Method 1 : The input content is *,1, At this time, the structure of SQL Statement for :
select *,1||flag from Flag, That is to say select *,1 from Flag
Method 2 : take || Becomes a string connector , That is, connect the query results
The input content is 1;set sql_mode=pipes_as_concat;select 1
The executed statements are select 1 and set sql_mode=pipes_as_concat and select 1||flag from Flag, read out flag
We can see the result of method 2 :flag There are connected 1, Method 1 no 
边栏推荐
- Remember a way to connect raspberry pie wirelessly without a display screen and can't find IP
- 视频直播源码,重置当前密码的相关改动
- js中的深拷贝浅拷贝
- Greatest common divisor and least common multiple
- 重磅!《2022中国开源发展蓝皮书》正式发布
- 2019_ AAAI_ Multi-Interactive Memory Network for Aspect Based Multimodal Sentiment Analysis
- 构建知识库时,如何避免最常见的几个错误?
- 栈溢出基础练习题——6(字符串漏洞64位下)
- 7. 求100~300间能被3整除的数的和。
- 两个及其简单的TCPUDP程序,树莓派与pc间的通信
猜你喜欢

2019_AAAI_ICCN

Theoretical basis of machine learning

递归级联网络:基于无监督学习的医学图像配准

爱奇艺向抖音开启授权,打开内容价值的新大门

星策社区发起人谭中意:用开源方式推进企业智能化转型

2019 Bar _ Aaai ICCN

C51 single chip microcomputer digital (display hours, minutes and seconds)

Implementing IO multiplexing in UNIX using epoll function to realize network socket server

2020_ ACL_ A Transformer-based joint-encoding for Emotion Recognition and Sentiment Analysis

MRS +Apache Zeppelin,让数据分析更便捷
随机推荐
C51单片机数码(显示时分秒)
机器学习理论基础
机器学习开发应用步骤的理解
中国工程院院士倪光南:拥抱开源 与世界协同创新
字符串在JVM中的内存分配
PWN --- ret2shellcode
手把手教你焊接CAD设计板底(初学者使用)图文教程
2020_ ACL_ A Transformer-based joint-encoding for Emotion Recognition and Sentiment Analysis
UNIX Programming - network socket
scikit-learn——机器学习应用开发的步骤
Introduction to SQL -- Basic additions, deletions, modifications, and exercises
视频知识点(17)- flv.js 实现播放本地视频文件的技巧
Recent ACM insights and future ideas
[untitled]
ciscn_2019_n_1 ——两种解法
Chapter7 循环神经网络-2
CSDN陪伴了我四年本科生活,自己也开始好好记录一下啦
Zstuacm registration results (complete with STL linked list)
2020_ ACM MM_ MISA: Modality-Invariant and -Specific Representations for Multimodal Sentiment Analysis
爱奇艺向抖音开启授权,打开内容价值的新大门