Module: Pwnlib::Shellcraft::Registers
- Included in:
- Generators::Helper::Runner
- Defined in:
- lib/pwnlib/shellcraft/registers.rb
Overview
Define register names and methods for shellcode generators.
Defined Under Namespace
Classes: Register
Constant Summary collapse
- X86_BASEREGS =
%w(ax cx dx bx sp bp si di ip).freeze
- I386 =
(X86_BASEREGS.map { |r| "e#{r}" } + X86_BASEREGS + %w(eflags cs ss ds es fs gs)).freeze
- AMD64 =
(X86_BASEREGS.map { |r| "r#{r}" } + (8..15).map { |r| "r#{r}" } + (8..15).map { |r| "r#{r}d" } + I386).freeze
- X86_ORDERED =
x86 registers in decreasing size
([ %w(rax eax ax al), %w(rbx ebx bx bl), %w(rcx ecx cx cl), %w(rdx edx dx dl), %w(rdi edi di), %w(rsi esi si), %w(rbp ebp bp), %w(rsp esp sp) ] + (8..15).map { |r| ['', 'd', 'w', 'b'].map { |t| "r#{r}#{t}" } }).freeze
- INTEL =
(X86_ORDERED.each_with_object({}) do |row, obj| row.each_with_index do |reg, i| obj[reg] = Register.new(reg, 64 >> i) end end).freeze
Class Method Summary collapse
- .bits_required(value) ⇒ Object
-
.get_register(name) ⇒ Register?
Get a Register object by name.
- .register?(obj) ⇒ Boolean
- .registers ⇒ Object
Class Method Details
.bits_required(value) ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/pwnlib/shellcraft/registers.rb', line 135 def bits_required(value) bits = 0 value = value.abs while value.positive? bits += 8 value >>= 8 end bits end |
.get_register(name) ⇒ Register?
Get a Register object by name.
124 125 126 127 128 129 |
# File 'lib/pwnlib/shellcraft/registers.rb', line 124 def get_register(name) return name if name.instance_of?(Register) return INTEL[name.to_s] if name.instance_of?(String) || name.instance_of?(Symbol) nil end |
.register?(obj) ⇒ Boolean
131 132 133 |
# File 'lib/pwnlib/shellcraft/registers.rb', line 131 def register?(obj) !get_register(obj).nil? end |