Skip to content

Commit

Permalink
Added the --sql option for ronin encode (closes #195).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent e716bd2 commit a6d96a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ronin/cli/commands/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module Commands
# -p, --php Encodes the data as a PHP string
# --python Encodes the data as a Python string
# -R, --ruby Encodes the data as a Ruby string
# --sql Encodes the data as a SQL string
# --uuencode uuencodes the data
# -x, --xml XML encodes the data
# -h, --help Print help information
Expand Down Expand Up @@ -203,6 +204,11 @@ class Encode < StringMethodsCommand
@method_calls << :ruby_encode
end

option :sql, desc: 'Encodes the data as a SQL string' do
require 'ronin/support/encoding/sql'
@method_calls << :sql_encode
end

option :uuencode, desc: 'uuencodes the data' do
require 'ronin/support/encoding/uuencoding'
@method_calls << :uuencode
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-encode.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Encodes each character of the given data into a variety of formats.
`-R`, `--ruby`
: Encodes the data as a Ruby string.

`--sql`
: Encodes the data as a SQL string.

`-x`, `--xml`
: XML encodes the data.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_encode to #method_calls" do
expect(subject.method_calls.last).to eq(:sql_encode)
end
end

describe "--xml" do
let(:argv) { %w[--xml] }

Expand Down

0 comments on commit a6d96a3

Please sign in to comment.