diff --git a/lib/ronin/cli/commands/encode.rb b/lib/ronin/cli/commands/encode.rb index 45dc4d225..c0a59400f 100644 --- a/lib/ronin/cli/commands/encode.rb +++ b/lib/ronin/cli/commands/encode.rb @@ -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 Node.js encodes the data # -S, --shell Encodes the data as a Shell string # -P, --powershell Encodes the data as a PowerShell string # --punycode Encodes the data as Punycode @@ -136,6 +137,12 @@ class Encode < StringMethodsCommand @method_calls << :js_encode end + option :nodejs, short: '-n', + desc: 'Node.js encodes the data' 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' diff --git a/man/ronin-encode.1.md b/man/ronin-encode.1.md index 87aac02f8..5662d4912 100644 --- a/man/ronin-encode.1.md +++ b/man/ronin-encode.1.md @@ -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` +: Node.js encodes the data. + `-S`, `--shell` : Encodes the data as a Shell string. diff --git a/spec/cli/commands/encode_spec.rb b/spec/cli/commands/encode_spec.rb index d2a98ae7c..ea59886ef 100644 --- a/spec/cli/commands/encode_spec.rb +++ b/spec/cli/commands/encode_spec.rb @@ -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] }