当前位置: 首页 > news >正文

pikachu靶场CSRF-post测试报告

目录

一、测试环境

1、系统环境

2、使用工具/软件

二、测试目的

三、操作过程

1、抓包使用burp生成csrf脚本

四、源代码分析

五、结论


一、测试环境

1、系统环境

渗透机:本机(127.0.0.1)

靶  机:本机(127.0.0.1)

2、使用工具/软件

Burp suite2024.7.2

测试网址:http://127.0.0.1/pikachu/pikachu/vul/csrf/csrfpost/csrf_post_login.php

二、测试目的

实现post请求方式页面的csrf攻击,修改页面内容。

三、操作过程

1、抓包使用burp生成csrf脚本

根据提示的用户,登录到会员中心,页面提交即可修改参数

如下就是提交修改的请求包,是post方式,参数在请求主体中

请求报文中,右键-->engagement tools-->generate CSRF Poc

生成csrf的利用代码

这个利用代码,使用表单提交了原本post请求中的参数,是html写的

可以手动修改提交的参数值,访问这个html页面即可提交到修改信息的页面

请求方法是post

我将csrf利用poc保存在根目录下

访问这个页面,只需要点击提交,即可修改用户的信息

点击提交,成功修改信息

四、源代码分析

<?php
/*** Created by runner.han* There is nothing new under the sun*/$SELF_PAGE = substr($_SERVER['PHP_SELF'],strrpos($_SERVER['PHP_SELF'],'/')+1);if ($SELF_PAGE = "csrf_post_edit.php"){$ACTIVE = array('','','','','','','','','','','','','','','','','','','','','','','','','','active open','','','','active','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','');}$PIKA_ROOT_DIR =  "../../../";
include_once $PIKA_ROOT_DIR . 'header.php';include_once $PIKA_ROOT_DIR."inc/config.inc.php";
include_once $PIKA_ROOT_DIR."inc/function.php";
include_once $PIKA_ROOT_DIR."inc/mysql.inc.php";
$link=connect();
// 判断是否登录,没有登录不能访问
if(!check_csrf_login($link)){
//    echo "<script>alert('登录后才能进入会员中心哦')</script>";header("location:csrf_post_login.php");
}$html1='';
if(isset($_POST['submit'])){if($_POST['sex']!=null && $_POST['phonenum']!=null && $_POST['add']!=null && $_POST['email']!=null){$getdata=escape($link, $_POST);$query="update member set sex='{$getdata['sex']}',phonenum='{$getdata['phonenum']}',address='{$getdata['add']}',email='{$getdata['email']}' where username='{$_SESSION['csrf']['username']}'";$result=execute($link, $query);if(mysqli_affected_rows($link)==1 || mysqli_affected_rows($link)==0){header("location:csrf_post.php");}else {$html1.='修改失败,请重试';}}
}?>
……
<div class="page-content"><?php//通过当前session-name到数据库查询,并显示其对应信息$username=$_SESSION['csrf']['username'];$query="select * from member where username='$username'";$result=execute($link, $query);$data=mysqli_fetch_array($result, MYSQL_ASSOC);$name=$data['username'];$sex=$data['sex'];$phonenum=$data['phonenum'];$add=$data['address'];$email=$data['email'];$html=<<<A
<div id="per_info"><form method="post"><h1 class="per_title">hello,{$name},欢迎来到个人会员中心 | <a style="color:bule;" href="csrf_post.php?logout=1">退出登录</a></h1><p class="per_name">姓名:{$name}</p><p class="per_sex">性别:<input type="text" name="sex" value="{$sex}"/></p><p class="per_phone">手机:<input class="phonenum" type="text" name="phonenum" value="{$phonenum}"/></p>    <p class="per_add">住址:<input class="add" type="text" name="add" value="{$add}"/></p> <p class="per_email">邮箱:<input class="email" type="text" name="email" value="{$email}"/></p> <input class="sub" type="submit" name="submit" value="submit"/></form>
</div>
A;echo $html;echo $html1;?>

只是将获取变量方式改为了post方式。页面对身份进行了验证,但没有校验身份的真实性,可能会被伪造身份。造成csrf攻击。

五、结论

csrf攻击的原理是服务器未设置身份校验,导致身份容易被冒用,造成越权修改信息、执行命令等操作。

对于身份校验,应启用对应策略,保证身份不会被冒用。

使用post方式提交,更安全一些,不会将参数暴露在url中。


http://www.mrgr.cn/news/51888.html

相关文章:

  • leetcode中常用的enumerate用法和常用场景
  • 基于Python的自然语言处理系列(35):Transformer 模型的微调(Finetuning)
  • 3-6 AUTOSAR RTE数据一致性管理
  • Corgi Raytracing - Built-in RP Forward Deferred URP VR SPI supported 光线追踪
  • spark:Structured Streaming介绍
  • 基于ST VIPERGAN50的50W 反激隔离型智能风冷无霜冰箱电源解决方案
  • Elasticsearch:Redact(编辑) processor
  • 【系统配置】信创系统配置文件保护与防篡改 _ 统信 _ 麒麟 _ 方德
  • MOE论文详解(3)-Switch Transformers
  • 猫头虎 分享:Python库 BeautifulSoup 的简介、安装、用法详解入门教程
  • Redis 常用指令详解
  • 基于Datawhale开源的量化投资学习指南(2):宏观经济学基础概念
  • MySQL - Navicat自动备份MySQL数据
  • CAXA制造工程师2024软件下载
  • 【2022工业3D异常检测文献】Patch+FPFH: 结合3D手工点云描述符和颜色特征的异常检测方法
  • SQL Injection | SQL 注入 —— 数据提交方式
  • ESP32-IDF GPIO 专题
  • x-cmd pkg | deno - Node.js 创始人的创新之作,安全且现代的 Node.js 替代方案
  • C++ 学习笔记八 数组
  • TCP/IP 协议【四次挥手】简要说明