Skip to content

Instantly share code, notes, and snippets.

@nmalcolm
Created November 29, 2014 14:02
Show Gist options
  • Save nmalcolm/8568acca149f465cdf5a to your computer and use it in GitHub Desktop.
Save nmalcolm/8568acca149f465cdf5a to your computer and use it in GitHub Desktop.
Instagram Pushpin
diff --git a/core/base.py b/core/base.py
index 4d957f8..67e838c 100644
--- a/core/base.py
+++ b/core/base.py
@@ -120,7 +120,7 @@ class Recon(framework.Framework):
# create the database and table
self.query_keys('CREATE TABLE keys (name TEXT PRIMARY KEY, value TEXT)')
# populate key names
- for name in ['bing_api', 'builtwith_api', 'facebook_api', 'facebook_password', 'facebook_secret', 'facebook_username', 'flickr_api', 'google_api', 'google_cse', 'ipinfodb_api', 'jigsaw_api', 'jigsaw_password', 'jigsaw_username', 'linkedin_api', 'linkedin_secret', 'linkedin_token', 'pwnedlist_api', 'pwnedlist_iv', 'pwnedlist_secret', 'rapportive_token', 'shodan_api', 'sonar_api', 'twitter_api', 'twitter_secret', 'twitter_token', 'virustotal_api']:
+ for name in ['bing_api', 'builtwith_api', 'facebook_api', 'facebook_password', 'facebook_secret', 'facebook_username', 'flickr_api', 'instagram_api', 'google_api', 'google_cse', 'ipinfodb_api', 'jigsaw_api', 'jigsaw_password', 'jigsaw_username', 'linkedin_api', 'linkedin_secret', 'linkedin_token', 'pwnedlist_api', 'pwnedlist_iv', 'pwnedlist_secret', 'rapportive_token', 'shodan_api', 'sonar_api', 'twitter_api', 'twitter_secret', 'twitter_token', 'virustotal_api']:
self.query_keys('INSERT INTO keys (name) VALUES (?)', (name,))
# migrate keys
key_path = '%s/keys.dat' % (self.home)
import module
# unique to module
from datetime import datetime
import json
class Module(module.Module):
def __init__(self, params):
module.Module.__init__(self, params, query='SELECT DISTINCT latitude || \',\' || longitude FROM locations WHERE latitude IS NOT NULL AND longitude IS NOT NULL')
self.register_option('radius', 1000, True, 'radius in kilometers')
self.info = {
'Name': 'Instagram Geolocation Search',
'Author': 'Nathan Malcolm (@SintheticLabs)',
'Description': 'Searches Instagram for media in the specified proximity to a location.',
'Comments': [
'Radius must be greater than zero and no more than 5 kilometers (5000 meters).'
]
}
def module_run(self, points):
api_key = self.get_key('instagram_api')
rad = self.options['radius']
url = 'https://api.instagram.com/v1/media/search'
count = 0
new = 0
for point in points:
self.heading(point, level=0)
lat = point.split(',')[0]
lon = point.split(',')[1]
payload = {'lat': lat, 'lng': lon, 'distance': rad, 'access_token': api_key}
processed = 0
while True:
resp = self.request(url, payload=payload)
jsonobj = json.loads(resp.text)
# check for, and exit on, an erroneous request
if jsonobj['meta']['code'] != 200:
self.error(jsonobj['meta']['error_message'])
break
if not count: self.output('Collecting data for an unknown number of photos...')
for item in jsonobj['data']:
latitude = item['location']['latitude']
longitude = item['location']['longitude']
if not all((latitude, longitude)): continue
source = 'Instagram'
screen_name = item['user']['username']
profile_name = item['user']['full_name']
profile_url = 'http://instagram.com/%s' % screen_name
media_url = item['images']['standard_resolution']['url']
thumb_url = item['images']['thumbnail']['url']
try: message = item['caption']['text']
except: message = ''
try: time = datetime.fromtimestamp(float(item['created_time']))
except ValueError: time = datetime(1970, 1, 1)
new += self.add_pushpins(source, screen_name, profile_name, profile_url, media_url, thumb_url, message, latitude, longitude, time)
count += 1
processed += len(jsonobj['data'])
self.verbose('%s photos processed.' % (processed))
try: print jsonobj['data'][19]['created_time']
except: break
payload['max_timestamp'] = jsonobj['data'][19]['created_time']
self.summarize(new, count)
diff --git a/modules/reporting/pushpin.py b/modules/reporting/pushpin.py
index 63e7900..e0b6fc4 100644
--- a/modules/reporting/pushpin.py
+++ b/modules/reporting/pushpin.py
@@ -30,6 +30,7 @@ class Module(module.Module):
'shodan': 'http://maps.google.com/mapfiles/ms/icons/yellow-dot.png',
'twitter': 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
'youtube': 'http://maps.google.com/mapfiles/ms/icons/red-dot.png',
+ 'instagram': 'http://maps.google.com/mapfiles/ms/icons/pink-dot.png',
}
media_content = ''
map_content = ''
diff --git a/data/template_media.html b/data/template_media.html
index 7ed512e..d46a20e 100644
--- a/data/template_media.html
+++ b/data/template_media.html
@@ -132,6 +132,14 @@ div, img {
-moz-box-shadow: 0px 0px 10px purple;
box-shadow: 0px 0px 10px purple;
}
+.instagram {
+ border: 2px solid blue;
+ color: #3F729B;
+ background-color: white;/*lightblue;*/
+ -webkit-box-shadow: 0px 0px 10px green;
+ -moz-box-shadow: 0px 0px 10px green;
+ box-shadow: 0px 0px 10px green;
+}
</style>
</head>
<body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment