ν‹°μŠ€ν† λ¦¬ λ·°

WEB

WebDAV 취약점

🌧: 2020. 10. 25.
κ°œμš”

HTTP(S) ν”„λ‘œν† μ½œμ˜ ν™•μž₯ κΈ°λŠ₯으둜 μ›κ²©μœΌλ‘œ μ›Ή μ„œλ²„λ₯Ό read/write(읽기/μ“°κΈ°)κ°€ κ°€λŠ₯ν•˜λ„λ‘ λ§Œλ“€μ–΄μ€λ‹ˆλ‹€. λ˜ν•œ μ‚¬μš©μžκ°€ ν•΄λ‹Ή μ„œλ²„μ— λ¬Έμ„œλ₯Ό μƒμ„±ν•˜κ³  이동도 κ°€λŠ₯ν•˜μ§€λ§Œ, μ˜¬λ°”λ₯Έ λ³΄μ•ˆμ„€μ •μ΄ λ˜μ–΄ μžˆμ§€ μ•ŠμœΌλ©΄ κ³΅κ²©μžλŠ” μ•…μ„± νŒŒμΌμ„ μ—…λ‘œλ“œν•΄μ„œ μ‹œμŠ€ν…œμ— μΉ¨νˆ¬ν•˜κ±°λ‚˜ νŒŒμΌμ„ λ³€μ‘°ν•˜μ—¬ κ°€μš©μ„± λ˜λŠ” 무결성을 μΉ¨λ²”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

 

μ—¬κΈ°μ„œ λ§ν•˜λŠ” 잘λͺ»λœ λ³΄μ•ˆ μ„€μ •μ΄λž€

(1) μ‚¬μš©ν•˜μ§€ μ•Šμ§€λ§Œ ν™œμ„±ν™” ν•΄ λ‘” 경우

(2) μ‚¬μš©ν•˜κ³  μžˆμ§€λ§Œ μ ‘κ·Όν•˜μ§€ 말아야 될 곳에 Write(μ“°κΈ°) κΆŒν•œμ΄ λΆ€μ—¬λœ 경우

 

μƒμœ„μ˜ 2가지 μš”κ±΄μ΄ μΆ©μ‘±λœλ‹€λ©΄ ν•΄μ»€λŠ” μ•…μ˜μ μΈ μ›Ήμ‰˜ νŒŒμΌμ„ μ—…λ‘œλ“œν•˜μ—¬ κ³Όλ„ν•œ κΆŒν•œμ΄ λΆ€μ—¬λœ "index.php" νŒŒμΌμ„ λ³€μ‘°ν•˜μ—¬ DBD(Drive by Download) 곡격을 μ‹œλ„ν•˜κ±°λ‚˜ ν™ˆνŽ˜μ΄μ§€ 자체λ₯Ό λ³€μ‘°μ‹œμΌœ μ„œλΉ„μŠ€λ₯Ό 뢈λŠ₯으둜 λ§Œλ“€μ–΄λ²„λ¦΄ κ°€λŠ₯성이 μ‘΄μž¬ν•©λ‹ˆλ‹€.

 

WebDAVκ°€ ν™œμ„±ν™”λœ λŒ€μƒ μ„œλ²„μ— μ‘΄μž¬ν•˜λŠ” 파일 λ¦¬μŠ€νŠΈλ“€μ΄ ν™•μΈλ˜κ³  μžˆμŠ΅λ‹ˆλ‹€. κ³΅κ²©μžλŠ” WebDAV 디렉터리에 μ ‘κ·Όν•˜μ—¬ μ•…μ„± νŒŒμΌμ„ μ—…λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€.

 

webdav κ°€ ν™œμ„±ν™” 쀑인지 그리고 μ–΄λ– ν•œ λ©”μ„œλ“œλ₯Ό ν—ˆμš©ν•˜κ³  μžˆλŠ”μ§€ ν™•μΈν•˜κΈ°μœ„ν•΄ GET λ©”μ†Œλ“œλ₯Ό --> OPTIONS둜 λ³€κ²½ν•΄μ£Όκ³  μ£Όμ†Œλ₯Ό μ œμ™Έν•œ λ‚˜λ¨Έμ§€ μ˜μ—­μ€ λͺ¨λ‘ 날리고 Forward ν•΄μ€λ‹ˆλ‹€. 그럼 history μ•ˆμ— μ›ν•˜λŠ” 정보가 담겨 μžˆμ„ κ²ƒμž…λ‹ˆλ‹€.

 

