
The annual PowerShell Summit is fast approaching and at this late hour a challenge has been delivered from the Dark Faction to those who feel they are worthy of the title “Iron Scripter”. They doubt your skill and resolve. The Dark Faction scripts in the shadows and has always felt they are the true champions. The leaders of the Dark Faction have sent the Chairman an encoded message.
Here is an excerpt:
Rtsfi%nx%ymj%sj}y%ljsjwfynts%uqfyktwr%ktw%firnsnxywfyn{j%fzytrfynts3%%Rtsfi%xtq{jx%ywfinyntsfq%rfsfljrjsy%uwtgqj
rx%g~%qj{jwflnsl%ymj%3Sjy%Uqfyktwr3%%Kwtr%tzw%uwtyty~uj%-ymtzlm%qnrnyji.1%|j%hfs%uwtojhy%xnlsnknhfsy%gjsjknyx%yt
They are challenging the other factions and those who think they can be Iron Scripters, to unravel their message. The Dark Faction has decided to have mercy and are using a very simple Caesar Cipher. This is nothing more than a simple character substitution encoding. The original characters have been adjusted by some constant value up or down. Your challenge is to decode their message with PowerShell.
You will first need to retrieve the text message from http://bit.ly/DarkFactionMessage. You will also need to take blank lines into account in your decoding.
The Dark Faction doesn’t think you are up to the challenge. Can you prove them wrong?
I’m a bit late with taking on this task, but the solution was quite easy. Assuming that % was actually the substitution for the [space] character i found out that the substitution was -5 in the ascii table. I simply spent a few minutes to write a loop that substituted the characters and added those to a new string… Handling the blank lines was a bit trickier at first and took some time to figure out.
Here’s my Quick solution:
$Text = (get-Content -Path C:\temp\cypher.txt)
[String]$Solution = “”
ForEach ($line in $Text)
{
$OutLine = “”
If ($line -ne “”)
{
$i=0
Do
{
$Char = ([char]([byte]([char]$line[$i])-5))
$OutLine += $Char
$i++
}
While ($i -ne $line.Length)
}
Else {$OutLine = “`r`n`r`n”}
$Solution += $OutLine
}
Out-File -FilePath “C:\Temp\solution.txt” -InputObject $Solution
Happy scripting!
/Peter