Skip to content

Commit

Permalink
Added the --java option to ronin decode (closes #236).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 0ef22b5 commit 83e8ea1
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/decode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Commands
# -H, --html HTML decodes the data
# -u, --uri URI decodes the data
# --http HTTP decodes the data
# -J, --java Java decodes the data
# -j, --js JavaScript decodes the data
# -n, --nodejs Node.js decodes the data
# -S, --shell Encodes the data as a Shell String
Expand Down Expand Up @@ -130,6 +131,12 @@ class Decode < StringMethodsCommand
@method_calls << :http_decode
end

option :java, short: '-J',
desc: 'Java decodes the data' do
require 'ronin/support/encoding/java'
@method_calls << :java_decode
end

option :js, short: '-j',
desc: 'JavaScript decodes the data' do
require 'ronin/support/encoding/js'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-decode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Decodes each character of the given data from a variety of formats.
`--http`
: HTTP decodes the data.

`-J`, `--java`
: Java decodes the data.

`-j`, `--js`
: JavaScript decodes the data.

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

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

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

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

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

Expand Down

0 comments on commit 83e8ea1

Please sign in to comment.