save&decrypt snapchat images: howto

Background

Snapchat encrypts the photos received to your device based on the version of the application you are running. From version 5.0.1 (or something) onwards, it uses an ever changing key (it's 'predictable' but personally I can't be arsed with this shit)

Previous versions encrypt the photos with a static key, which is what this little guide makes use of.

The setup

Get an old version of snapchat; I currently use 4.1.07. It has filters and stories and all the stuff I need for day-to-day use. I won't link the .apk here for obvious reasons... if you can't find it then give me a shout.

Your phone needs to be rooted (or jailbroken if you are like that)

The code

This is all you are bothered about, let's be honest

wrapper.sh

#!/bin/bash

for i in *.nomedia
do
enc_file=$i
dec_file=$(echo $i | sed 's/.nomedia//')
./decrypt.rb $enc_file $dec_file
done

decrypt.rb

#!/usr/bin/ruby

require 'openssl'

enc_file = ARGV[0]
dec_file = ARGV[1]

data = File.open(enc_file, '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(dec_file, 'w') { |f| f.write(o) }

The process

Put the code in two files on your machine and chmod +x them

Load up snapchat to download your unviewed snaps to /data/data/com.snapchat.android/cache/received_image_snaps

Use your favourite file manager to copy these elsewhere

Move the .jpg.nomedia file to your PC (same directory as the script) and run the wrapper.sh

Hey presto!

problems?

-- oli