From 5df73f5b1b9a3c5487f013a1a1ae780cf903f2d5 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sat, 17 Aug 2024 18:46:58 -0700 Subject: [PATCH] Added the `--nodejs` option to `ronin decode` (closes #220). --- lib/ronin/cli/commands/decode.rb | 7 +++++++ man/ronin-decode.1.md | 3 +++ spec/cli/commands/decode_spec.rb | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/lib/ronin/cli/commands/decode.rb b/lib/ronin/cli/commands/decode.rb index 245a5427a..fa4d3b198 100644 --- a/lib/ronin/cli/commands/decode.rb +++ b/lib/ronin/cli/commands/decode.rb @@ -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 Node.js decodes the data # -S, --shell Decodes the data as a Shell string # -P, --powershell Decodes the data as a PowerShell string # --punycode Decodes the data as Punycode @@ -136,6 +137,12 @@ class Decode < StringMethodsCommand @method_calls << :js_decode end + option :nodejs, short: '-n', + desc: 'Node.js decodes the data' 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' diff --git a/man/ronin-decode.1.md b/man/ronin-decode.1.md index f3411394a..c7ea008ff 100644 --- a/man/ronin-decode.1.md +++ b/man/ronin-decode.1.md @@ -66,6 +66,9 @@ Decodes each character of the given data from a variety of formats. `-j`, `--js` : JavaScript decodes the data. +`-n`, `--nodejs` +: Node.js decodes the data. + `-S`, `--shell` : Decodes the data as a Shell string. diff --git a/spec/cli/commands/decode_spec.rb b/spec/cli/commands/decode_spec.rb index 296c98368..52c6b5701 100644 --- a/spec/cli/commands/decode_spec.rb +++ b/spec/cli/commands/decode_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_decode to #method_calls" do + expect(subject.method_calls.last).to eq(:node_js_decode) + end + end + describe "--shell" do let(:argv) { %w[--shell] }