Last active
July 3, 2019 06:59
-
-
Save smaglio81/de64c322238cb6828bd17a1893d091fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $crypto = @" | |
# g - 2 5 R e t o p c 7 - | |
# h v 1 Q n e l b e d E p | |
# "@ | |
$crypto = @" | |
P k T r 2 s z 2 * c F - | |
r a z 7 G u D 4 w 6 U # | |
g c t K 3 E @ B t 1 a Y | |
Q P i c % 7 0 5 Z v A e | |
W 6 j e P R f p m I ) H | |
y ^ L o o w C n b J d O | |
S i 9 M b e r # ) i e U | |
* f 2 Z 6 M S h 7 V u D | |
5 a ( h s v 8 e l 1 o W | |
Z O 7 l p K y J l D z $ | |
- j I @ t T 2 3 R a i k | |
q = F & w B 6 c % H l y | |
"@ | |
# using language files to automate testing the results | |
# https://sites.google.com/site/cryptocrackprogram/download/language-files | |
$dictFolder = "C:\Program Files\WindowsPowerShell\Modules\IronScriptor-20190702-Cryptogram\EnglishDict" | |
$dictFiles = dir -Path $dictFolder -Recurse *.* -File | |
$allwords = $dictFiles |% { Get-Content -Path $_.FullName } | |
function Test-DictionaryWords ([string] $Possible) { | |
$Possible = $Possible -replace "-", "" | |
$Possible = $Possible.ToUpper() | |
foreach($word in $allwords) { | |
if($Possible.StartsWith($word)) { | |
if($Possible.Length -eq $word.Length) { | |
return $true | |
} | |
$newPossible = $Possible.Substring($word.Length) | |
$results = Test-DictionaryWords -Possible $newPossible | |
if($results -eq $true) { | |
return $true | |
} | |
} | |
} | |
return $false | |
} | |
$crypto = $crypto -replace " ", "" | |
$crypto = $crypto -replace "`r", "" | |
$crypto = $crypto -replace "`n", "" | |
$cryptolen = $crypto.Length | |
$results = @() | |
for($x = 1; $x -lt 20; $x++) { | |
$props = [PSCustomObject] @{} | |
for($y = 1; $y -lt 20; $y++) { | |
$plaintext = "" | |
for($j = 0; ((($x + $y) * $j) + $x) -le $cryptolen; $j++) { | |
$cx = (($x + $y) * $j) + $x | |
$plaintext += $crypto[$cx - 1] | |
$cy = (($x + $y) * $j) + $x + $y | |
if($cy -le $cryptolen) { | |
$plaintext += $crypto[$cy - 1] | |
} | |
} | |
$props = [PSCustomObject] @{ | |
X = $x | |
Y = $y | |
PlainText = $plaintext | |
PlainTextL = $plaintext.ToLower() | |
DictionaryMatch = Test-DictionaryWords -Possible $plaintext | |
} | |
$results += @($props) | |
if($props.DictionaryMatch) { | |
$props | ft X, Y, PlainText -AutoSize | |
break | |
} | |
} | |
if($props.DictionaryMatch) { | |
break | |
} | |
} | |
#$results | ft X, Y, PlainTextL -AutoSize | |
#$results |? { $_.plaintext -match "-" } | ft X, Y, PlainText -AutoSize | |
#$results |? { $_.plaintextl -notmatch "[^a-zA-z\-]" } | ft X, Y, PlainTextL -AutoSize | |
#$results |? { $_.X -eq 1 -and $_.Y -eq 12 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment