Skip to content

Commit

Permalink
Added the --php option to ronin decode (closes #213).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 16, 2024
1 parent 16a30f6 commit db25bef
Show file tree
Hide file tree
Showing 3 changed files with 23 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 @@ -49,6 +49,7 @@ module Commands
# -P, --powershell Encodes the data as a PowerShell String
# --punycode Decodes the data as Punycode
# -Q, --quoted-printable Decodes the data as Quoted Printable
# -p, --php PHP decodes the data
# -R, --ruby Ruby decodes the data
# --uudecode uudecodes the data
# -x, --xml XML decodes the data
Expand Down Expand Up @@ -155,6 +156,12 @@ class Decode < StringMethodsCommand
@method_calls << :quoted_printable_decode
end

option :php, short: '-R',
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
5 changes: 4 additions & 1 deletion man/ronin-decode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ Decodes each character of the given data from a variety of formats.
`-Q`, `--quoted-printable`
: Decodes the data as Quoted Printable.

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

`-R`, `--ruby`
: Ruby decodes 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)
12 changes: 12 additions & 0 deletions spec/cli/commands/decode_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 :php_decode to #method_calls" do
expect(subject.method_calls.last).to eq(:php_decode)
end
end

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

Expand Down

0 comments on commit db25bef

Please sign in to comment.