HTTP history의 ResponseλΌλŠ” μ‘λ‹΅λž€μ— ν—ˆμš©ν•˜κ³  μžˆλŠ” λ©”μ†Œλ“œ λ¦¬μŠ€νŠΈλ“€μ΄ λ…ΈμΆœλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

OPTIONS : μ›Ή μ„œλ²„μ—μ„œ μ§€μ›λ˜λŠ” λ©”μ„œλ“œμ˜ μ’…λ₯˜λ₯Ό 확인할 λ•Œ μ‚¬μš©
PUT : Upload ν•˜λŠ” κΈ°λŠ₯을 κ°€μ‘ŒμŒ
HEAD : μ›Ή μ„œλ²„μ˜ 버전 정보, ν—¬μŠ€μ²΄ν¬, μ΅œμ’… μˆ˜μ • 일자 λ“± ν™•μΈμš©λ„

 

정상적인 μš”μ²­μ„ 받은 ν›„ put λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ μ›ν•˜λŠ” νŒŒμΌμ„ μ—…λ‘œλ“œμ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€. μ„±κ³΅μ μœΌλ‘œ λ°˜μ‘ν•œλ‹€λ©΄ ν•΄λ‹Ή νŽ˜μ΄μ§€μ—λŠ” CreatedλΌλŠ” 문ꡬ가 λ‚˜μ˜΅λ‹ˆλ‹€.

 

ν™œμ„±ν™”λœ WebDAVλ₯Ό μ‹λ³„ν•˜κ³  λŒ€μƒ μ„œλ²„μ—μ„œ ν—ˆμš©μ‹œμΌœλ‘” "PUT" λ©”μ„œλ“œλ₯Ό ν™œμš©ν•˜μ—¬ ν”„λ‘μ‹œ νˆ΄μ„ 톡해 μ„±κ³΅μ μœΌλ‘œ κ°±μ‹ μ‹œμΌœμ€¬μŠ΅λ‹ˆλ‹€.

 

ν”„λ‘μ‹œ 도ꡬ 이외에 μ ‘κ·Ό 방법

(1) FTP의 계정과 κΆŒν•œ 체크

(2) cadaver 도ꡬλ₯Ό 톡해 μ—…λ‘œλ“œ

 

μ›Ή ν”„λ‘μ‹œ 도ꡬ 이외에 또 λ‹€λ₯Έ λ°©λ²•μœΌλ‘œλŠ” FTP μ„œλΉ„μŠ€μ˜ 읡λͺ… 계정과 κΆŒν•œμ„ μ²΄ν¬ν•˜μ—¬ μœ„μ²˜λŸΌ λΉ„μŠ·ν•˜κ²Œ μ—…λ‘œλ“œν•˜μ—¬ 접근이 κ°€λŠ₯ν•΄μ§‘λ‹ˆλ‹€.

 

λ§ˆμ§€λ§‰μœΌλ‘œ Kali에 λ‚΄μž₯λ˜μ–΄ μžˆλŠ” "cadaver"μ΄λΌλŠ” 도ꡬλ₯Ό ν™œμš©ν•˜μ—¬ μ›ν•˜λŠ” νŒŒμΌμ„ μ—…λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€. cadaver νˆ΄μ€ WebDAVλ₯Ό λ‹€λ£° 수 μžˆλŠ” λ¦¬λˆ…μŠ€μš© λ„κ΅¬λ‘œ μ›κ²©μœΌλ‘œ λ‹€μ–‘ν•œ λ©”μ†Œλ“œλ₯Ό μ§€μ›ν•˜λ©° κ°„λ‹¨ν•œ CLI ν˜•μ‹μž…λ‹ˆλ‹€.

 

μœ„μ— 방식과 λ§ˆμ°¬κ°€μ§€λ‘œ PUT λ©”μ†Œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ WebShell을 μ—…λ‘œλ“œν•˜μ˜€μŠ΅λ‹ˆλ‹€. νŽ˜μ΄μ§€λ‘œ λŒμ•„κ°€ ν™•μΈν•΄λ³΄κ² μŠ΅λ‹ˆλ‹€.

 

