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 f77726f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/ronin/cli/commands/decode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module Commands
# --punycode Decodes the data as Punycode
# -Q, --quoted-printable Decodes the data as Quoted Printable
# -R, --ruby Ruby decodes the data
# -p, --php PHP decodes the data
# --uudecode uudecodes the data
# -x, --xml XML decodes the data
# -h, --help Print help information
Expand Down Expand Up @@ -155,6 +156,12 @@ class Decode < StringMethodsCommand
@method_calls << :quoted_printable_decode
end

option :php, short: '-p',
desc: 'PHP decodes the data' do
require 'ronin/support/encoding/php'
@method_calls << :php_decode
end

option :ruby, short: '-R',
desc: 'Ruby decodes the data' do
require 'ronin/support/encoding/ruby'
Expand Down
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
5 changes: 4 additions & 1 deletion man/ronin-decode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Decodes each character of the given data from a variety of formats.
`-R`, `--ruby`
: Ruby decodes the data.

`-p`, `--php`
: PHP decodes the data.

`--uudecode`
: uudecodes the data.

Expand All @@ -96,4 +99,4 @@ Postmodern <[email protected]>

## SEE ALSO

[ronin-encode](ronin-encode.1.md)
[ronin-encode](ronin-encode.1.md)
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 f77726f

Please sign in to comment.