当前位置:网站首页>[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 
边栏推荐
- The difference between get request and post request
- Chapter7 循环神经网络-2
- 优化器(Optimizer)(SGD、Momentum、AdaGrad、RMSProp、Adam)
- Firewall knowledge, principle, equipment, manufacturer research summary report
- C51 single chip microcomputer digital (display hours, minutes and seconds)
- Chapter7 recurrent neural network-2
- esp-idf vscode配置 从下载工具链到创建工程,步骤记录
- NLP学习路线图(思维导图),非常的全面和清晰!
- Pytorch实现文本情感分析
- 视频知识点(17)- flv.js 实现播放本地视频文件的技巧
猜你喜欢

Enter two strings STR1 and STR2, and count the number of times that the string STR2 appears in STR1.

win11任务管理器怎么打开?win11任务管理器打开的技巧方法

机器学习理论基础

Chapter7 循环神经网络-1

优化器(Optimizer)(SGD、Momentum、AdaGrad、RMSProp、Adam)

ESP IDF vscode configuration from downloading tool chain to creating project, step record

中国电子信息产业发展研究院院长张立:打造我国主导的开源价值链

C language knowledge points (pointer knowledge type)

hcip第三天--MGRE实验

Implementing IO multiplexing in UNIX using poll function to realize network socket server
随机推荐
Theoretical basis of machine learning
【数据库连接】——节选自培训
[强网杯 2019]随便注
pwn ——ret2libc3
Intel(中国)云基础设施软件研发总监王庆:Intel在云原生里的技术发展和展望
js中的深拷贝浅拷贝
LC: Sword finger offer 03. repeated numbers in the array
Recent ACM insights and future ideas
2019_AAAI_Multi-Interactive Memory Network for Aspect Based Multimodal Sentiment Analysis
從鍵盤輸入一串字符,輸出不同的字符以及每個字符出現的次數。(輸出不按照順序)運用String類的常用方法解題
3步就能制作漫画头像的机器人,想拥有一个吗?
重磅!《2022中国开源发展蓝皮书》正式发布
更新C语言笔记
Encoder decoder (seq2seq)
2019_ AAAI_ ICCN
Chapter7 循环神经网络-1
Lc: sword finger offer 10- I. Fibonacci series
NLP学习路线图(思维导图),非常的全面和清晰!
中国电子信息产业发展研究院院长张立:打造我国主导的开源价值链
pwn栈溢出基础练习题——1