![]() |
|
[Python] Admin Panel Finder - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: [Python] Admin Panel Finder (/Thread-Python-Admin-Panel-Finder) |
[Python] Admin Panel Finder - mls577 - 06-26-2013 My admin panel finder I coded in python. Everything should work fine, if not please let me know. The only thing that I could never get to work no matter what I did, was get the program to stop with ctrl + c, even throwing a KeyboardInterrupt exception didn't work no matter where I placed it. Anyway, if you want to exit the program just close out of the shell. download all of the files here, which you will need the text files included for this to work: http://mls577.bugs3.com/apf.rar If you want to see the source code to learn from it without downloading it, I have posted it below: Code: #!/usr/bin/env python3.1
#mls577
#shoutz to suidrewt and #haxme
#http authentication check added by redN00ws of Cleveridge ( cleveridge.org )
#admin panel finder takes a website and a specified script type i.e. php and tries different admin panel paths from a text file and see if it exists
#note: make sure you keep all these text files and the program in the same folder
#imports
import urllib.request
import urllib.error
import sys
#list of possible admin panels found
possibilities = []
def main():
print("Admin Panel Finder by mls577")
print(" shoutz to #suidrewt and #haxme")
#argument check
if(len(sys.argv) > 2):
build_url()
#check to see if posibilities list is empty
if(len(possibilities) == 0):
print("\nno admin panel found!")
else:
print("\npossible admin panels:\n")
for pos in possibilities:
print(pos)
else:
usage()
def usage():
print("usage:")
print("./apf <site> <script type>")
print("./apf site.com php")
print("./apf site.com asp")
print("./apf site.com cfm")
print("./apf site.com js")
print("./apf site.com cgi")
print("./apf site.com brf")
def build_url():
try:
script_type = str(sys.argv[2])
site = sys.argv[1]
script = {"asp": "asp.txt", "brf": "brf.txt", "cfm": "cfm.txt", "cgi": "cgi.txt", "js": "js.txt", "php": "php.txt"}
#list of admin panel locations
wordlist = open(script[script_type], "r")
for page in wordlist:
url = "http://" + site + "/" + page
code = connect(url)
results(code, url)
except IOError:
print("wrong script type or file not found")
except EOFError:
pass
def connect(url):
try:
print("\ntrying... " + url)
opener = urllib.request.build_opener() #create url opener
opener.addheaders = [("User-agent", "mozilla/5.0")] # create user agent
req = opener.open(url)
return req.getcode() #return http response code
except IOError:
auth = urllib.request.HTTPBasicAuthHandler() # Create handler for possible authentication with remote host
auth.add_password(
realm='test',
uri=url,
user='tester',
passwd='testpw'
)
opener= urllib.request.build_opener(auth) # Create opener
urllib.request.install_opener(opener)
try: # try to read the possible athentication page with a wrong username and password
fl= urllib.request.urlopen(url)
return fl.read()
except urllib.error.HTTPError as e: # if the a authentication page exists it will return a 401 Http response
if e.code == 401:
return e.code
except:
return 404
except:
return 404
def results(code, url):
if(code == 200 or code == 302):
print("possible admin panel found! Http Resp. 200/302")
possibilities.append(url) #add possible admin locations to list
elif(code == 401):
print("possible admin panel found! HTTP Auth Prompt")
possibilities.append(url) #add possible admin locations to list
else:
print("doesn't exist: ")
main()RE: [Python] Admin Panel Finder - redN00ws - 06-27-2013 I'll check it out...
RE: [Python] Admin Panel Finder - redN00ws - 06-27-2013 I've tested it with a few php sites. The first is a site I created it myself, it has a /phpmyadmin control panel and... it wasn't found The second was a well known joomla site with an /administrator control panel... not found My php.txt file was Code: admin
mysqladmin
phpmyadmin
administratorYour tool is checking the 4 url's but at the end it says "no admin panel found!" When I check for an other directory within the sites, it works fine... so I think it has something to do with popping up login panel... before it gives away the '200' response. I'll look at it further tomorrow... it is almost 11.30pm over here :wacko: RE: [Python] Admin Panel Finder - mls577 - 06-27-2013 (06-27-2013, 10:28 PM)redN00ws Wrote: I've tested it with a few php sites.depending on which list you're using, only 1 of those are on the list. this isn't my list, it's just one a found, you can add them as you wish. I'm not sure why it's not working right for you, because it is for me, I've tested it on a site I created and it found it. RE: [Python] Admin Panel Finder - redN00ws - 06-27-2013 Your tool works fine for e.g. Wordpress sites, because you will find a login app within the webpage, like [wordpress-site]/wp-login.php ![]() But it doesn't work for admin pages with a HTTP Auth Prompt, like ![]() These sites don't send a http response when you don't try to login. RE: [Python] Admin Panel Finder - redN00ws - 07-01-2013 Hi mls577, I've changed your code. Now, it also checks if a HTTP Authentication Prompt pops up and if the page gives a Http Response 401. I hope the way of coding is ok, because I'm a web programmer and just started with Python... but it works :ok: Code: #!/usr/bin/env python3.1
#mls577
#shoutz to suidrewt and #haxme
#http authentication check added by redN00ws of Cleveridge ( cleveridge.org )
#admin panel finder takes a website and a specified script type i.e. php and tries different admin panel paths from a text file and see if it exists
#note: make sure you keep all these text files and the program in the same folder
#imports
import urllib.request
import urllib.error
import sys
#list of possible admin panels found
possibilities = []
def main():
print("Admin Panel Finder by mls577")
print(" shoutz to #suidrewt and #haxme")
#argument check
if(len(sys.argv) > 2):
build_url()
#check to see if posibilities list is empty
if(len(possibilities) == 0):
print("\nno admin panel found!")
else:
print("\npossible admin panels:\n")
for pos in possibilities:
print(pos)
else:
usage()
def usage():
print("usage:")
print("./apf <site> <script type>")
print("./apf site.com php")
print("./apf site.com asp")
print("./apf site.com cfm")
print("./apf site.com js")
print("./apf site.com cgi")
print("./apf site.com brf")
def build_url():
try:
script_type = str(sys.argv[2])
site = sys.argv[1]
script = {"asp": "asp.txt", "brf": "brf.txt", "cfm": "cfm.txt", "cgi": "cgi.txt", "js": "js.txt", "php": "php.txt"}
#list of admin panel locations
wordlist = open(script[script_type], "r")
for page in wordlist:
url = "http://" + site + "/" + page
code = connect(url)
results(code, url)
except IOError:
print("wrong script type or file not found")
except EOFError:
pass
def connect(url):
try:
print("\ntrying... " + url)
opener = urllib.request.build_opener() #create url opener
opener.addheaders = [("User-agent", "mozilla/5.0")] # create user agent
req = opener.open(url)
return req.getcode() #return http response code
except IOError:
auth = urllib.request.HTTPBasicAuthHandler() # Create handler for possible authentication with remote host
auth.add_password(
realm='test',
uri=url,
user='tester',
passwd='testpw'
)
opener= urllib.request.build_opener(auth) # Create opener
urllib.request.install_opener(opener)
try: # try to read the possible athentication page with a wrong username and password
fl= urllib.request.urlopen(url)
return fl.read()
except urllib.error.HTTPError as e: # if the a authentication page exists it will return a 401 Http response
if e.code == 401:
return e.code
except:
return 404
except:
return 404
def results(code, url):
if(code == 200 or code == 302):
print("possible admin panel found! Http Resp. 200/302")
possibilities.append(url) #add possible admin locations to list
elif(code == 401):
print("possible admin panel found! HTTP Auth Prompt")
possibilities.append(url) #add possible admin locations to list
else:
print("doesn't exist: ")
main()RE: [Python] Admin Panel Finder - mls577 - 07-01-2013 Thread update with new code thanks to redN00ws RE: [Python] Admin Panel Finder - redN00ws - 07-01-2013 You're welcome ;o) |