windows和linux包含日志文件和环境变量getshell

简介: windows和linux包含日志文件和环境变量getshell

前提知识

在linux 下日志文件权限默认是 root 而php 的权限是 www-data 一般情况下都是读取不了,如果是 windows 环境是权限是允许的。

linux 默认的 apache 日志文件路径是

访问日志

/var/log/apache2/access.log

错误日志

/var/log/apache2/error.log

把文件日志包含进来即可

/proc/self/environ 这个文件里保存了系统的一些变量

实验复现

代码区

index.php

1. <?php
2. include $_GET['file'];
3. ?>

info.php

1. <?php
2. phpinfo();
3. ?>

测试区

  • linux
?filename=../../../../../../../etc/passwd&submit=提交

这里查看日志文件发现权限不够www-data用户进行包含

访问时在url中写入恶意代码,发现被浏览器进行转码

http://192.168.10.139/?%3C?phpinfo();?%3E

使用burp进行拦截发包,此时代码出现在日志文件内(由于权限不够此时无法进行包含)

  • windows

发现仍然被编码了

通过burp发包

包含该日志文件

http://localhost:8084/?file=D:\phpstudy_pro\Extensions\Apache2.4.39\logs\access.log.1677801600

而现实是需要先找到今日日志的文件名,因为直接包含access.log会太大导致页面没有响应

我们先包含配置文件D:\phpstudy_pro\Extensions\Apache2.4.39\conf\httpd.conf

寻找logformat

%h %l %u %t \"%r\" %>s %b \"%{User-Agent}i\"

根据预制格式获取文件名

1677801600

  • linux环境变量

此时我们在User-Agen写入php代码

查看/proc/self/environ未发现(写入权限不够)

相关实践学习
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
目录
相关文章
|
8天前
|
安全 Ubuntu Linux
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
64 4
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
|
13天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
219 0
|
21天前
|
安全 Java Linux
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
39 0
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
|
安全 Linux 测试技术
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
77 0
|
1月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
106 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
21天前
|
缓存 安全 Linux
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
76 0
|
29天前
|
安全 Linux API
JEB Pro v5.31 (macOS, Linux, Windows) - 逆向工程平台
JEB Pro v5.31 (macOS, Linux, Windows) - 逆向工程平台
67 0
|
8天前
|
运维 安全 网络安全
Windows Server 2019拨号“找不到设备”?Error 1058解决指南
Windows Server 2019拨号报错1058?别急!这不是硬件故障,而是关键服务被禁用。通过“服务依存关系”排查,依次启动“安全套接字隧道协议”“远程接入连接管理”和“路由与远程访问”服务,仅需4步即可恢复PPPoE或VPN拨号功能,轻松解决网络中断问题。
78 1
|
8天前
|
存储 SQL 人工智能
Windows Server 2025 中文版、英文版下载 (2025 年 9 月更新)
Windows Server 2025 中文版、英文版下载 (2025 年 9 月更新)
400 3
Windows Server 2025 中文版、英文版下载 (2025 年 9 月更新)
|
11天前
|
安全 Unix 物联网
Windows 7 & Windows Server 2008 R2 简体中文版下载 (2025 年 9 月更新)
Windows 7 & Windows Server 2008 R2 简体中文版下载 (2025 年 9 月更新)
126 2