Skip to content

Hacky Holidays CTF 2021: Power Snacks

TL;DR

  • The challenge consists of four independent PowerShell data-processing tasks.
  • Each task requires generating output in an exact format and piping it into a provided check function.
  • Tasks cover conditional loops, constrained string matching, CSV aggregation, and ordered filtering.
  • Correct PowerShell object handling and sorting behavior are critical for passing validation.

Video Walkthrough

Hacky Holidays Space Race CTF 2021 Power Snacks forensics video walkthrough showing PowerShell data processing and validation tasks

Challenge Description

Are you the very best PowerShell user?

Solution

# 1
$answer = For ($i=1; $i -le 1337; $i++) {
    if ($i % 42 -eq 0){
        Write-Output("Life, the universe, and everything")
    }else{
        Write-Output($i)
    }
}
$answer | check


# 2
$answer = ForEach($word In $(Get-Content ./dictionary | Sort-Object  {$_.Length}, {$_.ToString()})) {
     if($word.Length -gt 1){
        $scrabble_chars = "iydhlao"
        $match = 1
        ForEach($char in $word.ToCharArray()){
            if(!($scrabble_chars.Contains($char))){
                $match = 0
            }
            $scrabble_chars = $scrabble_chars -replace $char,""
        }
        if ($match){
            Write-Output([string]$word)
        }
    }
}
$answer | check


# 3
$answer = Import-Csv -Delimiter "`t" ./passwords.tsv | Group-Object category | Sort-Object @{Expression = "Count"; Descending = $True} | Select-Object Count,Name
$answer | check


# 4
$answer  = Import-Csv -Delimiter "`t" ./passwords.tsv | Sort-Object {$_.Password.Length}, {$_.Password} | Where-Object category -EQ "names" | Select-Object Password
$answer | check