Skip to content

Commit

Permalink
Added the --php option to the ronin quote command (closes #241).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 61e154d commit c1c6488
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ronin/cli/commands/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module Commands
# -j, --js JavaScript quotes the data
# -S, --shell Quotes the data as a Shell String
# -P, --powershell Quotes the data as a PowerShell String
# -p, --php Quotes the data as a PHP String
# --python Quotes the data as a Python String
# -R, --ruby Quotes the data as a Ruby String
# -h, --help Print help information
Expand Down Expand Up @@ -79,6 +80,12 @@ class Quote < StringMethodsCommand
@method_calls << :powershell_string
end

option :php, short: '-p',
desc: 'Quotes the data as a PHP String' do
require 'ronin/support/encoding/php'
@method_calls << :php_string
end

option :python, desc: 'Quotes the data as a Python String' do
require 'ronin/support/encoding/python'
@method_calls << :python_string
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-quote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Produces quoted a string for a variety of programming languages.
`-P`, `--powershell`
: Quotes the data as a PowerShell String.

`-p`, `--php`
: Quotes the data as a PHP String.

`--python`
: Quotes the data as a Python String.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/quote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
end
end

describe "--php" do
let(:argv) { %w[--php] }

it "must require 'ronin/support/encoding/php'" do
expect(require('ronin/support/encoding/php')).to be(false)
end

it "must add :php_string to #method_calls" do
expect(subject.method_calls.last).to eq(:php_string)
end
end

describe "--powershell" do
let(:argv) { %w[--powershell] }

Expand Down

0 comments on commit c1c6488

Please sign in to comment.