bugku 十六進製制與數字比較

2021-10-18 23:15:14 字數 859 閱讀 2496

<?php

error_reporting(0);

function noother_says_correct($temp)

';$one = ord('1'); //ord — 返回字元的 ascii 碼值

$nine = ord('9'); //ord — 返回字元的 ascii 碼值

$number = '3735929054';

// check all the input characters!

for ($i = 0; $i < strlen($number); $i++)

);if ( ($digit >= $one) && ($digit <= $nine) )

}if($number == $temp)

return $flag;

}$temp = $_get['password'];

echo noother_says_correct($temp);

?>

if ( ($digit >= $one) && ($digit <= $nine) )

return "flase"

password不允許數字1~9
number =temp=password

這本來是自相矛盾的,但php在轉碼時會把16進製制轉化為十進位制.於是想到當number =temp=password=3735929054轉化為十六進製制時,或許不存在數字1–9,得到deadc0de,果然不含1~9

構造payload:?password=0xdeadc0de

(以0x開頭的數值表示16進製制)

Bugku 十六進製制與數字比較

今日份ctf。2018年11月2日 首先來看看原始碼 error reporting 0 function noother says correct temp one ord 1 ord 返回字元的 ascii 碼值 nine ord 9 ord 返回字元的 ascii 碼值 number 3735...

十六進製制與數字

原始碼 檔名 digit1.php error reporting 0 if empty get password function noother says correct temp one ord 1 nine ord 9 number 3735929054 check all the inpu...

CString轉十六進製制數字

借用strtol函式可以直接將乙個cstring物件轉化為任意數制的整數。比如 cstring st 20 int n strtol st,null,16 strtol函式原型 long int strtol const char nptr,char endptr,int base 引數base範圍...