Skip to content

Commit

Permalink
Added the --nodejs option to ronin decode (closes #220).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 18, 2024
1 parent 29dc7d4 commit 5b42d16
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 @@ -45,6 +45,7 @@ module Commands
# -u, --uri URI decodes the data
# --http HTTP 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
# -P, --powershell Encodes the data as a PowerShell String
# --punycode Decodes the data as Punycode
Expand Down Expand Up @@ -133,6 +134,12 @@ class Decode < StringMethodsCommand
@method_calls << :js_decode
end

option :nodejs, short: '-n',
desc: 'Node.js decodes the data' do
require 'ronin/support/encoding/node_js'
@method_calls << :node_js_decode
end

option :shell, short: '-S',
desc: 'Decodes the data as a Shell String' do
require 'ronin/support/encoding/shell'
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 @@ -66,6 +66,9 @@ Decodes each character of the given data from a variety of formats.
`-j`, `--js`
: JavaScript decodes the data.

`-n`, `--nodejs`
: Node.js decodes the data.

`-S`, `--shell`
: Decodes the data as a Shell String.

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 @@ -104,6 +104,18 @@
end
end

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

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

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

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

Expand Down

0 comments on commit 5b42d16

Please sign in to comment.