你真的会php,你真的会PHP吗? - osc_uyf17ab9的个人空间 - OSCHINA - 中文开源技术交流社区...

你真的会PHP吗?

会?还是不会?

解题链接: http://ctf5.shiyanbar.com/web/PHP/index.php

1.看完源代码,没有有价值的信息,打开brup抓包会发现一个.txt,打开看一下

ac4051237fc41131eecbe9b3bbbbb5e9.png

47353a80a3d1080ea0b66339046ebc3f.png

2.打开后发现是一个php程序,审计吧

$info = "";

$req = [];

$flag="xxxxxxxxxx";

ini_set("display_error", false);

error_reporting(0);

if(!isset($_POST['number'])){

header("hint:6c525af4059b4fe7d8c33a.txt");

die("have a fun!!");

}

foreach([$_POST] as $global_var) {

foreach($global_var as $key => $value) {

$value = trim($value);

is_string($value) && $req[$key] = addslashes($value);

}

}

function is_palindrome_number($number) {

$number = strval($number);

$i = 0;

$j = strlen($number) - 1;

while($i < $j) {

if($number[$i] !== $number[$j]) {

return false;

}

$i++;

$j--;

}

return true;

}

if(is_numeric($_REQUEST['number'])){ /*is_numeric — 检测变量是否为数字或数字字符串*/

$info="sorry, you cann't input a number!";

}elseif($req['number']!=strval(intval($req['number']))){

$info = "number must be equal to it's integer!! ";

}else{ $value1 = intval($req["number"]); $value2 = intval(strrev($req["number"])); if($value1!=$value2){ $info="no, this is not a palindrome number!"; }/*该数的反转的整数值应该和它本身的整数值相等*/

else{ if(is_palindrome_number($req["number"])){ /*palindrome number验证回文数字*/

$info = "nice! {$value1} is a palindrome number!"; }else{ $info=$flag; } } } echo $info;

也许你会问什么是回文数字?直接给例子

Example 1:

Input: 121

Output: true

Example 2:

Input: -121

Output: false

Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.

Example 3:

Input: 10

Output: false

Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

经过审计我们可以发现如果我们要拿到flag,POST的number需要满足以下条件:

1.不为空,且不能是一个数值型数字,包括小数。(由is_numeric函数判断)

2.不能是一个回文数。(is_palindrome_number判断)

3.该数的反转的整数值应该和它本身的整数值相等。即:

intval($req["number"])=intval(strrev($req["number"]))

2,3看似矛盾,但可以利用空格或空字符串提交,如0200%00、0200%20,构造post提交

通过科学计数法构造:0e%00 满足条件1和条件3。继续构造0e-0%00(经测试,0e+0%00是不可以的)满足所有条件。

ccad06cabb37e82b371a2ddae2744240.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值