Skip to content

Commit

Permalink
Merge pull request #111 from Datalux/feat/fwingsnumbers
Browse files Browse the repository at this point in the history
[FEATURE] get phone numbers of users
  • Loading branch information
Datalux authored Mar 29, 2021
2 parents f5211eb + 069df73 commit b607089
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Osintgram offers an interactive shell to perform analysis on Instagram account o
- followings Get users followed by target
- fwersemail Get email of target followers
- fwingsemail Get email of users followed by target
- fwersnumber Get phone number of target followers
- fwingsnumber Get phone number of users followed by target
- hashtags Get hashtags used by target
- info Get target info
- likes Get total likes of target's posts
Expand Down
6 changes: 6 additions & 0 deletions doc/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ Return a list of emails of target followers
### fwingsemail
Return a list of emails of user followed by target

### fwersnumber
Return a list of phone number of target followers

### fwingsnumber
Return a list of phone number of user followed by target

### hashtags
Return a list with all hashtag used by target in his photos

Expand Down
65 changes: 33 additions & 32 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
import signal
import gnureadline

commands = ["quit", "exit", "list", "help", "addrs", "captions", "comments", "followers",
"followings", "fwersemail", "fwingsemail", "hashtags", "info", "likes",
"mediatype", "photodes", "photos", "propic", "stories", "tagged", "target",
"wcommented", "wtagged"]


def printlogo():
pc.printout("________ .__ __ \n", pc.YELLOW)
Expand Down Expand Up @@ -50,6 +45,10 @@ def cmdlist():
print("Get email of target followers")
pc.printout("fwingsemail\t")
print("Get email of users followed by target")
pc.printout("fwersnumber\t")
print("Get phone number of target followers")
pc.printout("fwingsnumber\t")
print("Get phone number of users followed by target")
pc.printout("hashtags\t")
print("Get hashtags used by target")
pc.printout("info\t\t")
Expand Down Expand Up @@ -93,10 +92,6 @@ def _quit():
sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
gnureadline.parse_and_bind("tab: complete")
gnureadline.set_completer(completer)

printlogo()

parser = argparse.ArgumentParser(description='Osintgram is a OSINT tool on Instagram. It offers an interactive shell '
Expand All @@ -112,31 +107,37 @@ def _quit():


commands = {
'list': cmdlist,
'help': cmdlist,
'quit': _quit,
'exit': _quit,
'addrs': api.get_addrs,
'captions': api.get_captions,
'comments': api.get_total_comments,
'followers': api.get_followers,
'followings': api.get_followings,
'fwersemail': api.get_fwersemail,
'fwingsemail': api.get_fwingsemail,
'hashtags': api.get_hashtags,
'info': api.get_user_info,
'likes': api.get_total_likes,
'mediatype': api.get_media_type,
'photodes': api.get_photo_description,
'photos': api.get_user_photo,
'propic': api.get_user_propic,
'stories': api.get_user_stories,
'tagged': api.get_people_tagged_by_user,
'target': api.change_target,
'wcommented': api.get_people_who_commented,
'wtagged': api.get_people_who_tagged
'list': cmdlist,
'help': cmdlist,
'quit': _quit,
'exit': _quit,
'addrs': api.get_addrs,
'captions': api.get_captions,
'comments': api.get_total_comments,
'followers': api.get_followers,
'followings': api.get_followings,
'fwersemail': api.get_fwersemail,
'fwingsemail': api.get_fwingsemail,
'fwersnumber': api.get_fwersnumber,
'fwingsnumber': api.get_fwingsnumber,
'hashtags': api.get_hashtags,
'info': api.get_user_info,
'likes': api.get_total_likes,
'mediatype': api.get_media_type,
'photodes': api.get_photo_description,
'photos': api.get_user_photo,
'propic': api.get_user_propic,
'stories': api.get_user_stories,
'tagged': api.get_people_tagged_by_user,
'target': api.change_target,
'wcommented': api.get_people_who_commented,
'wtagged': api.get_people_who_tagged
}

signal.signal(signal.SIGINT, signal_handler)
gnureadline.parse_and_bind("tab: complete")
gnureadline.set_completer(completer)

while True:
pc.printout("Run a command: ", pc.YELLOW)
cmd = input()
Expand Down
148 changes: 148 additions & 0 deletions src/Osintgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,154 @@ def get_fwingsemail(self):
else:
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_fwingsnumber(self):
if self.check_private_profile():
return

pc.printout("Searching for phone numbers of users followed by target... this can take a few minutes\n")

followings = []

rank_token = AppClient.generate_uuid()
data = self.api.user_following(str(self.target_id), rank_token=rank_token)

for user in data.get('users', []):
u = {
'id': user['pk'],
'username': user['username'],
'full_name': user['full_name']
}
followings.append(u)

next_max_id = data.get('next_max_id')

while next_max_id:
results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)

