From 798f3a61dc8eac3cc493a6d37e9eef638caf2f90 Mon Sep 17 00:00:00 2001 From: Datalux Date: Fri, 28 Aug 2020 11:38:44 +0200 Subject: [PATCH 1/4] fix: access to profile if you following target --- src/Osintgram.py | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Osintgram.py b/src/Osintgram.py index bc8a17ca..598809f6 100644 --- a/src/Osintgram.py +++ b/src/Osintgram.py @@ -21,6 +21,7 @@ class Osintgram: user_id = None target_id = None is_private = True + following = False target = "" writeFile = False jsonDump = False @@ -31,6 +32,7 @@ def __init__(self, target, is_file, is_json): print("\nAttempt to login...") self.login(u, p) self.setTarget(target) + self.following = self.check_following() self.writeFile = is_file self.jsonDump = is_json @@ -106,8 +108,7 @@ def change_target(self): return def get_addrs(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target localizations...\n") @@ -173,8 +174,7 @@ def get_addrs(self): pc.printout("Sorry! No results found :-(\n", pc.RED) def get_captions(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target captions...\n") @@ -232,8 +232,7 @@ def get_captions(self): return def get_total_comments(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target total comments...\n") @@ -266,8 +265,7 @@ def get_total_comments(self): pc.printout(" comments in " + str(posts) + " posts\n") def get_followers(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target followers...\n") @@ -319,8 +317,7 @@ def get_followers(self): print(t) def get_followings(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target followings...\n") @@ -372,8 +369,7 @@ def get_followings(self): print(t) def get_hashtags(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target hashtags...\n") @@ -481,8 +477,7 @@ def get_user_info(self): sys.exit(2) def get_total_likes(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target total likes...\n") @@ -515,8 +510,7 @@ def get_total_likes(self): pc.printout(" likes in " + str(posts) + " posts\n") def get_media_type(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target captions...\n") @@ -564,8 +558,7 @@ def get_media_type(self): pc.printout("Sorry! No results found :-(\n", pc.RED) def get_people_who_commented(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for users who commented...\n") @@ -623,8 +616,7 @@ def get_people_who_commented(self): pc.printout("Sorry! No results found :-(\n", pc.RED) def get_photo_description(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return content = urllib.request.urlopen("https://www.instagram.com/" + str(self.target) + "/?__a=1") @@ -673,8 +665,7 @@ def get_photo_description(self): pc.printout("Sorry! No results found :-(\n", pc.RED) def get_user_photo(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return limit = -1 @@ -764,8 +755,7 @@ def get_user_propic(self): sys.exit(2) def get_user_stories(self): - if self.is_private: - pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + if self.check_private_profile(): return pc.printout("Searching for target stories...\n") @@ -968,3 +958,14 @@ def onlogin_callback(self, api, new_settings_file): with open(new_settings_file, 'w') as outfile: json.dump(cache_settings, outfile, default=self.to_json) #print('SAVED: {0!s}'.format(new_settings_file)) + + def check_following(self): + endpoint = 'users/{user_id!s}/full_detail_info/'.format(**{'user_id': self.target_id}) + return self.api._call_api(endpoint)['user_detail']['user']['friendship_status']['following'] + + def check_private_profile(self): + if self.is_private and not self.following: + pc.printout("Impossible to execute command: user has private profile\n", pc.RED) + return True + return False + From 9b9086a76e8c3259edeb6e144059b87336c426a0 Mon Sep 17 00:00:00 2001 From: Datalux Date: Fri, 28 Aug 2020 11:44:46 +0200 Subject: [PATCH 2/4] fix(addrs): minor bug fix --- src/Osintgram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Osintgram.py b/src/Osintgram.py index 598809f6..405eed9d 100644 --- a/src/Osintgram.py +++ b/src/Osintgram.py @@ -118,7 +118,7 @@ def get_addrs(self): locations = {} for post in data: - if post['location'] is not None: + if 'location' in post and post['location'] is not None: lat = post['location']['lat'] lng = post['location']['lng'] locations[str(lat) + ', ' + str(lng)] = post.get('taken_at') From ae593f233f27b8c4706a342c603c898e55363117 Mon Sep 17 00:00:00 2001 From: Datalux Date: Fri, 28 Aug 2020 11:46:47 +0200 Subject: [PATCH 3/4] chore: added following status in banner --- src/Osintgram.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Osintgram.py b/src/Osintgram.py index 405eed9d..3737fc02 100644 --- a/src/Osintgram.py +++ b/src/Osintgram.py @@ -32,7 +32,6 @@ def __init__(self, target, is_file, is_json): print("\nAttempt to login...") self.login(u, p) self.setTarget(target) - self.following = self.check_following() self.writeFile = is_file self.jsonDump = is_json @@ -41,6 +40,7 @@ def setTarget(self, target): user = self.get_user(target) self.target_id = user['id'] self.is_private = user['is_private'] + self.following = self.check_following() self.__printTargetBanner__() def __getUsername__(self): @@ -99,6 +99,8 @@ def __printTargetBanner__(self): pc.printout(" [" + str(self.target_id) + "] ") if self.is_private: pc.printout("[PRIVATE PROFILE]", pc.RED) + if self.following: + pc.printout(" [YOU FOLLOW]", pc.GREEN) print('\n') def change_target(self): From 339b717c116c0f6106ed05e80ce7282a2ed67bce Mon Sep 17 00:00:00 2001 From: Datalux Date: Fri, 28 Aug 2020 11:50:04 +0200 Subject: [PATCH 4/4] chore: edited banner --- src/Osintgram.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Osintgram.py b/src/Osintgram.py index 3737fc02..4b706d6d 100644 --- a/src/Osintgram.py +++ b/src/Osintgram.py @@ -98,9 +98,13 @@ def __printTargetBanner__(self): pc.printout(str(self.target), pc.CYAN) pc.printout(" [" + str(self.target_id) + "] ") if self.is_private: - pc.printout("[PRIVATE PROFILE]", pc.RED) + pc.printout("[PRIVATE PROFILE]", pc.BLUE) if self.following: - pc.printout(" [YOU FOLLOW]", pc.GREEN) + pc.printout(" [FOLLOWING]", pc.GREEN) + else: + pc.printout(" [NOT FOLLOWING]", pc.RED) + + print('\n') def change_target(self):