Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
datalux
GitHub Repository: datalux/osintgram
Path: blob/master/main.py
270 views
1
#!/usr/bin/env python3
2
import os
3
import sys
4
import signal
5
import argparse
6
7
from src import artwork, config
8
from src import printcolors as pc
9
from src.hikercli import HikerCLI, hk
10
from src.Osintgram import Osintgram
11
12
is_windows = False
13
14
try:
15
import gnureadline
16
except:
17
is_windows = True
18
import pyreadline
19
20
21
def printlogo():
22
pc.printout(artwork.ascii_art, pc.YELLOW)
23
pc.printout("\nVersion 1.1 - Developed by Giuseppe Criscione", pc.YELLOW)
24
pc.printout(
25
f"\nHikerAPI {hk.__version__} https://hikerapi.com/help/about\n\n", pc.YELLOW
26
)
27
pc.printout("Type 'list' to show all allowed commands\n")
28
pc.printout("Type 'FILE=y' to save results to files like '<target username>_<command>.txt (default is disabled)'\n")
29
pc.printout("Type 'FILE=n' to disable saving to files'\n")
30
pc.printout("Type 'JSON=y' to export results to a JSON files like '<target username>_<command>.json (default is "
31
"disabled)'\n")
32
pc.printout("Type 'JSON=n' to disable exporting to files'\n")
33
34
35
def cmdlist():
36
pc.printout("FILE=y/n\t")
37
print("Enable/disable output in a '<target username>_<command>.txt' file'")
38
pc.printout("JSON=y/n\t")
39
print("Enable/disable export in a '<target username>_<command>.json' file'")
40
pc.printout("addrs\t\t")
41
print("Get all registered addressed by target photos")
42
pc.printout("cache\t\t")
43
print("Clear cache of the tool")
44
pc.printout("captions\t")
45
print("Get target's photos captions")
46
pc.printout("commentdata\t")
47
print("Get a list of all the comments on the target's posts")
48
pc.printout("comments\t")
49
print("Get total comments of target's posts")
50
pc.printout("followers\t")
51
print("Get target followers")
52
pc.printout("followings\t")
53
print("Get users followed by target")
54
pc.printout("fwersemail\t")
55
print("Get email of target followers")
56
pc.printout("fwingsemail\t")
57
print("Get email of users followed by target")
58
pc.printout("fwersnumber\t")
59
print("Get phone number of target followers")
60
pc.printout("fwingsnumber\t")
61
print("Get phone number of users followed by target")
62
pc.printout("hashtags\t")
63
print("Get hashtags used by target")
64
pc.printout("info\t\t")
65
print("Get target info")
66
pc.printout("likes\t\t")
67
print("Get total likes of target's posts")
68
pc.printout("mediatype\t")
69
print("Get target's posts type (photo or video)")
70
pc.printout("photodes\t")
71
print("Get description of target's photos")
72
pc.printout("photos\t\t")
73
print("Download target's photos in output folder")
74
pc.printout("propic\t\t")
75
print("Download target's profile picture")
76
pc.printout("stories\t\t")
77
print("Download target's stories")
78
pc.printout("tagged\t\t")
79
print("Get list of users tagged by target")
80
pc.printout("target\t\t")
81
print("Set new target")
82
pc.printout("wcommented\t")
83
print("Get a list of user who commented target's photos")
84
pc.printout("wtagged\t\t")
85
print("Get a list of user who tagged target")
86
87
88
def signal_handler(sig, frame):
89
pc.printout("\nGoodbye!\n", pc.RED)
90
sys.exit(0)
91
92
93
def completer(text, state):
94
options = [i for i in commands if i.startswith(text)]
95
if state < len(options):
96
return options[state]
97
else:
98
return None
99
100
101
def _quit():
102
pc.printout("Goodbye!\n", pc.RED)
103
sys.exit(0)
104
105
106
signal.signal(signal.SIGINT, signal_handler)
107
if is_windows:
108
pyreadline.Readline().parse_and_bind("tab: complete")
109
pyreadline.Readline().set_completer(completer)
110
else:
111
gnureadline.parse_and_bind("tab: complete")
112
gnureadline.set_completer(completer)
113
114
parser = argparse.ArgumentParser(description='Osintgram is a OSINT tool on Instagram. It offers an interactive shell '
115
'to perform analysis on Instagram account of any users by its nickname ')
116
parser.add_argument('id', type=str, # var = id
117
help='username')
118
parser.add_argument('-C','--cookies', help='clear\'s previous cookies', action="store_true")
119
parser.add_argument('-j', '--json', help='save commands output as JSON file', action='store_true')
120
parser.add_argument('-f', '--file', help='save output in a file', action='store_true')
121
parser.add_argument('-c', '--command', help='run in single command mode & execute provided command', action='store')
122
parser.add_argument('-o', '--output', help='where to store photos', action='store')
123
124
args = parser.parse_args()
125
126
127
if config.getHikerToken():
128
api = HikerCLI(args.id, args.file, args.json, args.command, args.output, args.cookies)
129
else:
130
api = Osintgram(args.id, args.file, args.json, args.command, args.output, args.cookies)
131
132
133
commands = {
134
'list': cmdlist,
135
'help': cmdlist,
136
'quit': _quit,
137
'exit': _quit,
138
'addrs': api.get_addrs,
139
'cache': api.clear_cache,
140
'captions': api.get_captions,
141
"commentdata": api.get_comment_data,
142
'comments': api.get_total_comments,
143
'followers': api.get_followers,
144
'followings': api.get_followings,
145
'fwersemail': api.get_fwersemail,
146
'fwingsemail': api.get_fwingsemail,
147
'fwersnumber': api.get_fwersnumber,
148
'fwingsnumber': api.get_fwingsnumber,
149
'hashtags': api.get_hashtags,
150
'info': api.get_user_info,
151
'likes': api.get_total_likes,
152
'mediatype': api.get_media_type,
153
'photodes': api.get_photo_description,
154
'photos': api.get_user_photo,
155
'propic': api.get_user_propic,
156
'stories': api.get_user_stories,
157
'tagged': api.get_people_tagged_by_user,
158
'target': api.change_target,
159
'wcommented': api.get_people_who_commented,
160
'wtagged': api.get_people_who_tagged
161
}
162
163
164
signal.signal(signal.SIGINT, signal_handler)
165
if is_windows:
166
pyreadline.Readline().parse_and_bind("tab: complete")
167
pyreadline.Readline().set_completer(completer)
168
else:
169
gnureadline.parse_and_bind("tab: complete")
170
gnureadline.set_completer(completer)
171
172
if not args.command:
173
printlogo()
174
175
176
while True:
177
if args.command:
178
cmd = args.command
179
_cmd = commands.get(args.command)
180
else:
181
signal.signal(signal.SIGINT, signal_handler)
182
if is_windows:
183
pyreadline.Readline().parse_and_bind("tab: complete")
184
pyreadline.Readline().set_completer(completer)
185
else:
186
gnureadline.parse_and_bind("tab: complete")
187
gnureadline.set_completer(completer)
188
pc.printout("Run a command: ", pc.YELLOW)
189
cmd = input()
190
191
_cmd = commands.get(cmd)
192
193
if _cmd:
194
_cmd()
195
elif cmd == "FILE=y":
196
api.set_write_file(True)
197
elif cmd == "FILE=n":
198
api.set_write_file(False)
199
elif cmd == "JSON=y":
200
api.set_json_dump(True)
201
elif cmd == "JSON=n":
202
api.set_json_dump(False)
203
elif cmd == "":
204
print("")
205
else:
206
pc.printout("Unknown command\n", pc.RED)
207
208
if args.command:
209
break
210
211