Skip to content

Instantly share code, notes, and snippets.

@jamescmartinez
Last active August 13, 2023 20:23
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jamescmartinez/6913761 to your computer and use it in GitHub Desktop.
Save jamescmartinez/6913761 to your computer and use it in GitHub Desktop.
Snapchat Image Decrypt - This Ruby script decrypts the blob received from the `bq/blob` endpoint. Many thanks to @kivikakk, @adamcaudill, @tlack, and @NeilHanlon for inspiration, code, guides, and of course, the encryption key.
#!/usr/bin/env ruby
require 'openssl'
data = File.open('blob', 'r:ASCII-8BIT').read
c = OpenSSL::Cipher.new('AES-128-ECB')
c.decrypt
c.key = 'M02cnQ51Ji97vwT4'
o = ''.force_encoding('ASCII-8BIT')
data.bytes.each_slice(16) { |s| o += c.update(s.map(&:chr).join) }
o += c.final
File.open('blob.jpg', 'w') { |f| f.write(o) }
@daskog
Copy link

daskog commented Nov 25, 2014

Any update for the latest version of Snapchat? I see there is a update on the python version that takes care of the new encryption implementation introduced in later version of Snapchat, md5, etc.

@asad-awadia
Copy link

Updates? Did anyone solve the error?
`final': wrong final block length (OpenSSL::Cipher::CipherError)

@jvkassi
Copy link

jvkassi commented Jan 10, 2015

This is no more working

@Amaterasu27
Copy link

M02cnQ51Ji97vwT4 is the old key
Need to find the new one

@sampellino
Copy link

Any update on this?

@Daniellsantamaria
Copy link

snapchat_decrypt.rb Raw
1
2
3
4
5
6
7
8
9
10
11
12

!/usr/bin/env ruby

require 'openssl'

data = File.open('blob', 'r:ASCII-8BIT').read
c = OpenSSL::Cipher.new('AES-128-ECB')
c.decrypt
c.key = 'M02cnQ51Ji97vwT4'
o = ''.force_encoding('ASCII-8BIT')
data.bytes.each_slice(16) { |s| o += c.update(s.map(&:chr).join) }
o += c.final
File.open('blob.jpg', 'w') { |f| f.write(o) }

@Daniellsantamaria
Copy link

Thank you for posting this code. I had a number of snapchat files to decrypt so added A loop
Snapchat = Dir["*.jpg.nomedia"]
Snapchat.each {joysantamaria
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

!/usr/bin/env ruby

require 'openssl'

data = File.open('blob', 'r:ASCII-8BIT').read
c = OpenSSL::Cipher.new('AES-128-ECB')
c.decrypt
c.key = 'M02cnQ51Ji97vwT4'
o = ''.force_encoding('ASCII-8BIT')
data.bytes.each_slice(16) { |s| o += c.update(s.map(&:chr).join) }
o += c.final
File.open('blob.jpg', 'w') { |f| f.write(o) }

@socalchs
Copy link

socalchs commented Jun 4, 2015

Can anyone walk me through this? From plugging in my phone into the computer(im guessing thats what youre supposed to (thats how lost I am)) to viewing the files. I'll give you a couple bucks through paypal if someone can do it and it works. Thanks!

@jordan64000
Copy link

key : M02cnQ51Ji97vwT4 is dead :'(

@grx11
Copy link

grx11 commented Aug 5, 2015

well, i would like that someone in this damn world teach this on video or something i just lost at least 28 photos of my story that couldn't be publicated still don't know why D: i'm so frustated right now... ): i tried everything D:

@betrisey
Copy link

betrisey commented Sep 6, 2015

The blob files are no longer encrypted, you just have to add the extension .jpg

@luanagelmi
Copy link

Please help me
I do not understand much about these matters
What should I do with this code?
@jamescmartinez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment