-
Notifications
You must be signed in to change notification settings - Fork 665
/
datasploit.py
executable file
·112 lines (104 loc) · 4.27 KB
/
datasploit.py
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
#!/usr/bin/env python
import dep_check
dep_check.check_dependency()
import re
import sys
import shutil
import os
import textwrap
import argparse
import emailOsint
import domainOsint
import ipOsint
import usernameOsint
from tld import get_tld
from netaddr import IPAddress,AddrFormatError
def main(argv):
output=None
desc="""
____/ /____ _ / /_ ____ _ _____ ____ / /____ (_)/ /_
/ __ // __ `// __// __ `// ___// __ \ / // __ \ / // __/
/ /_/ // /_/ // /_ / /_/ /(__ )/ /_/ // // /_/ // // /_
\__,_/ \__,_/ \__/ \__,_//____// .___//_/ \____//_/ \__/
/_/
Open Source Assistant for #OSINT
www.datasploit.info
"""
epilog=""" Connect at Social Media: @datasploit
"""
# Set all parser arguments here.
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,description=textwrap.dedent(desc),epilog=epilog)
parser.add_argument("-i","--input",help="Provide Input",dest='single_target')
parser.add_argument("-f","--file",help="Provide Input",dest='file_target')
parser.add_argument("-a","--active",help="Run Active Scan attacks",dest='active',action="store_false")
parser.add_argument("-q","--quiet",help="Run scans in automated manner accepting default answers",dest='quiet',action="store_false")
parser.add_argument("-o","--output",help="Provide Destination Directory",dest='output')
# check and ensure the config file is present otherwise create one. required for all further operations
ds_dir=os.path.dirname(os.path.realpath(__file__))
config_file_path = os.path.join(ds_dir,"config.py")
config_sample_path= os.path.join(ds_dir,"config_sample.py")
print os.path.exists(config_file_path)
if not os.path.exists(config_file_path):
print "[+] Looks like a new setup, setting up the config file."
shutil.copyfile(config_sample_path,config_file_path)
print "[+] A config file is added please follow guide at https://datasploit.github.io/datasploit/apiGeneration/ to fill API Keys for better results"
# We can think about quiting at this point.
# parse arguments in case they are provided.
x=parser.parse_args()
active=x.active
quiet=x.quiet
single_input=x.single_target
file_input=x.file_target
output=x.output
# if no target is provided print help and quit.
if not (single_input or file_input):
print "\nSingle target or file input required to run\n"
parser.print_help()
sys.exit()
# Banner print
print textwrap.dedent(desc)
if single_input:
try:
auto_select_target(single_input, output)
except KeyboardInterrupt:
print "\nCtrl+C called Quiting"
if file_input:
try:
if os.path.isfile(file_input):
print "File Input: %s" % file_input
with open(file_input, 'r') as f:
for target in f:
auto_select_target(target.rstrip(), output)
print "\nDone processing %s" % file_input
else:
print "%s is not a readable file" % file_input
print "Exiting..."
except KeyboardInterrupt:
print "\nCtrl+C called Quiting"
def auto_select_target(target, output=None):
"""Auto selection logic"""
print "Target: %s" % target
try:
inp=IPAddress(target);
if inp.is_private() or inp.is_loopback():
print "Internal IP Detected : Skipping"
sys.exit()
else:
print "Looks like an IP, running ipOsint...\n"
ipOsint.run(target, output)
except SystemExit:
print "exiting"
except AddrFormatError:
if re.match('[^@]+@[^@]+\.[^@]+', target):
print "Looks like an EMAIL, running emailOsint...\n"
emailOsint.run(target, output)
elif get_tld(target, fix_protocol=True,fail_silently=True) is not None:
print "Looks like a DOMAIN, running domainOsint...\n"
domainOsint.run(target, output)
else:
print "Nothing Matched assuming username, running usernameOsint...\n"
usernameOsint.run(target, output)
except:
print "Unknown Error Occured"
if __name__ == "__main__":
main(sys.argv[1:])