File tree 1 file changed +8
-7
lines changed
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 129
129
yeAAo1E8BOeAYfBlm4NG9Q==
130
130
}
131
131
132
- def aes_decrypt ( key , payload )
132
+ def aes_decrypt ( mode , key , payload )
133
133
iv = payload [ 0 , 16 ]
134
134
data = payload [ 16 ..-1 ]
135
- aes = OpenSSL ::Cipher . new ( ' aes-128-cbc' )
135
+ aes = OpenSSL ::Cipher . new ( " aes-128-#{ mode } " )
136
136
aes . decrypt
137
+ aes . iv_len = 16 if mode == :gcm
137
138
aes . iv = iv
138
139
aes . key = key . unpack1 ( 'm0' )
139
- aes . update ( payload ) + ( aes . final rescue '' )
140
+ aes . update ( data ) + ( aes . final rescue '' )
140
141
end
141
142
142
143
mark_head = "\xAC \xED \x00 \x05 " . b
143
144
found = false
144
145
Keys . each do |key |
145
- begin
146
- plaintext = aes_decrypt ( key , cipher )
146
+ [ :cbc , :gcm ] . each do | mode |
147
+ plaintext = aes_decrypt ( mode , key , cipher )
147
148
if ( index = plaintext . index ( mark_head ) )
148
149
plaintext = plaintext [ index ..-1 ]
149
- STDERR . puts "key : #{ key } "
150
+ STDERR . puts "Mode: #{ mode . upcase } , Key : #{ key } "
150
151
puts plaintext
151
- found = true
152
+ found = true
152
153
break
153
154
end
154
155
rescue => e
You can’t perform that action at this time.
0 commit comments