Skip to content

Commit

Permalink
Added the --nodejs option to ronin unescape (closes #217).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 18, 2024
1 parent ea9ffa5 commit 47c34af
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/unescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Commands
# -u, --uri URI unescapes the data
# --http HTTP unescapes the data
# -j, --js JavaScript unescapes the data
# -n, --nodejs Node.js unescapes the data
# -S, --shell Unescapes the data as a Shell String
# -P, --powershell Unescapes the data as a PowerShell String
# -p, --php Unescapes the data as a PHP String
Expand Down Expand Up @@ -89,6 +90,12 @@ class Unescape < StringMethodsCommand
@method_calls << :js_unescape
end

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

option :shell, short: '-S',
desc: 'Unescapes the data as a Shell String' do
require 'ronin/support/encoding/shell'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-unescape.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Unescapes each escaped character from a variety of encodings.
`-j`, `--js`
: JavaScript unescapes the data.

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

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

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/unescape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,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_unescape to #method_calls" do
expect(subject.method_calls.last).to eq(:node_js_unescape)
end
end

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

Expand Down

0 comments on commit 47c34af

Please sign in to comment.