From 6605870172607ec0ad5b337afe44c49e2d0658cf Mon Sep 17 00:00:00 2001 From: Postmodern Date: Fri, 22 Nov 2024 18:07:13 -0800 Subject: [PATCH] Added the `--php` option to `ronin unquote` (closes #242). --- 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 e9b068bf6..39ceff423 100644 --- a/lib/ronin/cli/commands/unquote.rb +++ b/lib/ronin/cli/commands/unquote.rb @@ -39,6 +39,7 @@ module Commands # -j, --js Unquotes the JavaScript String # -S, --shell Unquotes the Shell String # -P, --powershell Unquotes the PowerShell String + # -p, --php Unquotes the PHP String # --python Unquotes the PowerShell String # -R, --ruby Unquotes the Ruby String # -h, --help Print help information @@ -79,6 +80,12 @@ class Unquote < StringMethodsCommand @method_calls << :powershell_unquote end + option :php, short: '-p', + desc: 'Unquotes the PHP String' do + require 'ronin/support/encoding/php' + @method_calls << :php_unquote + end + option :python, desc: 'Unquotes the PowerShell String' do require 'ronin/support/encoding/python' @method_calls << :python_unquote diff --git a/man/ronin-unquote.1.md b/man/ronin-unquote.1.md index c3ee9fc13..faa80e72b 100644 --- a/man/ronin-unquote.1.md +++ b/man/ronin-unquote.1.md @@ -47,6 +47,9 @@ Unquotes a double/single quoted string. `-P`, `--powershell` : Unquotes the PowerShell String. +`-p`, `--php` +: Unquotes the PHP String. + `--python` : Unquotes the Python String. diff --git a/spec/cli/commands/unquote_spec.rb b/spec/cli/commands/unquote_spec.rb index 5b78ffd0f..5a20373f0 100644 --- a/spec/cli/commands/unquote_spec.rb +++ b/spec/cli/commands/unquote_spec.rb @@ -68,6 +68,18 @@ end end + describe "--php" do + let(:argv) { %w[--php] } + + it "must require 'ronin/support/encoding/php'" do + expect(require('ronin/support/encoding/php')).to be(false) + end + + it "must add :php_unquote to #method_calls" do + expect(subject.method_calls.last).to eq(:php_unquote) + end + end + describe "--python" do let(:argv) { %w[--python] }