Skip to content

Commit 016fe27

Browse files
committed
add gcm mode
1 parent 34a81d0 commit 016fe27

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

crypto/shiro_rememberMe_decrypt.rb

+8-7
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,27 @@
129129
yeAAo1E8BOeAYfBlm4NG9Q==
130130
}
131131

132-
def aes_decrypt(key, payload)
132+
def aes_decrypt(mode, key, payload)
133133
iv = payload[0,16]
134134
data = payload[16..-1]
135-
aes = OpenSSL::Cipher.new('aes-128-cbc')
135+
aes = OpenSSL::Cipher.new("aes-128-#{mode}")
136136
aes.decrypt
137+
aes.iv_len = 16 if mode == :gcm
137138
aes.iv = iv
138139
aes.key = key.unpack1('m0')
139-
aes.update(payload) + (aes.final rescue '')
140+
aes.update(data) + (aes.final rescue '')
140141
end
141142

142143
mark_head = "\xAC\xED\x00\x05".b
143144
found = false
144145
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)
147148
if (index = plaintext.index(mark_head))
148149
plaintext = plaintext[index..-1]
149-
STDERR.puts "key: #{key}"
150+
STDERR.puts "Mode: #{mode.upcase}, Key: #{key}"
150151
puts plaintext
151-
found = true
152+
found = true
152153
break
153154
end
154155
rescue => e

0 commit comments

Comments
 (0)