-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOhShint.py
More file actions
669 lines (540 loc) · 26.6 KB
/
OhShint.py
File metadata and controls
669 lines (540 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# General imports
import os
import sys
import time
import webbrowser
import re
import ipaddress
# Homemade module imports
from passwords import generate_passwords
from usernames import generate_usernames
from emails import generate_emails
from image_metadata import metadata_extractor, clear_metadata
from ip_geolocation import url2ip
from ip_geolocation import ip_details
from lookup import search
# Ascii art
ascii_art_lines = [
r" ('-. .-. .-') ('-. .-. .-') _ .-') _ ",
r" ( OO ) / ( OO ). ( OO ) / ( OO ) )( OO) ) ",
r" .-'),-----. ,--. ,--.(_)---\_),--. ,--. ,-.-') ,--./ ,--,' / '._ ",
r"( OO' .-. '| | | |/ _ | | | | | | |OO)| \ | |\ |'--...__) ",
r"/ | | | || .| |\ :` `. | .| | | | \| \| | )'--. .--' ",
r"\_) | |\| || | '..`''.)| | | |(_/| . |/ | | ",
r" \ | | | || .-. |.-._) \| .-. | ,| |_.'| |\ | | | ",
r" `' '-' '| | | |\ /| | | |(_| | | | \ | | |.-..-..-. ",
r" `-----' `--' `--' `-----' `--' `--' `--' `--' `--' `--'`-'`-'`-' "
]
# Help messages
main_help_message = """
\033[94mAvailable Commands:\033[0m
\033[94m1. user\t\t- Generate a list of potential usernames\033[0m
\033[94m2. pass\t\t- Generate a list of potential passwords\033[0m
\033[94m3. lookup\t- Search for a username on different social media sites\033[0m
\033[94m4. mtdata\t- Extract or clear metadata from an image\033[0m
\033[94m5. email\t- Generate a list of potential emails\033[0m
\033[94m6. ip\t\t- Get details about an IP address\033[0m
\033[94m7. url\t\t- Get IP details from a given URL\033[0m
\033[94m8. visit\t- Open the webpage of a found URL in a lookup\033[0m
\033[94m9. show\t\t- Display generated usernames, lookup results, or password list storage path\033[0m
\033[94m10. help\t\t- Display this help message\033[0m
\033[94m11. exit\t\t- Exit the program\033[0m
\033[94mFor more information on a command use: [COMMAND] -h\033[0m
"""
email_help_message = """
\033[94mEmail generator - Generates potential emails\033[0m
Usage:
email
Options:
-h Show this help message
How to use:
Just run the command and follow the steps!
"""
ip_help_message = """
\033[94mIP details - Get details about an IP address\033[0m
Usage:
ip <ip_address>
Options:
-h Show this help message
Examples:
ip 192.168.0.1
Notes:
Provides details such as geolocation and ISP information about the specified IP address.
"""
url_help_message = """
\033[94mURL to IP - Get IP details from a given URL\033[0m
Usage:
url <url> [options]
Options:
-h Show this help message
-f In the case of reaching an API limit use this flag to atleast get the URL IP address
Examples:
url http://example.com
Notes:
Converts the provided URL to an IP address and retrieves details about it.
"""
mtdata_help_message = """
\033[94mmtdata - Metadata extraction and clearing tool\033[0m
Usage:
mtdata <file_path> [options]
Options:
-h Show this help message
-c Clear metadata from the specified file
-o Overwrite the original images metadata if clearing its metadata instead of creating a new image
-mn Display MakerNote metadata (hidden by default)
Examples:
mtdata image.jpg Extract metadata from image.jpg and display it
mtdata image.jpg -mn Extract metadata from image.jpg, including MakerNote data, and display it
mtdata image.jpg -c Clear metadata from image.jpg and save the result as modified_image.jpg
mtdata image.jpg -c -o Clear metadata from image.jpg and save the result as new_image.jpg
"""
user_help_message = """
\033[94mUsername generator - Generates potential usernames\033[0m
Usage:
user
How to use:
Just run the command and follow the steps!
"""
pass_help_message = """
\033[94mPassword finder - Generates potential passwords\033[0m
Usage:
pass
How to use:
Just run the command and follow the steps!
"""
lookup_help_message = """
\033[94mLookup - Searches for user information based on a username\033[0m
Usage:
lookup <username> [options]
Options:
-h Show this help message
-i <ID> Use the username associated with the given ID from the generated usernames list
Examples:
lookup username
lookup -i 2
Notes:
To use the -i option, you must first generate a list of usernames using the usr command.
The command searches for information related to the specified username and displays the results.
"""
visit_help_message = """
\033[94mVisit - Opens a browser tab of a URL found during a lookup033[0m
Usage:
visit <id>
Options:
-h Show this help message
Examples:
visit 0
Notes:
Before using this command, ensure you have completed a lookup first.
"""
show_help_message = """
\033[94mShow - Displays generated data or storage paths\033[0m
Usage:
show [option]
Options:
-h Show this help message
usernames Display the generated usernames and storage path
emails Display the generated emails and storage path
lookup Display the results of the last lookup performed
passwords Display the path to the stored password list
ip Display details about the last IP lookup performed
url Display details about the last URL lookup performed
Notes:
Before using some options, ensure you have generated usernames, emails, or performed lookups.
Use 'show [option]' to view specific information based on your command.
"""
# A function used for openning links found in lookups
def open_website(url):
webbrowser.open(url)
# Variable initialization
username_file_path = ""
pass_file_path = ""
url_ip_details = ""
ip_add_details = ""
lookup_results = {}
# Ascii art logo
for line in ascii_art_lines:
print(f"\033[94m{line}\033[0m")
time.sleep(0.07)
print(f"\n{main_help_message}\n")
# Main Code
try:
while True:
prompt = input("OhShint! > ")
prompt = prompt.split()
if not prompt:
continue
elif prompt[0] == "exit":
print("\033[94mQuitting...\033[0m")
sys.exit()
elif prompt[0] == "help":
print(main_help_message)
continue
elif prompt[0] == "url":
if "-h" in prompt:
print(url_help_message)
continue
else:
try:
url = prompt[1]
regex = r'^(?!:\/\/)([a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+\.?[a-zA-Z0-9-_]*$)'
assert re.match(regex, url), f"Please enter a invalid URL format: {url}"
except IndexError:
print("Please specify a URL")
except AssertionError as e:
print(e)
except Exception as e:
print(e)
else:
url_ip = url2ip(url)
if "-f" in prompt:
print(url_ip)
url_ip_details = f"Details for: {url}\n" + ip_details(ip=url_ip)
print(url_ip_details)
finally:
continue
elif prompt[0] == "ip":
if "-h" in prompt:
print(ip_help_message)
continue
else:
try:
ip = prompt[1]
if not ip:
raise IndexError("Please specify an IPv4 or IPv6 address.")
try:
ip_obj = ipaddress.ip_address(ip)
if not isinstance(ip_obj, ipaddress.IPv4Address) or isinstance(ip_obj, ipaddress.IPv6Address):
raise AssertionError(f"{ip} is neither a valid IPv4 nor IPv6 address.")
except ValueError:
print(f"{ip} is not a valid IPv4 or IPv6 address.")
except IndexError:
print("Please specify an ipv4/ipv6 address")
except AssertionError as e:
print(e)
except Exception as e:
print(e)
else:
ip_add_details = ip_details(ip=ip)
print(ip_add_details)
finally:
continue
elif prompt[0] == "email":
name, last_name, bday, prnt, tlds, domains = None, None, None, False, [], []
if "-h" in prompt:
print(email_help_message)
continue
else:
while True:
name = input("What is the name of the target: ")
if name == "":
print("\033[94mName is not an optional parameter, please enter the targets name\033[0m")
elif not name.isalpha():
print("\033[94mName should only contain letters\033[0m")
else:
break
while True:
last_name = input("Enter the last name of the target: ")
if last_name == "":
print("\033[94mLast name is not an optional parameter, please enter the targets last name\033[0m")
elif not last_name.isalpha():
print("\033[94mLast name should only contain letters\033[0m")
else:
break
while True:
bday = input("Enter the birthday of the target (DDMMYYYY): ")
if bday == "":
print("\033[94mBirthday is not an optional parameter, please enter the targets birthdate.\033[0m")
elif not bday.isdigit():
print("\033[94mBirthday entered contains letters, please enter the birthday in DDMMYYYY format and use only numbers.\033[0m")
elif len(bday) != 8:
print("\033[94mInvalid birthday format, please enter the birthday in DDMMYYYY format.\033[0m")
else:
break
print("Enter the TLD(s) you would like to check.\nExample input: com\nHint: Empty input to end. If you don't enter any TLDs the script will use a preset list.")
while True:
tld = input("TLD to check:")
if tld:
tlds.append(tld)
else:
print("\n")
break
print("Enter the domain(s) you would like to check.\nExample input: gmail\nHint: Empty input to end. If you dont enter any domains the script will use a preset list.")
while True:
domain = input("Domain to check:")
if domain:
domains.append(domain)
else:
print("\n")
break
file_name = input("Enter the name you want the file to be saved as (optional): ")
if file_name == "":
file_name = f"{name}_{last_name}_emails.txt"
print(f"\033[94mFile name was automatically set to: {name}_{last_name}_emails.txt\033[0m")
else:
file_name = file_name + ".txt"
temp_emails, email_file_path = generate_emails(first_name=name, last_name=last_name, bday=bday, tld=tlds, domain = domains, file_name=file_name, prnt=prnt)
emails = {index: email for index, email in enumerate(temp_emails)}
elif prompt[0] == "user":
name, last_name, bday, prnt = None, None, None, False
if "-h" in prompt:
print(user_help_message)
continue
else:
while True:
name = input("What is the name of the target: ")
if name == "":
print("\033[94mName is not an optional parameter, please enter the targets name\033[0m")
elif not name.isalpha():
print("\033[94mName should only contain letters\033[0m")
else:
break
while True:
last_name = input("Enter the last name of the target: ")
if last_name == "":
print("\033[94mLast name is not an optional parameter, please enter the targets last name\033[0m")
elif not last_name.isalpha():
print("\033[94mLast name should only contain letters\033[0m")
else:
break
while True:
bday = input("Enter the birthday of the target (DDMMYYYY): ")
if bday == "":
print("\033[94mBirthday is not an optional parameter, please enter the targets birthdate.\033[0m")
elif not bday.isdigit():
print("\033[94mBirthday entered contains letters, please enter the birthday in DDMMYYYY format and use only numbers.\033[0m")
elif len(bday) != 8:
print("\033[94mInvalid birthday format, please enter the birthday in DDMMYYYY format.\033[0m")
else:
break
prnt = input("Would you like to display the created usernames? (y/N): ")
try:
if prnt == "" or prnt.lower() == "n":
prnt = False
elif prnt.lower() == "y":
prnt = True
else:
prnt = False
except:
prnt = False
if prnt: print("\033[94mResult will be printed\033[0m")
else: print("\033[94mResult won't be printed\033[0m")
file_name = input("Enter the name you want the file to be saved as (optional): ")
if file_name == "":
file_name = f"{name}_{last_name}_usernames.txt"
print(f"\033[94mFile name was automatically set to: {name}_{last_name}_usernames.txt\033[0m")
else:
file_name = file_name + ".txt"
temp_usernames, username_file_path = generate_usernames(first_name=name, last_name=last_name, bday=bday, file_name=file_name, prnt=prnt)
usernames = {index: username for index, username in enumerate(temp_usernames)}
elif prompt[0] == "pass":
prnt = False
save = False
name, last_name, bday, file_name, prnt, save = None, None, None, None, False, False
if "-h" in prompt:
print(pass_help_message)
continue
else:
while True:
name = input("What is the name of the target: ")
if name == "":
print("\033[94mName is not an optional parameter, please enter the targets name\033[0m")
elif not name.isalpha():
print("\033[94mName should only contain letters\033[0m")
else:
break
while True:
last_name = input("Enter the last name of the target: ")
if last_name == "":
print("\033[94mLast name is not an optional parameter, please enter the targets last name\033[0m")
elif not last_name.isalpha():
print("\033[94mLast name should only contain letters\033[0m")
else:
break
while True:
bday = input("Enter the birthday of the target (DDMMYYYY): ")
if bday == "":
print("\033[94mBirthday is not an optional parameter, please enter the targets birthdate.\033[0m")
elif not bday.isdigit():
print("\033[94mBirthday entered contains letters, please enter the birthday in DDMMYYYY format and use only numbers.\033[0m")
elif len(bday) != 8:
print("\033[94mInvalid birthday format, please enter the birthday in DDMMYYYY format.\033[0m")
else:
break
pet = input("Enter the name of the targets pet (optional): ")
nickname = input("Enter the nickname of the target (optional): ")
while True:
size = input("Enter the size of the wordlist\nA) Small (~500 passwords)\nB) Medium(~1500 passwords)\nC) Large(~14000 passwords)\nNote: Sizes vary based on the information given\n\nSelection: ")
if size == "":
print("\033[94mWordlist size is not an optional parameter, please enter the desired size.\033[0m")
else:
if size.lower() == "a" :
size = "small"
break
elif size.lower() == "b" :
size = "medium"
break
elif size.lower() == "c":
size = "large"
break
else:
print("\033[94mInvalid input\033[0m")
file_name = input("Enter the name you want the file to be saved as (optional): ")
if file_name == "":
file_name = f"{name}_{last_name}_wordlist.txt"
print(f"\033[94mFile name was automatically set to: {name}_{last_name}_wordlist.txt\033[0m")
else:
file_name = file_name + ".txt"
temp_passwords, pass_file_path = generate_passwords(first_name=name, last_name=last_name, bday=bday, pet=pet, nickname=nickname, file_name=file_name, size=size)
passwords = {index: password for index, password in enumerate(temp_passwords)}
elif prompt[0] == "show":
if "-h" in prompt:
print(show_help_message)
continue
if "usernames" in prompt:
if usernames:
for k, v in usernames.items():
print(f"{k}: {v}")
if username_file_path:
print(f"\033[94mUsername list was stored at:\n {username_file_path}\033[0m")
continue
else:
print("\033[94mPlease generate a username list first.\033[0m")
continue
elif "emails" in prompt:
if emails:
for k, v in emails.items():
print(f"{k}: {v}")
if email_file_path:
print(f"\033[94mEmail list was stored at:\n {email_file_path}\033[0m")
else:
print("\033[94mPlease generate an email list first.\033[0m")
continue
elif "lookup" in prompt:
if lookup_results:
for k, v in lookup_results.items():
print(f"{k}: {v}")
continue
else:
print("\033[94mPlease complete a lookup first.\033[0m")
continue
elif "passwords" in prompt:
if pass_file_path != "":
print(f"\033[94mPassword list was stored at:\n {pass_file_path}\033[0m")
else:
print("\033[94mPlease generate a password list first\033[0m")
elif "ip" in prompt:
if ip_add_details:
print(ip_add_details)
continue
else:
print("\033[94mPlease complete an IP lookup first.\033[0m")
continue
elif "url" in prompt:
if url_ip_details:
print(url_ip_details)
continue
else:
print("\033[94mPlease complete a URL lookup first.\033[0m")
continue
elif prompt[0] == "lookup":
if "-h" in prompt:
print(lookup_help_message)
continue
if "-i" in prompt:
try:
id = prompt[prompt.index("-i") + 1]
except IndexError:
print("\033[94mPlease specify an ID\033[0m")
continue
except Exception as e:
print(f"\033[94m{e}\033[0m")
if not usernames:
print("\033[94mGenerate a usernames list to start using IDs\033[0m")
continue
if not id.isdigit():
print("\033[94mID should be a number\033[0m")
continue
try:
username = usernames[id]
print(username)
except:
print("\033[94mPlease select an ID in the list of usernames generated\033[0m")
continue
try:
lookup_results = search(username)
except Exception as e:
print(f"\033[94mError: {e}\033[0m")
continue
else:
try:
username = prompt[1]
except IndexError:
print("\033[94mPlease specify a username\033[0m")
continue
except Exception as e:
print(f"\033[94m{e}\033[0m")
continue
try:
lookup_results = search(username)
except Exception as e:
print(f"\033[94mError: {e}\033[0m")
continue
elif prompt[0] == "visit":
if "-h" in prompt:
print(visit_help_message)
continue
try:
if lookup_results == {}:
print("Please complete a lookup first")
continue
website_id = prompt[1]
if not website_id.isdigit():
print("Look up id must be a number")
continue
else: website_id = int(website_id)
if website_id in lookup_results:
open_website(lookup_results[website_id])
print(f"Visiting {lookup_results[website_id]}...")
else:
print("Look up ID must be valid, run 'show lookup' to view valid commands")
except IndexError:
print("Please specify an ID")
except Exception as e:
print(e)
continue
elif prompt[0] == "mtdata":
if "-h" in prompt:
print(mtdata_help_message)
continue
try:
path = prompt[1]
if not os.path.exists(path):
print("\033[94mFile doesn't exist\033[0m")
continue
except:
print("\033[94mNo path specified.\033[0m")
continue
if "-c" in prompt:
if "-o" in prompt:
out_path = path
else:
out_path = path.split("/")
out_path[-1] = f"modified_{out_path[-1]}"
out_path = "/".join(out_path)
clear_metadata(path, out_path)
mtdata = metadata_extractor(file_path=out_path, check = True)
if not mtdata:
print("\033[94mMetadata was cleared successfully!!!\033[0m")
else:
show_mk_note = "-mn" in prompt
mtdata = metadata_extractor(file_path=path)
if mtdata:
for k, v in mtdata.items():
if k != "MakerNote" or show_mk_note:
print(f"\033[94m{k}:\033[0m {v}")
mtdata = {}
else:
print("\033[94mInvalid command\033[0m")
except KeyboardInterrupt:
print("\n\033[94mQuitting...\033[0m")