当前位置:网站首页>单身杯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中可以直接执行指令。
边栏推荐
- Countdown 2 days! Based on the cross development practice of Apache dolphin scheduler & tidb, you can greatly improve your efficiency from writing to scheduling
- A guide for you to fully use TS
- NIO实现
- 20220725 自动控制原理中的补偿器
- Opengauss simple version installation error
- Agile and tidy way
- MySql 中应该如何将多行数据转为多列数据
- IDEA——使用@Slf4j打印日志
- What are the basics of getting started with spot silver
- PR字幕制作
猜你喜欢

Heap parsing and heap sorting

Getting started with kernel PWN (5)

IDEA——使用@Slf4j打印日志

Image annotation software reference

【一库】妙啊!这个库组织npm脚本简直爆炸!

Become an Apache contributor, so easy!

3.0.0 alpha 重磅发布!九大新功能、全新 UI 解锁调度系统新能力
![Rgb-t tracking - [dataset benchmark] gtot / rgbt210 / rgbt234 / vot-2019-2020 / laser / VTUAV](/img/10/40d02da10a6f6779635dc820c074c6.png)
Rgb-t tracking - [dataset benchmark] gtot / rgbt210 / rgbt234 / vot-2019-2020 / laser / VTUAV

问题:Can‘t download sh shellcheck. Please install it manually及shell脚本的一些命令使用

Realization of LED water lamp based on C51
随机推荐
Drools (4): drools basic syntax (2)
A guide for you to fully use TS
Differences in the use of function call pointer parameters *p, * & P
Leetcode:749. isolate virus [Unicom component + priority queue + status representation]
Yolov5 improvements: add attention mechanism (video tutorial)
Curl post request on the server, using postman tool for parameter conversion
Common programming shortcut keys of idea (take off after learning the operation)
IDEA——使用@Slf4j打印日志
No .egg-info directory found in xxx\pip-pip-egg-info-mq
DaemonSet
Talent column | can't use Apache dolphin scheduler? The most complete introductory tutorial written by the boss in one month [3]
Heap parsing and heap sorting
Drools(2):Drools快速入门
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-5 personal solutions
Question: can't download sh shellcheck Please install it manually and some commands of shell script
Embedded development: tools -- intelligent watchdog design
Apache dolphin scheduler version 3.0.0-beta-1 was released, and flinksql and Zeppelin task types were added
中国联通改造 Apache DolphinScheduler 资源中心,实现计费环境跨集群调用与数据脚本一站式访问
Analysis of strong tennis cup 2021 PWN competition -- baby_ diary
正则表达式如何写变量