Skip to content

Instantly share code, notes, and snippets.

@C0deH4cker
Last active January 1, 2016 07:09
Show Gist options
  • Save C0deH4cker/8109939 to your computer and use it in GitHub Desktop.
Save C0deH4cker/8109939 to your computer and use it in GitHub Desktop.
Run this on a Mac with an iPhone plugged in and then view a video snap. It will be saved to the current directory. To stop, press Control-C. Requires iFuse. Works without a jailbreak. Clearly not affiliated with Snapchat in any way.
#!/usr/bin/env python
import sys, os
import subprocess
from shutil import copyfile
def main():
mnt = os.path.expanduser("~/mnt")
snap = mnt + "/snapchat"
tmp = snap + "/tmp"
# Create mount path if necessary
if not os.path.exists(snap):
os.makedirs(snap)
# Mount Snapchat's sandbox container
ret = subprocess.call(["ifuse", "--container", "com.toyopagroup.picaboo", snap])
if ret != 0:
print("Error mounting Snapchat application directory!")
return ret
# Wait for mount to succeed
while not os.path.exists(tmp):
pass
# Keep scanning Snapchat's tmp dir until we find a .mov file
try:
while 1:
items = os.listdir(tmp)
for item in items:
if item.endswith(".mov") and item not in os.listdir("."):
# Found a .mov file, so copy it to the current directory
print("Saving %s to %s." % (item, os.getcwd() + "/" + item))
copyfile(tmp + "/" + item, item)
except KeyboardInterrupt, e:
pass
finally:
# Clean up our mess
ret = subprocess.call(["umount", snap])
if ret != 0:
print("Error unmounting Snapchat!")
os.rmdir(snap)
try:
os.rmdir(mnt)
except OSError, e:
pass
print("")
if __name__ == "__main__":
ret = main()
if ret != 0:
sys.exit(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment