Anonymously saving instagram stories to personal cloud.

Holy sheit its been a long time since I wrote here. Been busy with some big personal projects and college. FeelsBadMan. :-/

Anyways…. I recently (last night) built an OSINT tool to save instagram stories to dropbox anonymously. Here’s how it works ->

  • Use headless chrome to visit this page -> ‘https://www.anonigviewer.com/profile.php?u=’+userName . Why use a third party website ? Because I am lazy asf and was trying to speedrun this project. moving on….
  • Find x-paths of all the latest stories and extract the media uris using almighty regex.
  • Download the media using requests whilst ignoring all the ssl warnings. (don’t do this in prod)
  • Maintain a local database of the stories you’ve downloaded with timestamps and stuff.
  • Upload all of the media you ripped to dropbox using their awesome api (seriously, they have the best api-docs I’ve read in a while).

Here’s the code ->

from selenium import webdriver
import time
import re
from selenium.webdriver.common.by import By
from selenium import webdriver
import time
import re
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import requests
import dropbox
from tinydb import TinyDB, Query

# Declare yo user
user = 'doom'
storeFolder = "sauce/"

driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://www.anonigviewer.com/profile.php?u='+user)

# Upload to dropbox
uriList = []

def dropUpload(uris):
	dropbox_access_token= "" #Yo acess token goes here
	client = dropbox.Dropbox(dropbox_access_token)
	print("DataStore Connected")
	for uri in uris:
		to_path= "/"+uri
		from_path=uri
		client.files_upload(open(from_path, "rb").read(), to_path)
		print("Upload Komplete")


# Poor man's nosql store omegalul

def isPresent(url):
	db = TinyDB('db.json')
	p = Query()
	present = db.search(p.link==url)
	if(len(present)==0):
		db.insert({'link': url, 'timestamp': time.time()})
		return False
	else:
		return True

# Coutesy Of StackOverFlow lol

def download_file(url,type):
	if(isPresent(url)==False):
		timestr = time.strftime("%Y%m%d-%H%M%S")
		local_filename = storeFolder+timestr+type
		r = requests.get(url,verify=False, stream=True)
		with open(local_filename, 'wb') as f:
			for chunk in r.iter_content(chunk_size=1024): 
				if chunk:
					f.write(chunk)
		uriList.append(local_filename)
		return local_filename

# Ugly code don't look

wait = WebDriverWait(driver, 50)	# 50 Sec of summer
sauceCheck = wait.until(EC.visibility_of_element_located((By.XPATH, '/html/body/div[4]/div[3]/div/div[1]/div[1]/div/div')))
sauces = driver.find_elements_by_class_name('mb-4')
print(len(sauces))
i=1
preSauces = []
for sauce in sauces:
	preSauces.append(driver.find_element_by_xpath('/html/body/div[4]/div[3]/div/div[1]/div['+str(i)+']/div/div').get_attribute("onclick"))
	i=i+1

driver.close()

# Video or an Image ?

for preSauce in preSauces:
	if preSauce.find("GraphVideo")!=-1:
		type_ = ".mp4"
	elif preSauce.find("GraphImage")!=-1:
		type_ = ".jpg"
	link = re.findall(r'(https?://\S+)', preSauce)[0].split('"')[0]
	download_file(link,type_)

dropUpload(uriList)

Couple of things to take care of ->

Dropbox requires to start directory names with “/” . Make sure to you give appropriate write permissions in the app console.

Now just package this script -> add it to a cron-job on a remote server and bam. Speedrun insta stalker any% complete xD.

Btw I am finishing up working on a really cool low-level driver written in go. I’ll post something about it soon. GGs till then.