ctf technology to bypass the preg_match

1, example

<?php
error_reporting(0);
if(isset($_GET['code'])){
        $code=$_GET['code'];
            if(strlen($code)>40){
                    die("This is too Long.");
                    }
            if(preg_match("/[A-Za-z0-9]+/",$code)){
                    die("NO.");
                    }
            @eval($code);
}
else{
        highlight_file(__FILE__);
}
highlight_file(__FILE);

// ?>

Use bypass XOR: exclusive or configurations may be used in the various special characters and letters and numbers

str = r"~!@#$%^&*()_+<>?,.;:-[]{}\/"

for i in range(0, len(str)):
    for j in range(0, len(str)):
        a = ord(str[i])^ord(str[j])
        print(str[i] + ' ^ ' + str[j] + ' is ' + chr(a))

Command successfully trigger execution:

Guess you like

Origin www.cnblogs.com/v01cano/p/11736722.html