-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbofk-cli.rb
120 lines (85 loc) · 2.23 KB
/
bofk-cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env ruby
=begin
pattern create
pattern offset
endian little character converter
hex2bin
bin2hex
=end
APP_ROOT = Dir.pwd
ROOT = $:.unshift(File.join(APP_ROOT, "bin"))
LIB = "#{APP_ROOT}/lib"
OUT = "#{APP_ROOT}/out"
require 'pry'
require 'pattern'
require 'hex2lendian'
require 'hex2bin'
require 'optparse'
require 'pp'
options = {}
optparse = OptionParser.new do|opts|
#--> Pattern create
opts.on('-c' , '--pattern-create LENGTH', "Create Unique pattern string") do |c|
options[:create] = c
end
#--> Pattern offset
opts.on('-o', '--pattern-offset OFFSET', "Find Pattern offset string.") do |o|
options[:offset] = o
end
#--> Hex to little endian characters converter
opts.on('-e', '--hex2lend OPCODE', "Convert Hex to little endian characters.") do |h2le|
options[:hex2endl] = h2le
end
#--> Hex to bin
opts.on('-b', '--hex2bin ', "Convert Hex shellcode to binary file.") do |h2b|
options[:hex2bin] = h2b
end
#--> bin to Hex
opts.on('-x', '--bin2hex', "Convert binary shellcode to Hex string.") do |bin2hex|
options[:bin2hex] = bin2hex
end
#--> Display the help screen
opts.banner = "Usage:\n" +
"ruby bofk-cli.rb --pattern-create 500\n" +
"ruby bofk-cli.rb --pattern-offset 5F343D3E\n" +
"ruby bofk-cli.rb --hex2endl 0x41F2E377\n" +
"ruby bofk-cli.rb --hex2bin input.txt output.bin\n" +
"ruby bofk-cli.rb --bin2hex input.bin output.txt\n\n"
opts.on( '-h', '--help', "Display this screen \n" ) do
puts opts
exit
end
end
optparse.parse!
options
ARGV
@pattern = Pattern.new
@hex2bin = Hex2Bin.new()
case
#--> Pattern create
when options[:create]
then
puts @pattern.create(options[:create])
#--> Pattern offset
when options[:offset]
then
puts @pattern.offset(options[:offset]) # TODO: make offset can take 2 ARGS
#--> Hex to little endian characters converter
when options[:hex2endl]
then
@hex2lendian = Hex2littleEndian.new(options[:hex2endl])
puts @hex2lendian.to_Lendian
#--> Hex to bin
when options[:hex2bin]
then
#ss = gets
#@hex2bin.shellcode(gets.chomp)
@hex2bin.shellcode(options[:hex2bin])
@hex2bin.to_bin
#--> bin to Hex
when options[:bin2hex]
then
puts "bin2hex : to be solved"
else
puts "WTF!!!"
end