From 0b5807bbf959a4b28591a169ae8026f402d3dad2 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sat, 23 Nov 2024 16:02:58 -0800 Subject: [PATCH] Added the `--sql` option to `ronin decode` (closes #194). --- lib/ronin/cli/commands/decode.rb | 6 ++++++ man/ronin-decode.1.md | 3 +++ spec/cli/commands/decode_spec.rb | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/lib/ronin/cli/commands/decode.rb b/lib/ronin/cli/commands/decode.rb index 4074aa1d3..9bac02d48 100644 --- a/lib/ronin/cli/commands/decode.rb +++ b/lib/ronin/cli/commands/decode.rb @@ -56,6 +56,7 @@ module Commands # -p, --php Decodes the data as a PHP string # --python Decodes the data as a Python string # -R, --ruby Decodes the data as a Ruby string + # --sql Decodes the data as a SQL string # --uudecode uudecodes the data # -x, --xml XML decodes the data # -h, --help Print help information @@ -203,6 +204,11 @@ class Decode < StringMethodsCommand @method_calls << :ruby_decode end + option :sql, desc: 'Decodes the data as a SQL string' do + require 'ronin/support/encoding/sql' + @method_calls << :sql_decode + end + option :uudecode, desc: 'uudecodes the data' do require 'ronin/support/encoding/uuencoding' @method_calls << :uudecode diff --git a/man/ronin-decode.1.md b/man/ronin-decode.1.md index 3d653a870..0f5633e13 100644 --- a/man/ronin-decode.1.md +++ b/man/ronin-decode.1.md @@ -102,6 +102,9 @@ Decodes each character of the given data from a variety of formats. `--uudecode` : uudecodes the data. +`--sql` +: Decodes the data as a SQL string. + `-x`, `--xml` : XML decodes the data. diff --git a/spec/cli/commands/decode_spec.rb b/spec/cli/commands/decode_spec.rb index 877536a79..4b91c5678 100644 --- a/spec/cli/commands/decode_spec.rb +++ b/spec/cli/commands/decode_spec.rb @@ -264,6 +264,18 @@ end end + describe "--sql" do + let(:argv) { %w[--sql] } + + it "must require 'ronin/support/encoding/sql'" do + expect(require('ronin/support/encoding/sql')).to be(false) + end + + it "must add :sql_decode to #method_calls" do + expect(subject.method_calls.last).to eq(:sql_decode) + end + end + describe "--xml" do let(:argv) { %w[--xml] }