WebShell.phpκ°€ Webdav 디렉토리에 μ—…λ‘œλ“œλ˜κ³  μ‹€ν–‰κΉŒμ§€ ν•  수 있게 λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ—¬κΈ°μ„œ μΆ”κ°€μ μœΌλ‘œ κ³΅κ²©μžλŠ” μžμ‹ μ˜ 기둝을 μ§€μš°κ³  νŽ˜μ΄μ§€λ₯Ό λ³€μ‘°ν•˜κ±°λ‚˜ μ†ŒμŠ€λ₯Ό λ³€μ‘°ν•¨μœΌλ‘œμ¨ λΆˆνŠΉμ • λ‹€μˆ˜κ°€ 큰 ν”Όν•΄λ₯Ό μ΄ˆλž˜ν•  수 있게 λ©λ‹ˆλ‹€.

 

Metasploit 을 ν™œμš©ν•œ WebDAV 곡격
 msfconsole
 msf5 > use auxiliary/scanner/http/webdav_scanner  --> WebDAV ν™œμ„±ν™” μ—¬λΆ€ μŠ€μΊ” 
 msf5 auxiliary(scanner/http/webdav_scanner) > set RHOSTS 192.168.0.131
 RHOSTS => 192.168.0.131
 msf5 auxiliary(scanner/http/webdav_scanner) > set THREADS 20
 THREADS => 20

 msfconsole
 msf5 > use auxiliary/scanner/http/webdav_website_content  --> WebDAV 컨텐츠 μ—΄κ±°
 msf5 auxiliary(scanner/http/webdav_website_content) > set RHOSTS 192.168.0.131
 RHOSTS => 192.168.0.131
 msf5 auxiliary(scanner/http/webdav_website_content) > set THREADS 20
 THREADS => 20
 msf5 auxiliary(scanner/http/webdav_website_content) > run
 msf5 auxiliary(scanner/http/webdav_scanner) > run
λŒ€μ‘ λ°©μ•ˆ
 < insecure SourceCode >
 ExtendedStatus On
 <Location /server-status>
 SetHandler server-status
 Order deny,allow
 Allow from all
 </Location>

 # Allows WebDAV, not secure!!!
 Alias /webdav /var/www/bWAPP/documents
 <Location /webdav>
 DAV On   --> Webdav ν™œμ„±ν™”λ˜μ–΄ 있음
 </Location>
 
 < Secure SourceCode >
 Alias /webdav /webdav
 <Location /webdav>
 Options Indexes
 DAV On  --> Webdav μ„œλΉ„μŠ€λŠ” ν™œμ„±ν™” λ˜μ–΄μžˆμ§€λ§Œ μ‹œμŠ€ν…œ μ‚¬μš©μžμ— ν•œν•˜μ—¬ μ ‘κ·Όμ œμ–΄ μˆ˜ν–‰μ€‘
 AuthType Basic
 AuthName "webdav"
 AuthUserFile /etc/apache2/webdav.password
 Require valid-user
 </Location>
 <!--IIS 의 WebDAV μ„€μ •-->
 *IIS κ΅¬μ„±μ‹œ WebDAVλŠ” 기본적으둜 μ„€μΉ˜λ¨(IIS 6.0 버전뢀터 기본적으둜 λΉ„ν™œμ„±ν™”)
 (1)WIN 2003 -> 2003 R2 버전은 μ—…λ°μ΄νŠΈ μ€‘μ§€λœ 버전
 μ‹œμž‘ -> μ‹€ν–‰ -> INETMGR -> μ›Ή μ‚¬μ΄νŠΈ -> μ›Ήμ„œλΉ„μŠ€ ν™•μž₯으둜 λ“€μ–΄κ°€μ„œ "WebDAV κΈˆμ§€"
 
 (2)WIN 2008,2012
 IISκ΄€λ¦¬μž -> μ„œλ²„ 선택 -> IIS -> ISAPI 및 CGI μ œν•œ -> WebDAV ν•­λͺ© 선택 -> [μž‘μ—…]μ—μ„œ μ œκ±°ν•˜κ±°λ‚˜
 ,νŽΈμ§‘ -> " ν™•μž₯ 경둜 μ‹€ν–‰ ν—ˆμš©(A) " λΆ€λΆ„ μ²΄ν¬ν•΄μ œ
κ³΅μœ ν•˜κΈ° 링크
Comment