Skip to content

Commit

Permalink
Enhance outputs - colorize
Browse files Browse the repository at this point in the history
  • Loading branch information
KINGSABRI committed Jan 31, 2013
1 parent 9534589 commit 72ce771
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions bofk-cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@
=end

APP_ROOT = Dir.pwd
GEMS = $:.unshift File.join(APP_ROOT,'gems')
ROOT = $:.unshift(File.join(APP_ROOT, "lib"))
BIN = "#{APP_ROOT}/bin"
OUT = "#{APP_ROOT}/out"


require 'pry'
require 'colorize'
require 'pattern'
require 'hex2lendian'
require 'hex2bin'
require 'bin2hex'
require 'optparse'
require 'pp'
require 'utils'

$titlef = "---[ ".light_blue
$plusG = "[+] ".green

options = {}

Expand All @@ -39,7 +44,7 @@
options[:hex2endl] = h2le
end
#--> Hex to bin
opts.on('-b', '--hex2bin ', "Convert Hex shellcode to binary file.") do |h2b|
opts.on('-b', '--hex2bin RAW', "Convert Hex shellcode to binary file.") do |h2b|
options[:hex2bin] = h2b
end
#--> bin to Hex
Expand All @@ -52,9 +57,9 @@
"ruby bofk-cli.rb --pattern-offset Aa4Z\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\n\n"
"ruby bofk-cli.rb --bin2hex input.bin output.txt\n\n"

opts.on( '-h', '--help', "Display this screen \n" ) do
opts.on( '-h', '--help', "Display this screen \n" ) do
puts opts
exit
end
Expand All @@ -64,21 +69,32 @@
ARGV


util_etc = BofKUtils::Etc.new

@pattern = Pattern.new
@hex2bin = Hex2Bin.new()
@hex2bin = Hex2Bin.new
@bin2hex = Bin2Hex.new

case

#--> Pattern create
when options[:create]
then
puts @pattern.create(options[:create])
decor = util_etc.decorate("Pattern create")
puts "#{decor[:head]}".light_blue + "#{decor[:title]}".white + "#{decor[:tail]}".light_blue
puts "[+] ".green + "Size: #{@pattern.create(options[:create]).size}\n".white.underline
puts "#{@pattern.create(options[:create])}".light_cyan
puts "#{decor[:end]}".light_blue
puts ""

#--> Pattern offset
when options[:offset]
then
puts @pattern.offset(options[:offset]) # TODO: make offset can take 2 ARGS
decor = util_etc.decorate("Pattern offset")
puts "#{decor[:head]}".light_blue + "#{decor[:title]}".white + "#{decor[:tail]}".light_blue
puts "#{@pattern.offset(options[:offset])}".light_cyan # TODO: make offset can take 2 ARGS
puts "#{decor[:end]}".light_blue
puts ""

#--> Hex to little endian characters converter
when options[:hex2endl]
Expand All @@ -89,17 +105,25 @@
#--> Hex to bin
when options[:hex2bin]
then
decor = util_etc.decorate("Hex to Binary")
puts "#{decor[:head]}".light_blue + "#{decor[:title]}".white + "#{decor[:tail]}".light_blue
p options[:hex2bin]
@hex2bin.shellcode(options[:hex2bin])
@hex2bin.to_bin
puts "#{decor[:end]}".light_blue
puts ""

#--> bin to Hex
when options[:bin2hex]
then
puts "\n\n"
@bin2hex.read(options[:bin2hex])
puts @bin2hex.to_hex
puts "\n\n"
decor = util_etc.decorate("Binary to Hex")
puts "#{decor[:head]}".light_blue + "#{decor[:title]}".white + "#{decor[:tail]}".light_blue
@bin2hex.read(options[:bin2hex])
puts "[+] ".green + "File Size: #{File.size(options[:bin2hex])} byte.\n".white.underline
puts @bin2hex.to_hex
puts "#{decor[:end]}".light_blue
puts ""

else
puts "WTF!!!"
end
Expand Down

0 comments on commit 72ce771

Please sign in to comment.