Module: Xploit::Pack
- Defined in:
- lib/xploit/util.rb
Constant Summary collapse
- PACK_HASH =
{ byte: ['c', 1], ubyte: ['C', 1], word: ['s', 2], uword: ['S', 2], dword: ['l', 4], udword: ['L', 4], qword: ['q', 8], uqword: ['Q', 8] }
Instance Method Summary collapse
- #p16(*data) ⇒ Object
- #p32(*data) ⇒ Object
- #p64(*data) ⇒ Object
- #p8(*data) ⇒ Object
- #pack(data, type) ⇒ Object
- #pi16(*data) ⇒ Object
- #pi32(*data) ⇒ Object
- #pi64(*data) ⇒ Object
- #pi8(*data) ⇒ Object
- #u16(*data) ⇒ Object
- #u32(*data) ⇒ Object
- #u64(*data) ⇒ Object
- #u8(*data) ⇒ Object
- #ui16(*data) ⇒ Object
- #ui32(*data) ⇒ Object
- #ui64(*data) ⇒ Object
- #ui8(*data) ⇒ Object
- #unpack(data, type) ⇒ Object
Instance Method Details
#p16(*data) ⇒ Object
26 27 28 |
# File 'lib/xploit/util.rb', line 26 def p16(*data) pack(data, :uword) end |
#p32(*data) ⇒ Object
34 35 36 |
# File 'lib/xploit/util.rb', line 34 def p32(*data) pack(data, :udword) end |
#p64(*data) ⇒ Object
42 43 44 |
# File 'lib/xploit/util.rb', line 42 def p64(*data) pack(data, :uqword) end |
#p8(*data) ⇒ Object
18 19 20 |
# File 'lib/xploit/util.rb', line 18 def p8(*data) pack(data, :ubyte) end |
#pack(data, type) ⇒ Object
82 83 84 |
# File 'lib/xploit/util.rb', line 82 def pack(data, type) data.flatten.pack("#{PACK_HASH[type][0]}*") end |
#pi16(*data) ⇒ Object
30 31 32 |
# File 'lib/xploit/util.rb', line 30 def pi16(*data) pack(data, :word) end |
#pi32(*data) ⇒ Object
38 39 40 |
# File 'lib/xploit/util.rb', line 38 def pi32(*data) pack(data, :dword) end |
#pi64(*data) ⇒ Object
46 47 48 |
# File 'lib/xploit/util.rb', line 46 def pi64(*data) pack(data, :qword) end |
#pi8(*data) ⇒ Object
22 23 24 |
# File 'lib/xploit/util.rb', line 22 def pi8(*data) pack(data, :byte) end |
#u16(*data) ⇒ Object
58 59 60 |
# File 'lib/xploit/util.rb', line 58 def u16(*data) unpack(data, :uword) end |
#u32(*data) ⇒ Object
66 67 68 |
# File 'lib/xploit/util.rb', line 66 def u32(*data) unpack(data, :udword) end |
#u64(*data) ⇒ Object
74 75 76 |
# File 'lib/xploit/util.rb', line 74 def u64(*data) unpack(data, :uqword) end |
#u8(*data) ⇒ Object
50 51 52 |
# File 'lib/xploit/util.rb', line 50 def u8(*data) unpack(data, :ubyte) end |
#ui16(*data) ⇒ Object
62 63 64 |
# File 'lib/xploit/util.rb', line 62 def ui16(*data) unpack(data, :word) end |
#ui32(*data) ⇒ Object
70 71 72 |
# File 'lib/xploit/util.rb', line 70 def ui32(*data) unpack(data, :dword) end |
#ui64(*data) ⇒ Object
78 79 80 |
# File 'lib/xploit/util.rb', line 78 def ui64(*data) unpack(data, :qword) end |
#ui8(*data) ⇒ Object
54 55 56 |
# File 'lib/xploit/util.rb', line 54 def ui8(*data) unpack(data, :byte) end |
#unpack(data, type) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/xploit/util.rb', line 86 def unpack(data, type) tempchar, tempbyte = PACK_HASH[type] data = data.flatten.map do |d| unless (pad_size = d.bytesize % tempbyte) == 0 pad_size = d.bytesize + tempbyte - (d.bytesize % tempbyte) end d.ljust(pad_size, "\x00").unpack("#{tempchar}*") end data.flatten end |