Skip to content

Commit

Permalink
Added the --nodejs option to ronin encode (closes #219).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 26, 2024
1 parent f296171 commit 794c55d
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/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Commands
# -u, --uri URI encodes the data
# --http HTTP encodes the data
# -j, --js Encodes the data as a JavaScript string
# -n, --nodejs Encodes the data as a Node.js string
# -S, --shell Encodes the data as a Shell string
# -P, --powershell Encodes the data as a PowerShell string
# --punycode Encodes the data as Punycode
Expand Down Expand Up @@ -136,6 +137,12 @@ class Encode < StringMethodsCommand
@method_calls << :js_encode
end

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

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

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

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

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

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

Expand Down

0 comments on commit 794c55d

Please sign in to comment.