for user in results.get('users', []):
u = {
'id': user['pk'],
'username': user['username'],
'full_name': user['full_name']
}
followings.append(u)

next_max_id = results.get('next_max_id')

results = []

for follow in followings:
sys.stdout.write("\rCatched %i followings phone numbers" % len(results))
sys.stdout.flush()
user = self.api.user_info(str(follow['id']))
if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
follow['contact_phone_number'] = user['user']['contact_phone_number']
results.append(follow)

print("\n")

if len(results) > 0:
t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
t.align["ID"] = "l"
t.align["Username"] = "l"
t.align["Full Name"] = "l"
t.align["Phone number"] = "l"

json_data = {}

for node in results:
t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])

if self.writeFile:
file_name = "output/" + self.target + "_fwingsnumber.txt"
file = open(file_name, "w")
file.write(str(t))
file.close()

if self.jsonDump:
json_data['followings_phone_numbers'] = results
json_file_name = "output/" + self.target + "_fwingsnumber.json"
with open(json_file_name, 'w') as f:
json.dump(json_data, f)

print(t)
else:
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_fwersnumber(self):
if self.check_private_profile():
return

pc.printout("Searching for phone numbers of users followers... this can take a few minutes\n")

followings = []

rank_token = AppClient.generate_uuid()
data = self.api.user_following(str(self.target_id), rank_token=rank_token)

for user in data.get('users', []):
u = {
'id': user['pk'],
'username': user['username'],
'full_name': user['full_name']
}
followings.append(u)

next_max_id = data.get('next_max_id')

while next_max_id:
results = self.api.user_following(str(self.target_id), rank_token=rank_token, max_id=next_max_id)

for user in results.get('users', []):
u = {
'id': user['pk'],
'username': user['username'],
'full_name': user['full_name']
}
followings.append(u)

next_max_id = results.get('next_max_id')

results = []

for follow in followings:
sys.stdout.write("\rCatched %i followers phone numbers" % len(results))
sys.stdout.flush()
user = self.api.user_info(str(follow['id']))
if 'contact_phone_number' in user['user'] and user['user']['contact_phone_number']:
follow['contact_phone_number'] = user['user']['contact_phone_number']
results.append(follow)

print("\n")

if len(results) > 0:
t = PrettyTable(['ID', 'Username', 'Full Name', 'Phone'])
t.align["ID"] = "l"
t.align["Username"] = "l"
t.align["Full Name"] = "l"
t.align["Phone number"] = "l"

json_data = {}

for node in results:
t.add_row([str(node['id']), node['username'], node['full_name'], node['contact_phone_number']])

if self.writeFile:
file_name = "output/" + self.target + "_fwersnumber.txt"
file = open(file_name, "w")
file.write(str(t))
file.close()

if self.jsonDump:
json_data['followings_phone_numbers'] = results
json_file_name = "output/" + self.target + "_fwerssnumber.json"
with open(json_file_name, 'w') as f:
json.dump(json_data, f)

print(t)
else:
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_comments(self):
if self.check_private_profile():
return
Expand Down

0 comments on commit b607089

Please sign in to comment.