Skip to content

Commit

Permalink
Added the --nodejs option to ronin escape (closes #218).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 1890405 commit 62f48d5
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/escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Commands
# -u, --uri URI escapes the data
# --http HTTP escapes the data
# -j, --js Encodes the data as a JavaScript string
# -n, --nodejs Escapes the data as a Node.js string
# -S, --shell Escapes the data as a Shell string
# -P, --powershell Escapes the data as a PowerShell string
# -Q, --quoted-printable Escapes the data as Quoted Printable
Expand Down Expand Up @@ -89,6 +90,12 @@ class Escape < StringMethodsCommand
@method_calls << :js_escape
end

option :nodejs, short: '-n',
desc: 'Escapes the data as a Node.js string' do
require 'ronin/support/encoding/node_js'
@method_calls << :node_js_escape
end

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

`-n`, `--nodejs`
: Escapes the data as a Node.js string.

`-S`, `--shell`
: Escapes the data as a Shell string.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/escape_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_escape to #method_calls" do
expect(subject.method_calls.last).to eq(:node_js_escape)
end
end

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

Expand Down

0 comments on commit 62f48d5

Please sign in to comment.