pwntools 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -11
- data/Rakefile +5 -1
- data/lib/pwn.rb +9 -7
- data/lib/pwnlib/abi.rb +60 -0
- data/lib/pwnlib/asm.rb +146 -0
- data/lib/pwnlib/constants/constant.rb +16 -2
- data/lib/pwnlib/constants/constants.rb +35 -19
- data/lib/pwnlib/constants/linux/amd64.rb +30 -1
- data/lib/pwnlib/context.rb +25 -17
- data/lib/pwnlib/dynelf.rb +117 -54
- data/lib/pwnlib/elf/elf.rb +267 -0
- data/lib/pwnlib/ext/helper.rb +4 -4
- data/lib/pwnlib/logger.rb +87 -0
- data/lib/pwnlib/memleak.rb +58 -29
- data/lib/pwnlib/pwn.rb +19 -8
- data/lib/pwnlib/reg_sort.rb +102 -108
- data/lib/pwnlib/shellcraft/generators/amd64/common/common.rb +14 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/infloop.rb +17 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/memcpy.rb +31 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/mov.rb +127 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/nop.rb +16 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/popad.rb +27 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/pushstr.rb +64 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/pushstr_array.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/ret.rb +32 -0
- data/lib/pwnlib/shellcraft/generators/amd64/common/setregs.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/execve.rb +21 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/linux.rb +14 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/ls.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/sh.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/syscall.rb +21 -0
- data/lib/pwnlib/shellcraft/generators/helper.rb +106 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/common.rb +14 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/infloop.rb +17 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/mov.rb +90 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/nop.rb +16 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/pushstr.rb +39 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/pushstr_array.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/i386/common/setregs.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/execve.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/linux.rb +14 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/ls.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/sh.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/syscall.rb +19 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/common.rb +26 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/infloop.rb +22 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/mov.rb +15 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/pushstr.rb +15 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/pushstr_array.rb +85 -0
- data/lib/pwnlib/shellcraft/generators/x86/common/setregs.rb +82 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/execve.rb +69 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/linux.rb +14 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/ls.rb +66 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/sh.rb +52 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/syscall.rb +52 -0
- data/lib/pwnlib/shellcraft/registers.rb +145 -0
- data/lib/pwnlib/shellcraft/shellcraft.rb +67 -0
- data/lib/pwnlib/timer.rb +60 -0
- data/lib/pwnlib/tubes/buffer.rb +96 -0
- data/lib/pwnlib/tubes/sock.rb +95 -0
- data/lib/pwnlib/tubes/tube.rb +270 -0
- data/lib/pwnlib/util/cyclic.rb +95 -94
- data/lib/pwnlib/util/fiddling.rb +256 -220
- data/lib/pwnlib/util/getdents.rb +83 -0
- data/lib/pwnlib/util/hexdump.rb +109 -108
- data/lib/pwnlib/util/lists.rb +55 -0
- data/lib/pwnlib/util/packing.rb +226 -228
- data/lib/pwnlib/util/ruby.rb +18 -0
- data/lib/pwnlib/version.rb +2 -1
- data/test/abi_test.rb +21 -0
- data/test/asm_test.rb +104 -0
- data/test/constants/constant_test.rb +1 -0
- data/test/constants/constants_test.rb +4 -2
- data/test/context_test.rb +1 -0
- data/test/data/echo.rb +20 -0
- data/test/data/elfs/Makefile +22 -0
- data/test/data/elfs/amd64.frelro.elf +0 -0
- data/test/data/elfs/amd64.frelro.pie.elf +0 -0
- data/test/data/elfs/amd64.nrelro.elf +0 -0
- data/test/data/elfs/amd64.prelro.elf +0 -0
- data/test/data/elfs/i386.frelro.pie.elf +0 -0
- data/test/data/elfs/i386.prelro.elf +0 -0
- data/test/data/elfs/source.cpp +19 -0
- data/test/data/flag +1 -0
- data/test/data/lib32/ld.so.2 +0 -0
- data/test/data/lib32/libc.so.6 +0 -0
- data/test/data/lib64/ld.so.2 +0 -0
- data/test/data/lib64/libc.so.6 +0 -0
- data/test/dynelf_test.rb +59 -24
- data/test/elf/elf_test.rb +120 -0
- data/test/ext_test.rb +3 -2
- data/test/files/use_pwnlib.rb +1 -1
- data/test/logger_test.rb +61 -0
- data/test/memleak_test.rb +4 -33
- data/test/reg_sort_test.rb +3 -1
- data/test/shellcraft/infloop_test.rb +26 -0
- data/test/shellcraft/linux/ls_test.rb +108 -0
- data/test/shellcraft/linux/sh_test.rb +119 -0
- data/test/shellcraft/linux/syscalls/execve_test.rb +136 -0
- data/test/shellcraft/linux/syscalls/syscall_test.rb +83 -0
- data/test/shellcraft/memcpy_test.rb +35 -0
- data/test/shellcraft/mov_test.rb +98 -0
- data/test/shellcraft/nop_test.rb +26 -0
- data/test/shellcraft/popad_test.rb +29 -0
- data/test/shellcraft/pushstr_array_test.rb +91 -0
- data/test/shellcraft/pushstr_test.rb +108 -0
- data/test/shellcraft/registers_test.rb +32 -0
- data/test/shellcraft/ret_test.rb +30 -0
- data/test/shellcraft/setregs_test.rb +62 -0
- data/test/shellcraft/shellcraft_test.rb +28 -0
- data/test/test_helper.rb +12 -1
- data/test/timer_test.rb +23 -0
- data/test/tubes/buffer_test.rb +45 -0
- data/test/tubes/sock_test.rb +68 -0
- data/test/tubes/tube_test.rb +241 -0
- data/test/util/cyclic_test.rb +2 -1
- data/test/util/fiddling_test.rb +2 -1
- data/test/util/getdents_test.rb +32 -0
- data/test/util/hexdump_test.rb +7 -9
- data/test/util/lists_test.rb +21 -0
- data/test/util/packing_test.rb +4 -3
- metadata +215 -25
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
|
+
require 'pwnlib/shellcraft/generators/x86/common/infloop'
|
3
|
+
|
4
|
+
module Pwnlib
|
5
|
+
module Shellcraft
|
6
|
+
module Generators
|
7
|
+
module Amd64
|
8
|
+
module Common
|
9
|
+
# See {X86::Common#infloop}.
|
10
|
+
def infloop
|
11
|
+
cat Generators::X86::Common.infloop
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
4
|
+
require 'pwnlib/shellcraft/generators/amd64/common/setregs'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Common
|
11
|
+
# Like +memcpy+ in glibc.
|
12
|
+
#
|
13
|
+
# Copy +n+ bytes from +src+ to +dst+.
|
14
|
+
#
|
15
|
+
# @param [String, Symbol, Integer] dst
|
16
|
+
# Destination.
|
17
|
+
# @param [String, Symbol, Integer] src
|
18
|
+
# Source to be copied.
|
19
|
+
# @param [Integer] n
|
20
|
+
# The number of bytes to be copied.
|
21
|
+
def memcpy(dst, src, n)
|
22
|
+
cat "/* memcpy(#{pretty(dst)}, #{pretty(src)}, #{pretty(n)}) */"
|
23
|
+
cat 'cld'
|
24
|
+
cat Common.setregs(rdi: dst, rsi: src, rcx: n)
|
25
|
+
cat 'rep movsb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
4
|
+
|
5
|
+
module Pwnlib
|
6
|
+
module Shellcraft
|
7
|
+
module Generators
|
8
|
+
module Amd64
|
9
|
+
module Common
|
10
|
+
# Move +src+ into +dst+ without newlines and null bytes.
|
11
|
+
#
|
12
|
+
# @param [String, Symbol] dst
|
13
|
+
# Register's name.
|
14
|
+
# @param [String, Symbol, Integer] src
|
15
|
+
# Register's name or immediate value.
|
16
|
+
# @param [Boolean] stack_allowed
|
17
|
+
# If equals to +false+, generated assembly code would not use stack-related operations.
|
18
|
+
# But beware of without stack-related operations the generated code length is longer.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# context.arch = 'amd64'
|
22
|
+
# shellcraft.mov('rdi', 'ax')
|
23
|
+
# #=> " movzx edi, ax\n"
|
24
|
+
# @example
|
25
|
+
# context.arch = 'amd64'
|
26
|
+
# puts shellcraft.mov('rax', 10)
|
27
|
+
# # push 9 /* mov eax, '\n' */
|
28
|
+
# # pop rax
|
29
|
+
# # inc eax
|
30
|
+
# #=> nil
|
31
|
+
# @example
|
32
|
+
# context.arch = 'amd64'
|
33
|
+
# puts shellcraft.mov('rax', 10, stack_allowed: false)
|
34
|
+
# # mov eax, 0x1010101
|
35
|
+
# # xor eax, 0x101010b /* 0xa == 0x1010101 ^ 0x101010b */
|
36
|
+
# #=> nil
|
37
|
+
def mov(dst, src, stack_allowed: true)
|
38
|
+
raise ArgumentError, "#{dst} is not a register" unless register?(dst)
|
39
|
+
dst = get_register(dst)
|
40
|
+
if register?(src)
|
41
|
+
src = get_register(src)
|
42
|
+
if dst.size < src.size && !dst.bigger.include?(src.name)
|
43
|
+
raise ArgumentError, "cannot mov #{dst}, #{src}: dst is smaller than src"
|
44
|
+
end
|
45
|
+
# Downgrade our register choice if possible.
|
46
|
+
# Opcodes for operating on 32-bit registers are always (?) shorter.
|
47
|
+
dst = get_register(dst.native32) if dst.size == 64 && src.size <= 32
|
48
|
+
else
|
49
|
+
context.local(arch: 'amd64') { src = evaluate(src) }
|
50
|
+
raise ArgumentError, format('cannot mov %s, %d: dst is smaller than src', dst, src) unless dst.fits(src)
|
51
|
+
orig_dst = dst
|
52
|
+
dst = get_register(dst.native32) if dst.size == 64 && bits_required(src) <= 32
|
53
|
+
|
54
|
+
# Calculate the packed version.
|
55
|
+
srcp = pack(src & ((1 << dst.size) - 1), bits: dst.size)
|
56
|
+
|
57
|
+
# Calculate the unsigned and signed versions.
|
58
|
+
srcu = unpack(srcp, bits: dst.size, signed: false)
|
59
|
+
# N.B.: We may have downsized the register for e.g. mov('rax', 0xffffffff)
|
60
|
+
# In this case, srcp is now a 4-byte packed value, which will expand to "-1", which isn't correct.
|
61
|
+
srcs = orig_dst.size == dst.size ? unpack(srcp, bits: dst.size, signed: true) : src
|
62
|
+
end
|
63
|
+
if register?(src)
|
64
|
+
if src == dst || dst.bigger.include?(src.name)
|
65
|
+
cat "/* moving #{src} into #{dst}, but this is a no-op */"
|
66
|
+
elsif dst.size > src.size
|
67
|
+
cat "movzx #{dst}, #{src}"
|
68
|
+
else
|
69
|
+
cat "mov #{dst}, #{src}"
|
70
|
+
end
|
71
|
+
elsif src.is_a?(Numeric) # Constant or immi
|
72
|
+
xor = ->(reg) { "xor #{reg.xor}, #{reg.xor}" }
|
73
|
+
if src.zero?
|
74
|
+
# Special case for zeroes.
|
75
|
+
# XORing the 32-bit register clears the high 32 bits as well.
|
76
|
+
cat "xor #{dst}, #{dst} /* #{src} */"
|
77
|
+
elsif stack_allowed && [32, 64].include?(dst.size) && src == 10
|
78
|
+
cat "push 9 /* mov #{dst}, '\\n' */"
|
79
|
+
cat "pop #{dst.native64}"
|
80
|
+
cat "inc #{dst}"
|
81
|
+
elsif stack_allowed && [32, 64].include?(dst.size) && (-2**7 <= srcs && srcs < 2**7) && okay(srcp[0])
|
82
|
+
# It's smaller to PUSH and POP small sign-extended values than to directly move them into various
|
83
|
+
# registers.
|
84
|
+
#
|
85
|
+
# 6aff58 push -1; pop rax
|
86
|
+
# 48c7c0ffffffff mov rax, -1
|
87
|
+
cat "push #{pretty(src)}"
|
88
|
+
cat "pop #{dst.native64}"
|
89
|
+
elsif okay(srcp)
|
90
|
+
# Easy case. This implies that the register size and value are the same.
|
91
|
+
cat "mov #{dst}, #{pretty(src)}"
|
92
|
+
elsif srcu < 2**8 && okay(srcp[0]) && dst.sizes.include?(8) # Move 8-bit value into register.
|
93
|
+
cat xor[dst]
|
94
|
+
cat "mov #{dst.sizes[8]}, #{pretty(src)}"
|
95
|
+
elsif srcu == srcu & 0xff00 && okay(srcp[1]) && dst.ff00
|
96
|
+
# Target value is a 16-bit value with no data in the low 8 bits, we can use the 'AH' style register.
|
97
|
+
cat xor[dst]
|
98
|
+
cat "mov #{dst.ff00}, #{pretty(src)} >> 8"
|
99
|
+
elsif srcu < 2**16 && okay(srcp[0, 2]) # Target value is a 16-bit value, use a 16-bit mov.
|
100
|
+
cat xor[dst]
|
101
|
+
cat "mov #{dst.sizes[16]}, #{pretty(src)}"
|
102
|
+
else # All else has failed. Use some XOR magic to move things around.
|
103
|
+
a, b = xor_pair(srcp, avoid: "\x00\n")
|
104
|
+
a = hex(unpack(a, bits: dst.size))
|
105
|
+
b = hex(unpack(b, bits: dst.size))
|
106
|
+
if dst.size != 64
|
107
|
+
# There's no XOR REG, IMM64 but we can take the easy route for smaller registers.
|
108
|
+
cat "mov #{dst}, #{a}"
|
109
|
+
cat "xor #{dst}, #{b} /* #{hex(src)} == #{a} ^ #{b} */"
|
110
|
+
elsif stack_allowed
|
111
|
+
# However, we can PUSH IMM64 and then perform the XOR that way at the top of the stack.
|
112
|
+
cat "mov #{dst}, #{a}"
|
113
|
+
cat "push #{dst}"
|
114
|
+
cat "mov #{dst}, #{b}"
|
115
|
+
cat "xor [rsp], #{dst} /* #{hex(src)} == #{a} ^ #{b} */"
|
116
|
+
cat "pop #{dst}"
|
117
|
+
else
|
118
|
+
raise ArgumentError, "Cannot put #{pretty(src)} into '#{dst}' without using stack."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
4
|
+
|
5
|
+
module Pwnlib
|
6
|
+
module Shellcraft
|
7
|
+
module Generators
|
8
|
+
module Amd64
|
9
|
+
module Common
|
10
|
+
# Pop all of the registers onto the stack which i386 +popad+ does.
|
11
|
+
def popad
|
12
|
+
cat <<-EOS
|
13
|
+
pop rdi
|
14
|
+
pop rsi
|
15
|
+
pop rbp
|
16
|
+
pop rbx /* add rsp, 8 */
|
17
|
+
pop rbx
|
18
|
+
pop rdx
|
19
|
+
pop rcx
|
20
|
+
pop rax
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
4
|
+
|
5
|
+
module Pwnlib
|
6
|
+
module Shellcraft
|
7
|
+
module Generators
|
8
|
+
module Amd64
|
9
|
+
module Common
|
10
|
+
# Push a string to stack.
|
11
|
+
#
|
12
|
+
# @param [String] str
|
13
|
+
# String to be pushed.
|
14
|
+
# @param [Boolean] append_null
|
15
|
+
# If need to append a null byte in the end of +str+.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# context.arch = 'amd64'
|
19
|
+
# puts shellcraft.pushstr('pusheen')
|
20
|
+
# # /* push "pusheen\x00" */
|
21
|
+
# # mov rax, 0x101010101010101
|
22
|
+
# # push rax
|
23
|
+
# # mov rax, 0x101010101010101 ^ 0x6e656568737570
|
24
|
+
# # xor [rsp], rax
|
25
|
+
# #=> nil
|
26
|
+
def pushstr(str, append_null: true)
|
27
|
+
# This will not affect callee's +str+.
|
28
|
+
str += "\x00" if append_null && !str.end_with?("\x00")
|
29
|
+
return if str.empty?
|
30
|
+
padding = str[-1].ord >= 128 ? "\xff" : "\x00"
|
31
|
+
cat "/* push #{str.inspect} */"
|
32
|
+
group(8, str, underfull_action: :fill, fill_value: padding).reverse_each do |word|
|
33
|
+
sign = u64(word, endian: 'little', signed: true)
|
34
|
+
sign32 = u32(word[0, 4], bits: 32, endian: 'little', signed: true)
|
35
|
+
if [0, 0xa].include?(sign) # simple forbidden byte case
|
36
|
+
cat "push #{pretty(sign + 1)}"
|
37
|
+
cat 'dec byte ptr [rsp]'
|
38
|
+
elsif sign >= -0x80 && sign <= 0x7f && okay(word[0]) # simple byte case
|
39
|
+
cat "push #{pretty(sign)}"
|
40
|
+
elsif sign >= -0x80000000 && sign <= 0x7fffffff && okay(word[0, 4])
|
41
|
+
# simple 32bit without forbidden byte
|
42
|
+
cat "push #{pretty(sign)}"
|
43
|
+
elsif okay(word)
|
44
|
+
cat "mov rax, #{pretty(sign)}"
|
45
|
+
cat 'push rax'
|
46
|
+
elsif sign32 > 0 && word[4, 4] == "\x00" * 4
|
47
|
+
# The high 4 byte of word are all zeros, so we can use +xor dword ptr [rsp]+.
|
48
|
+
a = u32(xor_pair(word[0, 4]).first, endian: 'little', signed: true)
|
49
|
+
cat "push #{pretty(a)} ^ #{pretty(sign)}"
|
50
|
+
cat "xor dword ptr [rsp], #{pretty(a)}"
|
51
|
+
else
|
52
|
+
a = u64(xor_pair(word).first, endian: 'little', signed: false)
|
53
|
+
cat "mov rax, #{pretty(a)}"
|
54
|
+
cat 'push rax'
|
55
|
+
cat "mov rax, #{pretty(a ^ sign)} /* #{pretty(a)} ^ #{pretty(sign)} */"
|
56
|
+
cat 'xor [rsp], rax'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
|
+
require 'pwnlib/shellcraft/generators/x86/common/pushstr_array'
|
3
|
+
|
4
|
+
module Pwnlib
|
5
|
+
module Shellcraft
|
6
|
+
module Generators
|
7
|
+
module Amd64
|
8
|
+
module Common
|
9
|
+
# See {Pwnlib::Shellcraft::Generators::X86::Common#pushstr_array}.
|
10
|
+
def pushstr_array(*args)
|
11
|
+
context.local(arch: 'amd64') do
|
12
|
+
cat X86::Common.pushstr_array(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
4
|
+
require 'pwnlib/shellcraft/generators/amd64/common/mov'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Common
|
11
|
+
# Instruction return.
|
12
|
+
#
|
13
|
+
# @param [String, Symbol, Integer] return_value
|
14
|
+
# Set the return value.
|
15
|
+
# Can be name of a register or an immediate value.
|
16
|
+
# +nil+ for not set return value.
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# context.arch = 'amd64'
|
20
|
+
# shellcraft.ret
|
21
|
+
# #=> " ret"
|
22
|
+
# shellcraft.ret(:rdi)
|
23
|
+
# #=> " mov rax, rdi\n ret\n"
|
24
|
+
def ret(return_value = nil)
|
25
|
+
cat Common.mov('rax', return_value) if return_value
|
26
|
+
cat 'ret'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
|
+
require 'pwnlib/shellcraft/generators/x86/common/setregs'
|
3
|
+
|
4
|
+
module Pwnlib
|
5
|
+
module Shellcraft
|
6
|
+
module Generators
|
7
|
+
module Amd64
|
8
|
+
module Common
|
9
|
+
# See {Generators::X86::Common#setregs}.
|
10
|
+
def setregs(*args)
|
11
|
+
context.local(arch: 'amd64') do
|
12
|
+
cat X86::Common.setregs(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/execve'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Linux
|
11
|
+
# See {Generators::X86::Linux#execve}.
|
12
|
+
def execve(*arguments)
|
13
|
+
context.local(arch: 'amd64') do
|
14
|
+
cat X86::Linux.execve(*arguments)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
2
|
+
require 'pwnlib/shellcraft/generators/x86/linux/ls'
|
3
|
+
|
4
|
+
module Pwnlib
|
5
|
+
module Shellcraft
|
6
|
+
module Generators
|
7
|
+
module Amd64
|
8
|
+
module Linux
|
9
|
+
# See #{Generators::X86::Linux#ls}.
|
10
|
+
def ls(*args)
|
11
|
+
context.local(arch: 'amd64') do
|
12
|
+
cat X86::Linux.ls(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
2
|
+
require 'pwnlib/shellcraft/generators/x86/linux/sh'
|
3
|
+
|
4
|
+
module Pwnlib
|
5
|
+
module Shellcraft
|
6
|
+
module Generators
|
7
|
+
module Amd64
|
8
|
+
module Linux
|
9
|
+
# See #{Generators::X86::Linux#sh}.
|
10
|
+
def sh(*args)
|
11
|
+
context.local(arch: 'amd64') do
|
12
|
+
cat X86::Linux.sh(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|