-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathShodanOpenDirs.py
47 lines (39 loc) · 1.22 KB
/
ShodanOpenDirs.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
from ftplib import FTP
try:
import shodan
except:
print('You need the Shodan Python module')
key = "" #Insert key here
api = shodan.Shodan(key)
def checkCreds(integer):
results = api.search('ftp', integer)
# Show the results
print('Results found: {}'.format(results['total']))
try:
with open('somefile.txt', 'a') as f:
counter = 0
for result in results['matches']:
ip = result['ip_str']
print(counter)
print('IP: {}'.format(result['ip_str']))
try:
ftp = FTP(ip)
ftp.login()
f.write(ip + "\n")
f.writelines(ftp.retrlines('LIST'))
f.write("\n")
print(" \n")
except:
print("Default login not available \n")
counter += 1
f.close()
except shodan.APIError as error:
print('Error {}'.format(error))
f.close()
try:
##Add this and change 1 to count, if you want more than 100 Resulst
#zWarning uses all your Query credits
#for count in range(1,21):
checkCreds(1)
except FileExistsError:
print("Error occured")