├── .deepsource.toml ├── README.md └── ShodanOpenDirs.py /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "python" 5 | enabled = true 6 | 7 | [analyzers.meta] 8 | runtime_version = "3.x.x" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShodanOpenDirs 2 | 3 | Simple Python code to retrieve all the servers with a open FTP port that allows anonymoys logins. Makes a txt file with the IPs afterwards. 4 | 5 | Go to https://www.shodan.io/ and create a account, i would recommend to use your EDU account if you have one. They do lifetime account sales for 5$ on black friday and events. Grab those when you see them. 6 | 7 | When you have made your account, grab they API key from the main page of your profile and insert it at line #9 in the code where it says key. 8 | 9 | If you want to use more query tokens and go past 100 searches, uncomment the for loop above the check creds function and structure it propperly with a indentation 10 | 11 | 12 | Enjoy! 13 | 14 | -------------------------------------------------------------------------------- /ShodanOpenDirs.py: -------------------------------------------------------------------------------- 1 | from ftplib import FTP 2 | 3 | try: 4 | import shodan 5 | except: 6 | print('You need the Shodan Python module') 7 | 8 | 9 | key = "" #Insert key here 10 | api = shodan.Shodan(key) 11 | 12 | 13 | def checkCreds(integer): 14 | 15 | results = api.search('ftp', integer) 16 | # Show the results 17 | print('Results found: {}'.format(results['total'])) 18 | try: 19 | with open('somefile.txt', 'a') as f: 20 | counter = 0 21 | for result in results['matches']: 22 | ip = result['ip_str'] 23 | print(counter) 24 | print('IP: {}'.format(result['ip_str'])) 25 | try: 26 | ftp = FTP(ip) 27 | ftp.login() 28 | f.write(ip + "\n") 29 | f.writelines(ftp.retrlines('LIST')) 30 | f.write("\n") 31 | print(" \n") 32 | except: 33 | print("Default login not available \n") 34 | counter += 1 35 | f.close() 36 | except shodan.APIError as error: 37 | print('Error {}'.format(error)) 38 | f.close() 39 | 40 | try: 41 | ##Add this and change 1 to count, if you want more than 100 Resulst 42 | #zWarning uses all your Query credits 43 | #for count in range(1,21): 44 | checkCreds(1) 45 | 46 | except FileExistsError: 47 | print("Error occured") 48 | --------------------------------------------------------------------------------