1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| function enenenenene { param( $plaintextBytes, $keyBytes ) $S = 0..255 $j = 0 for ($i = 0; $i -lt 256; $i++) { $j = ($j + $S[$i] + $keyBytes[$i % $keyBytes.Length]) % 256 $temp = $S[$i] $S[$i] = $S[$j] $S[$j] = $temp }
$i = 0 $j = 0 $ciphertextBytes = @() for ($k = 0; $k -lt $plaintextBytes.Length; $k++) { $i = ($i + 1) % 256 $j = ($j + $S[$i]) % 256 $temp = $S[$i] $S[$i] = $S[$j] $S[$j] = $temp $t = ($S[$i] + $S[$j]) % 256 $ciphertextBytes += ($plaintextBytes[$k] -bxor $S[$t]) }
return $ciphertextBytes } function enc1 { param( $inputbyte ) $key = @(0x70, 0x6f, 0x77, 0x65, 0x72) $encryptedText = @(); for ($k = 0; $k -lt $inputbyte.Length; $k++) { $encryptedText = enenenenene -plaintextBytes $inputbyte -keyBytes $key; $key = enenenenene -plaintextBytes $key -keyBytes $encryptedText; } return $encryptedText + $key; } function dec1 { param( $inputbyte ) $initial_key = @(0x70, 0x6f, 0x77, 0x65, 0x72) $encryptedText = $inputbyte[0..($inputbyte.Length-$initial_key.Length-1)] $key = $inputbyte[($inputbyte.Length-$initial_key.Length)..($inputbyte.Length-1)]
$key = enenenenene -plaintextBytes $key -keyBytes $encryptedText; $plain = enenenenene -plaintextBytes $encryptedText -keyBytes $key; return $plain; } function enc2 { param( $inputbyte ) $key = @(0x70, 0x30, 0x77, 0x65, 0x72) for ($k = 0; $k -lt $inputbyte.Length; $k++) { $inputbyte[$k] = $inputbyte[$k] + $key[$k % $key.Length] } return $inputbyte; }
function dec2 { param( $inputbyte ) $key = @(0x70, 0x30, 0x77, 0x65, 0x72) for ($k = 0; $k -lt $inputbyte.Length; $k++) { $inputbyte[$k] = $inputbyte[$k] - $key[$k % $key.Length] } return $inputbyte; }
function enc3 { param( $inputbyte ) $key = @(0x70, 0x30, 0x77, 0x33, 0x72) for ($k = 0; $k -lt $inputbyte.Length; $k++) { $inputbyte[$k] = $inputbyte[$k] * $key[$k % $key.Length] } return $inputbyte; }
function dec3 { param( $inputbyte ) $key = @(0x70, 0x30, 0x77, 0x33, 0x72) for ($k = 0; $k -lt $inputbyte.Length; $k++) { $inputbyte[$k] = $inputbyte[$k] / $key[$k % $key.Length] } return $inputbyte; }
Write-Host (dec1 -inputbyte (enc1 -inputbyte @(1, 2, 3, 4, 5))) Write-Host (dec2 -inputbyte (enc2 -inputbyte @(1, 2, 3, 4, 5))) Write-Host (dec3 -inputbyte (enc3 -inputbyte @(1, 2, 3, 4, 5)))
$result = @(38304, 8928, 43673, 25957 , 67260, 47152, 16656, 62832 , 19480 , 66690, 40432, 15072 , 63427 , 28558 , 54606, 47712 , 18240 , 68187 , 18256, 63954 , 48384, 14784, 60690 , 21724 , 53238 , 64176 , 9888 , 54859 , 23050 , 58368 , 46032 , 15648 , 64260 , 17899 , 52782 , 51968 , 12336 , 69377 , 27844 , 43206 , 63616)
$flag = dec1 -inputbyte (dec2 -inputbyte (dec2 -inputbyte (dec2 -inputbyte (dec3 -inputbyte (dec2 -inputbyte (dec2 -inputbyte $result))))))
$flag = [System.Text.Encoding]::ASCII.GetString($flag)
Write-Host $flag
|