Resolução do Walkthrough Blue da TryHackMe.
Walkthrough | ||
Resumo | ||
| ||
Diferente de um CTF, esse desafio trata-se na verdade de um Walkthrough, um passo a passo de como encontrar e explorar uma vulnerabilidade conhecida como o Eternal Blue. Eu particularmente não conhecia essa vulnerabilidade, então pude aprender bastante com esse passo a passo, visto que também pesquisei sobre o assunto para aprofundar ainda mais o conhecimento. | ||
O EternalBlue é uma vulnerabilidade que atinge máquinas com o sistema operacional Windows onde o mesmo possui versões desatualizadas do serviço de compartilhamento de arquivos (SMB v1). O CVE dessa vulnerabilidade é CVE-2017-0144 | ||
Em uma pesquisa rápida no Shodan, um site muito utilizado para reconhecimento e analise de possíveis alvos, procurei por máquinas que ainda utilizassem Windows 2008 no protocolo SMB v.1, eis o resultado. Obviamente, essas máquinas podem até estar com o patch de correção aplicados, ainda assim, no meu ponto de vista nem deveriam mais estar utilizando Windows Server 2008. | ||
Tentei buscar por vulnerabilidade, mas o shodan não permite esse tipo de pesquisa para quem não é “pagante” | ||
Questões | ||
Scan the machine. (If you are unsure how to tackle this, I recommend checking out the Nmap room) | ||
Nenhuma resposta é necessária | ||
How many ports are open with a port number under 1000? | ||
3 | ||
| ||
What is this machine vulnerable to? (Answer in the form of: ms??-???, ex: ms08-067) | ||
ms17-010 | ||
| ||
Start Metasploit | ||
Nenhuma resposta é necessária | ||
Find the exploitation code we will run against the machine. What is the full path of the code? (Ex: exploit/……..) | ||
exploit/windows/smb/ms17_010_eternalblue | ||
Para descobrir o caminho correto, apenas fiz uma pesquisa no Metasploit | ||
Show options and set the one required value. What is the name of this value? (All caps for submission) | ||
RHOSTS | ||
Antes de verificar as opções é necessário utilizar o comando ‘use + caminho’ para definitivamente utilizar o exploit. Posteriormente, o comando ‘show options’ mostrará as opções que devem ou podem ser preenchidas. Nesse caso, apenas o RHOSTS era obrigatório e não tinha nenhum valor atribuído. | ||
O RHOSTS nada mais é do que um parametro que deverá receber o valor (IP) da maquina alvo | ||
With that done, run the exploit! | ||
Nenhuma resposta é necessária, apenas executar o comando. Como a máquina é vulnerável, aparentemente um Windows 7, ao final da execução é retornado um shell | ||
Confirm that the exploit has run correctly. You may have to press enter for the DOS shell to appear. Background this shell (CTRL + Z). If this failed, you may have to reboot the target VM. Try running it again before a reboot of the target. | ||
Esse passo ele pede para digitar CTRL+Z apenas para colocar o shell obtido em segundo plano. | ||
If you haven’t already, background the previously gained shell (CTRL + Z). Research online how to convert a shell to meterpreter shell in metasploit. What is the name of the post module we will use? (Exact path, similar to the exploit we previously selected) | ||
Nenhuma resposta é necessária, apenas procurei pelo módulo solicitado. Como o shell entregue é um pouco limitado, os próximos passos serão para alterar o shell. | ||
Select this (use MODULE_PATH). Show options, what option are we required to change? | ||
SESSION | ||
O parâmetro obrigatório nesse módulo é o SESSION pois esse precisa saber em qual sessão já aberta o mesmo será executado. | ||
Set the required option, you may need to list all of the sessions to find your target here. | ||
Nenhuma resposta é necessária, apenas listar as sessões já abertas, que no caso seria a conexão aberta pelo exploit do Eternalblue na máquina vulnerável. | ||
Run! If this doesn’t work, try completing the exploit from the previous task once more. | ||
Nenhuma resposta é necessária, porém antes de executar o comando é necessário definir o parâmetro SESSION, ou seja, em qual sessão aberta o módulo vai executar. | ||
Após executar | ||
Once the meterpreter shell conversion completes, select that session for use. | ||
Nenhuma resposta é necessária, apenas acessar o shell | ||
Verify that we have escalated to NT AUTHORITY\SYSTEM. Run getsystem to confirm this. Feel free to open a dos shell via the command ‘shell’ and run ‘whoami’. This should return that we are indeed system. Background this shell afterwards and select our meterpreter session for usage again. | ||
Nenhuma resposta é necessária, apenas verificar o usuário que está executando os comandos | ||
List all of the processes running via the ‘ps’ command. Just because we are system doesn’t mean our process is. Find a process towards the bottom of this list that is running at NT AUTHORITY\SYSTEM and write down the process id (far left column) | ||
Nenhuma resposta é necessária, porém, para listar os processos é só rodar o comando ‘ps’ | ||
Migrate to this process using the ‘migrate PROCESS_ID’ command where the process id is the one you just wrote down in the previous step. This may take several attempts, migrating processes is not very stable. If this fails, you may need to re-run the conversion process or reboot the machine and start once again. If this happens, try a different process next time. | ||
Nenhuma resposta é necessária, apenas migrar de um processo para outro | ||
Within our elevated meterpreter shell, run the command ‘hashdump’. This will dump all of the passwords on the machine as long as we have the correct privileges to do so. What is the name of the non-default user? | ||
Copy this password hash to a file and research how to crack it. What is the cracked password? | ||
alqfna22 | ||
Eu tentei decodificar colocando o resultado do hashdump em um arquivo para que a ferramenta JohnTheRipper pudesse, através de uma wordlist, encontrar a senha, porém o resultado não foi o esperado. Em pesquisas, encontrei o site Crackstation. Em tentativas, descobri também que é necessário apenas parte do hash para decodificação | ||
Flag1? This flag can be found at the system root. | ||
flag{access_the_machine} | ||
Como o sistema operacional é Windows, osystem rootseria o C:, assim como para Linux seria /. Naveguei até o diretório e encontrei o arquivo e posteriormente a flag | ||
Flag2? This flag can be found at the location where passwords are stored within Windows | ||
flag{sam_database_elevated_access} | ||
Em pesquisa rápida, descobri que o local onde as senhas são salvas é em C:\Windows\System32\config. Sendo assim, naveguei até ele e encontrei a flag | ||
flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved. | ||
Como a dica não ficou muito clara pra mim, decidi por procurar o arquivo. Acredito que qualquer um dos caminhos encontrados acarretaria na mesma flag | ||
Naveguei até C:\Users\Jon\Documentse encontrei a flag | ||
Links | ||
https://tryhackme.com/room/bluehttps://infosecwriteups.com/metasploit-upgrade-normal-shell-to-meterpreter-shell-2f09be895646 | ||