十六进制与数字

源码:文件名:digit1.php

<?php
error_reporting(0);
if(
empty($_GET['password'])) {             
show_source(__FILE__);            
die();                          
}
function noother_says_correct($temp)
{
	$flag='flag{hello,lyn}';
	$one=ord('1');
	$nine=ord('9');
	$number='3735929054';
	//Check all the input characters!
	for ($i=0;$i<strlen($number);$i++)
	{
		//Disallow all the digits!
		$digit=ord($temp{$i});
		if(($digit>=$one)&&($digit<=$nine))
		{
			//Aha,digit not allowed
			return 'flase';
		}
	}
	if($number==$temp)
		return $flag;
}
$temp=$_GET['password'];
echo noother_says_correct($temp);
?>

代码分析:

这里,它不让输入1到9的数字,但是后面却让比较一串数字,平常的方法肯定就不能行了,大家都知道计算机中的进制转换,当然也是可以拿来比较的,0x开头则表示16进制,将这串数字转换成16进制之后发现,是deadc0de,在开头加上0x,代表这个是16进制的数字,然后再和十进制的3735929054比较,答案当然是相同的,返回true拿到flag。

?password=0xdeadc0de

在这里插入图片描述

成功获取flag。

参考链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值