Skip to content

Commit

Permalink
Added the --php option to ronin encode (closes #212).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 16, 2024
1 parent 5e761d5 commit 16a30f6
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/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Commands
# -P, --powershell Encodes the data as a PowerShell String
# --punycode Encodes the data as Punycode
# -Q, --quoted-printable Encodes the data as Quoted Printable
# -p, --php Encodes the data as a PHP String
# -R, --ruby Encodes the data as a Ruby String
# --uuencode uuencodes the data
# -x, --xml XML encodes the data
Expand Down Expand Up @@ -155,6 +156,12 @@ class Encode < StringMethodsCommand
@method_calls << :quoted_printable_encode
end

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

option :ruby, short: '-R',
desc: 'Encodes the data as a Ruby String' do
require 'ronin/support/encoding/ruby'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-encode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Encodes each character of the given data into a variety of formats.
`--uuencode`
: uuencodes the data.

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

`-R`, `--ruby`
: Encodes the data as a Ruby String.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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 :ruby_encode to #method_calls" do
expect(subject.method_calls.last).to eq(:php_encode)
end
end

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

Expand Down

0 comments on commit 16a30f6

Please sign in to comment.