-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
| ||
|
||
class Hex2Bin | ||
|
||
def initialize () | ||
@file = "out.bin" | ||
end | ||
|
||
begin | ||
def shellcode(shellcode) | ||
@shellcode = shellcode #gets | ||
end | ||
|
||
def to_bin(file = @file) | ||
File.open(@file , 'wb') do |f| | ||
f.print @shellcode | ||
sleep 0.2 | ||
end | ||
puts " File name: " + "#{@file}" | ||
puts " Shellcode length: " + "#{File.size(@file)}" + " bytes." | ||
puts " Done" + "!" | ||
end | ||
rescue | ||
puts "[!]" + "Error!\n" + "Usage:\n" + | ||
" Put your shellcode hexs in shellcode variable (Hardcode). then exectue.\n" + | ||
"ruby hex2bin.rb [output.bin]\n\n" | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# \xdb\xc1\xbe\x8e\x0c\xae\x5a\xd9\x74\x24\xf4\x5f\x33\xc9\xb1\x56\x83\xc7\x04\x31\x77\x14\x03\x77\x9a\xee\x5b\xa6\x4a\x67\xa3\x57\x8a\x18\x2d\xb2\xbb\x0a\x49\xb6\xe9\x9a\x19\x9a\x01\x50\x4f\x0f\x92\x14\x58\x20\x13\x92\xbe\x0f\xa4\x12\x7f\xc3\x66\x34\x03\x1e\xba\x96\x3a\xd1\xcf\xd7\x7b\x0c\x3f\x85\xd4\x5a\xed\x3a\x50\x1e\x2d\x3a\xb6\x14\x0d\x44\xb3\xeb\xf9\xfe\xba\x3b\x51\x74\xf4\xa3\xda\xd2\x25\xd5\x0f\x01\x19\x9c\x24\xf2\xe9\x1f\xec\xca\x12\x2e\xd0\x81\x2c\x9e\xdd\xd8\x69\x19\x3d\xaf\x81\x59\xc0\xa8\x51\x23\x1e\x3c\x44\x83\xd5\xe6\xac\x35\x3a\x70\x26\x39\xf7\xf6\x60\x5e\x06\xda\x1a\x5a\x83\xdd\xcc\xea\xd7\xf9\xc8\xb7\x8c\x60\x48\x12\x63\x9c\x8a\xfa\xdc\x38\xc0\xe9\x09\x3a\x8b\x65\xfe\x71\x34\x76\x68\x01\x47\x44\x37\xb9\xcf\xe4\xb0\x67\x17\x0a\xeb\xd0\x87\xf5\x13\x21\x81\x31\x47\x71\xb9\x90\xe7\x1a\x39\x1c\x32\x8c\x69\xb2\xec\x6d\xda\x72\x5c\x06\x30\x7d\x83\x36\x3b\x57\xb2\x70\xf5\x83\x97\x16\xf4\x33\x02\x54\x71\xd5\x46\x8a\xd4\x4d\xfe\x68\x03\x46\x99\x93\x61\xfa\x32\x04\x3d\x14\x84\x2b\xbe\x32\xa7\x80\x16\xd5\x33\xcb\xa2\xc4\x44\xc6\x82\x8f\x7d\x81\x59\xfe\xcc\x33\x5d\x2b\xa6\xd0\xcc\xb0\x36\x9e\xec\x6e\x61\xf7\xc3\x66\xe7\xe5\x7a\xd1\x15\xf4\x1b\x1a\x9d\x23\xd8\xa5\x1c\xa1\x64\x82\x0e\x7f\x64\x8e\x7a\x2f\x33\x58\xd4\x89\xed\x2a\x8e\x43\x41\xe5\x46\x15\xa9\x36\x10\x1a\xe4\xc0\xfc\xab\x51\x95\x03\x03\x36\x11\x7c\x79\xa6\xde\x57\x39\xd6\x94\xf5\x68\x7f\x71\x6c\x29\xe2\x82\x5b\x6e\x1b\x01\x69\x0f\xd8\x19\x18\x0a\xa4\x9d\xf1\x66\xb5\x4b\xf5\xd5\xb6\x59 | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
|
||
class Hex2Bin | ||
|
||
def initialize () | ||
@file = "out.bin" | ||
@shellcode = "" | ||
end | ||
|
||
begin | ||
def shellcode(shellcode) | ||
@shellcode = shellcode | ||
end | ||
|
||
# Sanitization | ||
def self.sanitize (string) | ||
string.scan(/[(\\x|\\\\x)x]/i) # [\\][\\\\]*x | ||
if string.include?("x") | ||
string.gsub(/[(\\x|\\\\x)x]/,'\x') # Sanitize "xdbxc1xbex8e" format to "\xdb\xc1\xbe\x8e" | ||
end | ||
|
||
#puts string.include?('\x') | ||
#if string.include?('.*x') | ||
##string.gsub('\\x', '\x') | ||
#end | ||
|
||
end | ||
|
||
def to_bin(file = @file) | ||
puts "\n\n\nbefore-----------------------\n" | ||
p @shellcode | ||
|
||
puts "\n\nafter------------------------\n" | ||
@shellcode = sanitize(@shellcode) | ||
p @shellcode | ||
|
||
#exit | ||
|
||
|
||
File.open(file = @file, 'wb') do |f| | ||
f.print @shellcode | ||
#sleep 0.1 | ||
end | ||
puts " File name: " + "#{@file}" | ||
puts " File size: " + "#{File.size(@file)}" + " bytes." | ||
puts "Shellcode length " + "#{@shellcode.size}" | ||
puts " Done" + "!" | ||
end | ||
|
||
rescue | ||
puts "[!]" + "Error!\n" + "Usage:\n" + | ||
" Put your shellcode hexs in shellcode variable (Hardcode). then exectue.\n" + | ||
"ruby hex2bin.rb [output.bin]\n\n" | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
# \xdb\xc1\xbe\x8e\x0c\xae\x5a\xd9\x74\x24\xf4\x5f\x33\xc9\xb1\x56\x83\xc7\x04\x31\x77\x14\x03\x77\x9a\xee\x5b\xa6\x4a\x67\xa3\x57\x8a\x18\x2d\xb2\xbb\x0a\x49\xb6\xe9\x9a\x19\x9a\x01\x50\x4f\x0f\x92\x14\x58\x20\x13\x92\xbe\x0f\xa4\x12\x7f\xc3\x66\x34\x03\x1e\xba\x96\x3a\xd1\xcf\xd7\x7b\x0c\x3f\x85\xd4\x5a\xed\x3a\x50\x1e\x2d\x3a\xb6\x14\x0d\x44\xb3\xeb\xf9\xfe\xba\x3b\x51\x74\xf4\xa3\xda\xd2\x25\xd5\x0f\x01\x19\x9c\x24\xf2\xe9\x1f\xec\xca\x12\x2e\xd0\x81\x2c\x9e\xdd\xd8\x69\x19\x3d\xaf\x81\x59\xc0\xa8\x51\x23\x1e\x3c\x44\x83\xd5\xe6\xac\x35\x3a\x70\x26\x39\xf7\xf6\x60\x5e\x06\xda\x1a\x5a\x83\xdd\xcc\xea\xd7\xf9\xc8\xb7\x8c\x60\x48\x12\x63\x9c\x8a\xfa\xdc\x38\xc0\xe9\x09\x3a\x8b\x65\xfe\x71\x34\x76\x68\x01\x47\x44\x37\xb9\xcf\xe4\xb0\x67\x17\x0a\xeb\xd0\x87\xf5\x13\x21\x81\x31\x47\x71\xb9\x90\xe7\x1a\x39\x1c\x32\x8c\x69\xb2\xec\x6d\xda\x72\x5c\x06\x30\x7d\x83\x36\x3b\x57\xb2\x70\xf5\x83\x97\x16\xf4\x33\x02\x54\x71\xd5\x46\x8a\xd4\x4d\xfe\x68\x03\x46\x99\x93\x61\xfa\x32\x04\x3d\x14\x84\x2b\xbe\x32\xa7\x80\x16\xd5\x33\xcb\xa2\xc4\x44\xc6\x82\x8f\x7d\x81\x59\xfe\xcc\x33\x5d\x2b\xa6\xd0\xcc\xb0\x36\x9e\xec\x6e\x61\xf7\xc3\x66\xe7\xe5\x7a\xd1\x15\xf4\x1b\x1a\x9d\x23\xd8\xa5\x1c\xa1\x64\x82\x0e\x7f\x64\x8e\x7a\x2f\x33\x58\xd4\x89\xed\x2a\x8e\x43\x41\xe5\x46\x15\xa9\x36\x10\x1a\xe4\xc0\xfc\xab\x51\x95\x03\x03\x36\x11\x7c\x79\xa6\xde\x57\x39\xd6\x94\xf5\x68\x7f\x71\x6c\x29\xe2\x82\x5b\x6e\x1b\x01\x69\x0f\xd8\x19\x18\x0a\xa4\x9d\xf1\x66\xb5\x4b\xf5\xd5\xb6\x59 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env ruby | ||
# | ||
# Small script to convert opcode to little endian format, like ex. from \x41\x42\x43\x44 or 0x41424344 to \x44\x43\x42\x41 | ||
# usage: | ||
# ruby hex2lendian.rb \x41\x42\x43\x44 | ||
# Coded by: KING SABRI | ||
# | ||
|
||
class Hex2littleEndian | ||
|
||
def initialize(string) | ||
@string = string | ||
@endian_ar = [] | ||
@endian_final = '' | ||
end | ||
|
||
begin | ||
# Sanitization | ||
def sanitize (string) | ||
case | ||
when string.include?('0x') #== false | ||
then | ||
string.gsub(/0x/, "") # Sanitize "0x77d6b141" format | ||
when string.include?("x") | ||
then | ||
string.gsub(/x/, "") # Sanitize "\x77\xd6\xb1\x41" format | ||
end | ||
end | ||
|
||
|
||
def to_Lendian | ||
str_sanitized = sanitize(@string) | ||
str_sanitized_ar = str_sanitized.scan(/.{2}/) | ||
|
||
# Convert string to little endian characters | ||
str_sanitized_ar.reverse.each do |bit| | ||
@endian_ar << bit | ||
end | ||
|
||
# Add \x to be ready for shellcode | ||
@endian_ar.each do |bit| | ||
@endian_final << '\x' + bit | ||
end | ||
|
||
return @endian_final | ||
end | ||
|
||
rescue | ||
puts "[!] " + "Error!\n" + "Usage:\n" + | ||
'ruby hex2lendian.rb \x41\x42\x43\x44' + "\n" + | ||
"ruby hex2lendian.rb 0x41424344\n\n" | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env ruby | ||
|
||
|
||
class Pattern | ||
|
||
def initialize | ||
|
||
@pattern = [] | ||
@offset = String | ||
|
||
end | ||
|
||
|
||
def create(length) | ||
if length != 0 or nil | ||
#@pattern = ('Aa0A'..'Zz9Z').to_a.first(length) # default values 175735 * 4 | ||
@pattern = ('Aa0A'..'Zz9Z').to_a.join.each_char.first(length.to_i).join # default value 702940 | ||
else | ||
puts "\n[+] Error!: --pattern-create accepts INTEGER and > 0 values only!" | ||
puts "Usage: --pattern-create [VALUE]\n\n" | ||
length = 0 | ||
end | ||
|
||
return @pattern | ||
end | ||
|
||
|
||
def offset(string , length = 10000) | ||
@pattern = ('Aa0A'..'Zz9Z').to_a.first(length.to_i).join # default values 175735 * 4 | ||
@offset = @pattern.index(string.to_s) | ||
if @offset.nil? | ||
puts "\n[+] Error!: Your pattern is wrong or too long, plz mention it!" | ||
puts "Usage: --pattern-offset #{string} Pattern_Size" | ||
puts "ex. bofk-cli.rb --pattern-offset PAa6 20000\n\n" | ||
# exit 1 | ||
end | ||
|
||
return @offset | ||
end | ||
|
||
end | ||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ruby bofk-cli.rb -h | ||
|
||
ruby bofk-cli.rb --pattern-create 200 | ||
|
||
ruby bofk-cli.rb --pattern-offset Aa1V | ||
|
||
ruby bofk-cli.rb --hex2lend 0x41424344 | ||
|
||
ruby bofk-cli.rb --hex2lend \x41\x42\x43\x44 | ||
|
||
|
||
|