From 6060003b7f27114be147ef26fe6d467192fa65ed Mon Sep 17 00:00:00 2001 From: Postmodern Date: Fri, 22 Nov 2024 21:57:39 -0800 Subject: [PATCH] Added the `--java` option to `ronin unquote` (closes #244). --- lib/ronin/cli/commands/unquote.rb | 7 +++++++ man/ronin-unquote.1.md | 3 +++ spec/cli/commands/unquote_spec.rb | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/lib/ronin/cli/commands/unquote.rb b/lib/ronin/cli/commands/unquote.rb index 8110432a4..ffefce203 100644 --- a/lib/ronin/cli/commands/unquote.rb +++ b/lib/ronin/cli/commands/unquote.rb @@ -36,6 +36,7 @@ module Commands # -n, --keep-newlines Preserves newlines at the end of each line # -X, --hex Unquotes the Hex string # -c, --c Unquotes the C string + # -J, --java Unquotes the Java String # -j, --js Unquotes the JavaScript String # -S, --shell Unquotes the Shell String # -P, --powershell Unquotes the PowerShell String @@ -62,6 +63,12 @@ class Unquote < StringMethodsCommand @method_calls << :c_unquote end + option :java, short: '-J', + desc: 'Unquotes the Java String' do + require 'ronin/support/encoding/java' + @method_calls << :java_unquote + end + option :js, short: '-j', desc: 'Unquotes the JavaScript String' do require 'ronin/support/encoding/js' diff --git a/man/ronin-unquote.1.md b/man/ronin-unquote.1.md index 2c8505c8f..2c111ab7a 100644 --- a/man/ronin-unquote.1.md +++ b/man/ronin-unquote.1.md @@ -38,6 +38,9 @@ Unquotes a double/single quoted string. `-c`, `--c` : Unquotes the C string. +`-J`, `--java` +: Unquotes the Java String. + `-j`, `--js` : Unquotes the JavaScript String. diff --git a/spec/cli/commands/unquote_spec.rb b/spec/cli/commands/unquote_spec.rb index dbebdf51c..55809e18d 100644 --- a/spec/cli/commands/unquote_spec.rb +++ b/spec/cli/commands/unquote_spec.rb @@ -32,6 +32,18 @@ end end + describe "--java" do + let(:argv) { %w[--java] } + + it "must require 'ronin/support/encoding/java'" do + expect(require('ronin/support/encoding/java')).to be(false) + end + + it "must add :java_unquote to #method_calls" do + expect(subject.method_calls.last).to eq(:java_unquote) + end + end + describe "--js" do let(:argv) { %w[--js] }