Attack and defense world simple_php (web simple)

Topic: Xiaoning heard that PHP is the best language, so she simply learned it and wrote a few lines of PHP code.

After opening, you will see a few lines of php code:

<?php
show_source(__FILE__);		//高亮显示代码
include("config.php");		//引用config.php,
$a=@$_GET['a'];				//传值a,发生错误时不显示
$b=@$_GET['b'];				//传值b,发生错误时不显示
if($a==0 and $a){
    
    			//如果a==0且a为真
    echo $flag1;			//输出第一部分flag
}
if(is_numeric($b)){
    
    			//如果b为数字或数字字符串
    exit();					//退出(即b不可以为数字或者数字字符串)
}
if($b>1234){
    
    				//b>1234
    echo $flag2;			//输出第2部分flag
}
?> 

So, here we are looking for a value, which is ==0 and is true .
Since PHP is a weak language, its "==" only indicates that the values ​​are equal, and when a string composed of numbers and letters is compared with a number, only the first number will participate in the comparison. So we write a variable a=0asdf, that is, a=0 plus a string of letters . In the same way b = a number greater than 1234 plus a string of letters .
A comparison example is as follows:

<?php
$a="0asdf";
$b="4444asdf";

if ($a==0) {
    
    
	echo "a==0<br/>";
}else{
    
    
	echo "a!=0<br/>";
}

if ($a) {
    
    
	echo "a is true<br/>";
}else{
    
    
	echo "a is false<br/>";
}

if (is_numeric($b)) {
    
    
	echo "b is num<br/>";
}else{
    
    
	echo "b isn\'t num<br/>";
}
if ($b>1234) {
    
    
	echo "b > 1234<br/>";
}else{
    
    
	echo "b  !> b<br/>";
}

Insert image description here
We bring in the values ​​​​of a and b and get the result: Cyberpeace{647E37C7627CC3E4019EC69324F66C7C}
Insert image description here

Guess you like

Origin blog.csdn.net/my_name_is_sy/article/details/124990301