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 Nov 26, 2024
1 parent 794c55d commit 7561678
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 Decodes the data as a JavaScript string
# -n, --nodejs Decodes the data as a Node.js string
# -S, --shell Decodes the data as a Shell string
# -P, --powershell Decodes the data as a PowerShell string
# --punycode Decodes the data as Punycode
Expand Down Expand Up @@ -136,6 +137,12 @@ class Decode < StringMethodsCommand
@method_calls << :js_decode
end

option :nodejs, short: '-n',
desc: 'Decodes the data as a Node.js string' 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`
: Decodes the data as a Node.js string.

`-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 @@ -132,6 +132,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 7561678

Please sign in to comment.