Skip to content

Commit b5d71a4

Browse files
authored
Merge pull request #201 from KhasMek/file-input
datasploit: option for file input
2 parents 004390a + 9432ff7 commit b5d71a4

File tree

1 file changed

+60
-40
lines changed

1 file changed

+60
-40
lines changed

datasploit.py

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@
1616

1717
def main(argv):
1818
output=None
19-
desc="""
19+
desc="""
2020
____/ /____ _ / /_ ____ _ _____ ____ / /____ (_)/ /_
2121
/ __ // __ `// __// __ `// ___// __ \ / // __ \ / // __/
22-
/ /_/ // /_/ // /_ / /_/ /(__ )/ /_/ // // /_/ // // /_
23-
\__,_/ \__,_/ \__/ \__,_//____// .___//_/ \____//_/ \__/
24-
/_/
25-
26-
Open Source Assistant for #OSINT
27-
www.datasploit.info
22+
/ /_/ // /_/ // /_ / /_/ /(__ )/ /_/ // // /_/ // // /_
23+
\__,_/ \__,_/ \__/ \__,_//____// .___//_/ \____//_/ \__/
24+
/_/
25+
26+
Open Source Assistant for #OSINT
27+
www.datasploit.info
2828
2929
"""
30-
epilog=""" Connect at Social Media: @datasploit
30+
epilog=""" Connect at Social Media: @datasploit
3131
"""
3232
# Set all parser arguments here.
3333
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,description=textwrap.dedent(desc),epilog=epilog)
34-
parser.add_argument("-i","--input",help="Provide Input",dest='target',required=True)
34+
parser.add_argument("-i","--input",help="Provide Input",dest='single_target')
35+
parser.add_argument("-f","--file",help="Provide Input",dest='file_target')
3536
parser.add_argument("-a","--active",help="Run Active Scan attacks",dest='active',action="store_false")
3637
parser.add_argument("-q","--quiet",help="Run scans in automated manner accepting default answers",dest='quiet',action="store_false")
3738
parser.add_argument("-o","--output",help="Provide Destination Directory",dest='output')
@@ -45,45 +46,64 @@ def main(argv):
4546
shutil.copyfile(config_sample_path,config_file_path)
4647
print "[+] A config file is added please follow guide at https://datasploit.github.io/datasploit/apiGeneration/ to fill API Keys for better results"
4748
# We can think about quiting at this point.
48-
# if no argument is provided print help and quit
49-
if len(argv) == 0:
50-
parser.print_help()
51-
sys.exit()
5249
# parse arguments in case they are provided.
5350
x=parser.parse_args()
5451
active=x.active
5552
quiet=x.quiet
56-
user_input=x.target
53+
single_input=x.single_target
54+
file_input=x.file_target
5755
output=x.output
56+
# if no target is provided print help and quit.
57+
if not (single_input or file_input):
58+
print "\nSingle target or file input required to run\n"
59+
parser.print_help()
60+
sys.exit()
5861
# Banner print
5962
print textwrap.dedent(desc)
60-
# Auto selection logic
61-
try:
62-
print "User Input: %s" % user_input
63+
if single_input:
6364
try:
64-
inp=IPAddress(user_input);
65-
if inp.is_private() or inp.is_loopback():
66-
print "Internal IP Detected : Skipping"
67-
sys.exit()
68-
else:
69-
print "Looks like an IP, running ipOsint...\n"
70-
ipOsint.run(user_input, output)
71-
except SystemExit:
72-
print "exiting"
73-
except AddrFormatError:
74-
if re.match('[^@]+@[^@]+\.[^@]+', user_input):
75-
print "Looks like an EMAIL, running emailOsint...\n"
76-
emailOsint.run(user_input, output)
77-
elif get_tld(user_input, fix_protocol=True,fail_silently=True) is not None:
78-
print "Looks like a DOMAIN, running domainOsint...\n"
79-
domainOsint.run(user_input, output)
65+
auto_select_target(single_input, output)
66+
except KeyboardInterrupt:
67+
print "\nCtrl+C called Quiting"
68+
if file_input:
69+
try:
70+
if os.path.isfile(file_input):
71+
print "File Input: %s" % file_input
72+
with open(file_input, 'r') as f:
73+
for target in f:
74+
auto_select_target(target.rstrip(), output)
75+
print "\nDone processing %s" % file_input
8076
else:
81-
print "Nothing Matched assuming username, running usernameOsint...\n"
82-
usernameOsint.run(user_input, output)
83-
except:
84-
print "Unknown Error Occured"
85-
except KeyboardInterrupt:
86-
print "Ctrl+C called Quiting"
77+
print "%s is not a readable file" % file_input
78+
print "Exiting..."
79+
except KeyboardInterrupt:
80+
print "\nCtrl+C called Quiting"
81+
82+
def auto_select_target(target, output=None):
83+
"""Auto selection logic"""
84+
print "Target: %s" % target
85+
try:
86+
inp=IPAddress(target);
87+
if inp.is_private() or inp.is_loopback():
88+
print "Internal IP Detected : Skipping"
89+
sys.exit()
90+
else:
91+
print "Looks like an IP, running ipOsint...\n"
92+
ipOsint.run(target, output)
93+
except SystemExit:
94+
print "exiting"
95+
except AddrFormatError:
96+
if re.match('[^@]+@[^@]+\.[^@]+', target):
97+
print "Looks like an EMAIL, running emailOsint...\n"
98+
emailOsint.run(target, output)
99+
elif get_tld(target, fix_protocol=True,fail_silently=True) is not None:
100+
print "Looks like a DOMAIN, running domainOsint...\n"
101+
domainOsint.run(target, output)
102+
else:
103+
print "Nothing Matched assuming username, running usernameOsint...\n"
104+
usernameOsint.run(target, output)
105+
except:
106+
print "Unknown Error Occured"
87107

88108
if __name__ == "__main__":
89-
main(sys.argv[1:])
109+
main(sys.argv[1:])

0 commit comments

Comments
 (0)