Skip to content

Commit

Permalink
Added PHPPayload#to_html (closes #183).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 19, 2024
1 parent b87f126 commit 6e07878
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/ronin/payloads/php_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ def to_command
"php -r #{Support::Encoding::Shell.quote(to_s)}"
end

#
# Converts the built PHP payload into a `<?php ... ?>` HTML embed.
#
# @return [String]
# The `<?php ... ?>` HTML embed containing the built PHP payload.
#
# @api public
#
# @since 0.3.0
#
def to_html
"<?php #{self} ?>"
end

end
end
end
6 changes: 6 additions & 0 deletions spec/php_payload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ def build
expect(subject.to_command).to eq(%{php -r "echo 'PWNED';"})
end
end

describe "#to_html" do
it "must embed the built payload into a '<?php ... ?>' HTML embed" do
expect(subject.to_html).to eq(%{<?php echo 'PWNED'; ?>})
end
end
end

0 comments on commit 6e07878

Please sign in to comment.