Skip to content

Commit ce7c063

Browse files
committed
Added new number options to CLI::PatternOptions (closes #260).
* `--float` -> `Ronin::Support::Text::Patterns::FLOAT`. * `--octal-byte` -> `Ronin::Support::Text::Patterns::OCTAL_BYTE`. * `--decimal-byte` -> `Ronin::Support::Text::Patterns::DECIMAL_BYTE`. * `--hex-byte` -> `Ronin::Support::Text::Patterns::HEX_BYTE`. * `--hex-word` -> `Ronin::Support::Text::Patterns::HEX_WORD`. * `--hex-dword` -> `Ronin::Support::Text::Patterns::HEX_DWORD`. * `--hex-qword` -> `Ronin::Support::Text::Patterns::HEX_QWORD`.
1 parent 7b9e098 commit ce7c063

File tree

6 files changed

+133
-0
lines changed

6 files changed

+133
-0
lines changed

lib/ronin/cli/commands/extract.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ module Commands
3232
# ## Options
3333
#
3434
# -N, --number Searches for all numbers
35+
# --float Searches for all floating point numbers
36+
# --octal-byte Searches for all octal bytes
37+
# --decimal-byte Searches for all decimal bytes
3538
# -X, --hex-number Searches for all hexadecimal numbers
39+
# --hex-byte Searches for all hexadecimal bytes
40+
# --hex-word Searches for all hexadecimal words
41+
# --hex-dword Searches for all hexadecimal double-words
42+
# --hex-qword Searches for all hexadecimal quad-words
3643
# --alpha Searches for all alphabetic characters
3744
# --uppercase Searches for all uppercase alphabetic characters
3845
# --lowercase Searches for all lowercase alphabetic characters

lib/ronin/cli/commands/grep.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ module Commands
3434
# ## Options
3535
#
3636
# -N, --number Searches for all numbers
37+
# --float Searches for all floating point numbers
38+
# --octal-byte Searches for all octal bytes
39+
# --decimal-byte Searches for all decimal bytes
3740
# -X, --hex-number Searches for all hexadecimal numbers
41+
# --hex-byte Searches for all hexadecimal bytes
42+
# --hex-word Searches for all hexadecimal words
43+
# --hex-dword Searches for all hexadecimal double-words
44+
# --hex-qword Searches for all hexadecimal quad-words
3845
# --alpha Searches for all alphabetic characters
3946
# --uppercase Searches for all uppercase alphabetic characters
4047
# --lowercase Searches for all lowercase alphabetic characters

lib/ronin/cli/pattern_options.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ class CLI
2626
# ## Options
2727
#
2828
# -N, --number Searches for all numbers
29+
# --float Searches for all floating point numbers
30+
# --octal-byte Searches for all octal bytes
31+
# --decimal-byte Searches for all decimal bytes
2932
# -X, --hex-number Searches for all hexadecimal numbers
33+
# --hex-byte Searches for all hexadecimal bytes
34+
# --hex-word Searches for all hexadecimal words
35+
# --hex-dword Searches for all hexadecimal double-words
36+
# --hex-qword Searches for all hexadecimal quad-words
3037
# --alpha Searches for all alphabetic characters
3138
# --uppercase Searches for all uppercase alphabetic characters
3239
# --lowercase Searches for all lowercase alphabetic characters
@@ -132,10 +139,38 @@ def self.define_numeric_options(command)
132139
@pattern = NUMBER
133140
end
134141

142+
command.option :float, desc: 'Searches for all floating point numbers' do
143+
@pattern = FLOAT
144+
end
145+
146+
command.option :octal_byte, desc: 'Searches for all octal bytes' do
147+
@pattern = OCTAL_BYTE
148+
end
149+
150+
command.option :decimal_byte, desc: 'Searches for all decimal bytes' do
151+
@pattern = DECIMAL_BYTE
152+
end
153+
135154
command.option :hex_number, short: '-X',
136155
desc: 'Searches for all hexadecimal numbers' do
137156
@pattern = HEX_NUMBER
138157
end
158+
159+
command.option :hex_byte, desc: 'Searches for all hexadecimal bytes' do
160+
@pattern = HEX_BYTE
161+
end
162+
163+
command.option :hex_word, desc: 'Searches for all hexadecimal words' do
164+
@pattern = HEX_WORD
165+
end
166+
167+
command.option :hex_dword, desc: 'Searches for all hexadecimal double-words' do
168+
@pattern = HEX_DWORD
169+
end
170+
171+
command.option :hex_qword, desc: 'Searches for all hexadecimal quad-words' do
172+
@pattern = HEX_QWORD
173+
end
139174
end
140175

141176
#

man/ronin-extract.1.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,30 @@ Extract common patterns in the given file(s) or input stream.
2323
`-N`, `--number`
2424
: Searches for all numbers.
2525

26+
`--float`
27+
: Searches for all floating point numbers.
28+
29+
`--octal-byte`
30+
: Searches for all bytes in octal format.
31+
32+
`--decimal-byte`
33+
: Searches for all bytes in decimal format.
34+
2635
`-X`, `--hex-number`
2736
: Searches for all hexadecimal numbers.
2837

38+
`--hex-byte`
39+
: Searches for all bytes in hexadecimal format.
40+
41+
`--hex-word`
42+
: Searches for all words in hexadecimal format.
43+
44+
`--hex-dword`
45+
: Searches for all double-words in hexadecimal format.
46+
47+
`--hex-qword`
48+
: Searches for all quad-words in hexadecimal format.
49+
2950
`--alpha`
3051
: Searches for all alphabetic characters.
3152

man/ronin-grep.1.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,30 @@ Greps for common patterns in the given file(s) or input stream.
2323
`-N`, `--number`
2424
: Searches for all numbers.
2525

26+
`--float`
27+
: Searches for all floating point numbers.
28+
29+
`--octal-byte`
30+
: Searches for all bytes in octal format.
31+
32+
`--decimal-byte`
33+
: Searches for all bytes in decimal format.
34+
2635
`-X`, `--hex-number`
2736
: Searches for all hexadecimal numbers.
2837

38+
`--hex-byte`
39+
: Searches for all bytes in hexadecimal format.
40+
41+
`--hex-word`
42+
: Searches for all words in hexadecimal format.
43+
44+
`--hex-dword`
45+
: Searches for all double-words in hexadecimal format.
46+
47+
`--hex-qword`
48+
: Searches for all quad-words in hexadecimal format.
49+
2950
`--alpha`
3051
: Searches for all alphabetic characters.
3152

spec/cli/pattern_options_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,48 @@ class TestCommand < Ronin::CLI::Command
2525
expect(subject.options[:number].desc).to eq('Searches for all numbers')
2626
end
2727

28+
it "must define a '--float' option" do
29+
expect(subject.options[:float]).to_not be(nil)
30+
expect(subject.options[:float].short).to be(nil)
31+
expect(subject.options[:float].value).to be(nil)
32+
expect(subject.options[:float].desc).to eq('Searches for all floating point numbers')
33+
end
34+
2835
it "must define a '-X,--hex-number' option" do
2936
expect(subject.options[:hex_number]).to_not be(nil)
3037
expect(subject.options[:hex_number].short).to eq('-X')
3138
expect(subject.options[:hex_number].value).to be(nil)
3239
expect(subject.options[:hex_number].desc).to eq('Searches for all hexadecimal numbers')
3340
end
3441

42+
it "must define a '--hex-byte' option" do
43+
expect(subject.options[:hex_byte]).to_not be(nil)
44+
expect(subject.options[:hex_byte].short).to be(nil)
45+
expect(subject.options[:hex_byte].value).to be(nil)
46+
expect(subject.options[:hex_byte].desc).to eq('Searches for all hexadecimal bytes')
47+
end
48+
49+
it "must define a '--hex-word' option" do
50+
expect(subject.options[:hex_word]).to_not be(nil)
51+
expect(subject.options[:hex_word].short).to be(nil)
52+
expect(subject.options[:hex_word].value).to be(nil)
53+
expect(subject.options[:hex_word].desc).to eq('Searches for all hexadecimal words')
54+
end
55+
56+
it "must define a '--hex-dword' option" do
57+
expect(subject.options[:hex_dword]).to_not be(nil)
58+
expect(subject.options[:hex_dword].short).to be(nil)
59+
expect(subject.options[:hex_dword].value).to be(nil)
60+
expect(subject.options[:hex_dword].desc).to eq('Searches for all hexadecimal double-words')
61+
end
62+
63+
it "must define a '--hex-qword' option" do
64+
expect(subject.options[:hex_qword]).to_not be(nil)
65+
expect(subject.options[:hex_qword].short).to be(nil)
66+
expect(subject.options[:hex_qword].value).to be(nil)
67+
expect(subject.options[:hex_qword].desc).to eq('Searches for all hexadecimal quad-words')
68+
end
69+
3570
it "must define a '--alpha' option" do
3671
expect(subject.options[:alpha]).to_not be(nil)
3772
expect(subject.options[:alpha].short).to be(nil)
@@ -592,8 +627,15 @@ class TestCommand < Ronin::CLI::Command
592627
#
593628
include_context "pattern option", '-N', :NUMBER
594629
include_context "pattern option", '--number', :NUMBER
630+
include_context "pattern option", '--float', :FLOAT
631+
include_context "pattern option", '--octal-byte', :OCTAL_BYTE
632+
include_context "pattern option", '--decimal-byte', :DECIMAL_BYTE
595633
include_context "pattern option", '-X', :HEX_NUMBER
596634
include_context "pattern option", '--hex-number', :HEX_NUMBER
635+
include_context "pattern option", '--hex-byte', :HEX_BYTE
636+
include_context "pattern option", '--hex-word', :HEX_WORD
637+
include_context "pattern option", '--hex-dword', :HEX_DWORD
638+
include_context "pattern option", '--hex-qword', :HEX_QWORD
597639

598640
#
599641
# Language pattern options

0 commit comments

Comments
 (0)