pwntools 0.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +96 -15
  3. data/Rakefile +8 -2
  4. data/lib/pwn.rb +10 -7
  5. data/lib/pwnlib/abi.rb +61 -0
  6. data/lib/pwnlib/asm.rb +357 -0
  7. data/lib/pwnlib/constants/constant.rb +19 -3
  8. data/lib/pwnlib/constants/constants.rb +46 -20
  9. data/lib/pwnlib/constants/linux/amd64.rb +32 -1
  10. data/lib/pwnlib/constants/linux/i386.rb +2 -0
  11. data/lib/pwnlib/context.rb +128 -27
  12. data/lib/pwnlib/dynelf.rb +122 -54
  13. data/lib/pwnlib/elf/elf.rb +340 -0
  14. data/lib/pwnlib/errors.rb +31 -0
  15. data/lib/pwnlib/ext/array.rb +2 -1
  16. data/lib/pwnlib/ext/helper.rb +6 -5
  17. data/lib/pwnlib/ext/integer.rb +2 -1
  18. data/lib/pwnlib/ext/string.rb +3 -2
  19. data/lib/pwnlib/logger.rb +245 -0
  20. data/lib/pwnlib/memleak.rb +59 -29
  21. data/lib/pwnlib/pwn.rb +27 -9
  22. data/lib/pwnlib/reg_sort.rb +109 -110
  23. data/lib/pwnlib/runner.rb +53 -0
  24. data/lib/pwnlib/shellcraft/generators/amd64/common/common.rb +16 -0
  25. data/lib/pwnlib/shellcraft/generators/amd64/common/infloop.rb +24 -0
  26. data/lib/pwnlib/shellcraft/generators/amd64/common/memcpy.rb +35 -0
  27. data/lib/pwnlib/shellcraft/generators/amd64/common/mov.rb +131 -0
  28. data/lib/pwnlib/shellcraft/generators/amd64/common/nop.rb +18 -0
  29. data/lib/pwnlib/shellcraft/generators/amd64/common/popad.rb +28 -0
  30. data/lib/pwnlib/shellcraft/generators/amd64/common/pushstr.rb +66 -0
  31. data/lib/pwnlib/shellcraft/generators/amd64/common/pushstr_array.rb +24 -0
  32. data/lib/pwnlib/shellcraft/generators/amd64/common/ret.rb +33 -0
  33. data/lib/pwnlib/shellcraft/generators/amd64/common/setregs.rb +24 -0
  34. data/lib/pwnlib/shellcraft/generators/amd64/linux/cat.rb +24 -0
  35. data/lib/pwnlib/shellcraft/generators/amd64/linux/execve.rb +24 -0
  36. data/lib/pwnlib/shellcraft/generators/amd64/linux/exit.rb +24 -0
  37. data/lib/pwnlib/shellcraft/generators/amd64/linux/linux.rb +16 -0
  38. data/lib/pwnlib/shellcraft/generators/amd64/linux/ls.rb +24 -0
  39. data/lib/pwnlib/shellcraft/generators/amd64/linux/open.rb +24 -0
  40. data/lib/pwnlib/shellcraft/generators/amd64/linux/sh.rb +24 -0
  41. data/lib/pwnlib/shellcraft/generators/amd64/linux/sleep.rb +24 -0
  42. data/lib/pwnlib/shellcraft/generators/amd64/linux/syscall.rb +24 -0
  43. data/lib/pwnlib/shellcraft/generators/helper.rb +115 -0
  44. data/lib/pwnlib/shellcraft/generators/i386/common/common.rb +16 -0
  45. data/lib/pwnlib/shellcraft/generators/i386/common/infloop.rb +24 -0
  46. data/lib/pwnlib/shellcraft/generators/i386/common/memcpy.rb +34 -0
  47. data/lib/pwnlib/shellcraft/generators/i386/common/mov.rb +93 -0
  48. data/lib/pwnlib/shellcraft/generators/i386/common/nop.rb +18 -0
  49. data/lib/pwnlib/shellcraft/generators/i386/common/pushstr.rb +41 -0
  50. data/lib/pwnlib/shellcraft/generators/i386/common/pushstr_array.rb +24 -0
  51. data/lib/pwnlib/shellcraft/generators/i386/common/setregs.rb +24 -0
  52. data/lib/pwnlib/shellcraft/generators/i386/linux/cat.rb +24 -0
  53. data/lib/pwnlib/shellcraft/generators/i386/linux/execve.rb +24 -0
  54. data/lib/pwnlib/shellcraft/generators/i386/linux/exit.rb +24 -0
  55. data/lib/pwnlib/shellcraft/generators/i386/linux/linux.rb +16 -0
  56. data/lib/pwnlib/shellcraft/generators/i386/linux/ls.rb +24 -0
  57. data/lib/pwnlib/shellcraft/generators/i386/linux/open.rb +24 -0
  58. data/lib/pwnlib/shellcraft/generators/i386/linux/sh.rb +24 -0
  59. data/lib/pwnlib/shellcraft/generators/i386/linux/sleep.rb +24 -0
  60. data/lib/pwnlib/shellcraft/generators/i386/linux/syscall.rb +24 -0
  61. data/lib/pwnlib/shellcraft/generators/x86/common/common.rb +29 -0
  62. data/lib/pwnlib/shellcraft/generators/x86/common/infloop.rb +24 -0
  63. data/lib/pwnlib/shellcraft/generators/x86/common/memcpy.rb +17 -0
  64. data/lib/pwnlib/shellcraft/generators/x86/common/mov.rb +17 -0
  65. data/lib/pwnlib/shellcraft/generators/x86/common/pushstr.rb +17 -0
  66. data/lib/pwnlib/shellcraft/generators/x86/common/pushstr_array.rb +86 -0
  67. data/lib/pwnlib/shellcraft/generators/x86/common/setregs.rb +84 -0
  68. data/lib/pwnlib/shellcraft/generators/x86/linux/cat.rb +54 -0
  69. data/lib/pwnlib/shellcraft/generators/x86/linux/execve.rb +72 -0
  70. data/lib/pwnlib/shellcraft/generators/x86/linux/exit.rb +34 -0
  71. data/lib/pwnlib/shellcraft/generators/x86/linux/linux.rb +16 -0
  72. data/lib/pwnlib/shellcraft/generators/x86/linux/ls.rb +67 -0
  73. data/lib/pwnlib/shellcraft/generators/x86/linux/open.rb +47 -0
  74. data/lib/pwnlib/shellcraft/generators/x86/linux/sh.rb +53 -0
  75. data/lib/pwnlib/shellcraft/generators/x86/linux/sleep.rb +52 -0
  76. data/lib/pwnlib/shellcraft/generators/x86/linux/syscall.rb +52 -0
  77. data/lib/pwnlib/shellcraft/registers.rb +148 -0
  78. data/lib/pwnlib/shellcraft/shellcraft.rb +73 -0
  79. data/lib/pwnlib/timer.rb +67 -0
  80. data/lib/pwnlib/tubes/buffer.rb +99 -0
  81. data/lib/pwnlib/tubes/process.rb +155 -0
  82. data/lib/pwnlib/tubes/serialtube.rb +114 -0
  83. data/lib/pwnlib/tubes/sock.rb +101 -0
  84. data/lib/pwnlib/tubes/tube.rb +442 -0
  85. data/lib/pwnlib/ui.rb +21 -0
  86. data/lib/pwnlib/util/cyclic.rb +97 -94
  87. data/lib/pwnlib/util/fiddling.rb +288 -220
  88. data/lib/pwnlib/util/getdents.rb +85 -0
  89. data/lib/pwnlib/util/hexdump.rb +116 -112
  90. data/lib/pwnlib/util/lists.rb +58 -0
  91. data/lib/pwnlib/util/packing.rb +223 -228
  92. data/lib/pwnlib/util/ruby.rb +19 -0
  93. data/lib/pwnlib/version.rb +3 -1
  94. data/test/abi_test.rb +22 -0
  95. data/test/asm_test.rb +177 -0
  96. data/test/constants/constant_test.rb +2 -0
  97. data/test/constants/constants_test.rb +5 -2
  98. data/test/context_test.rb +14 -3
  99. data/test/data/assembly/aarch64.s +19 -0
  100. data/test/data/assembly/amd64.s +21 -0
  101. data/test/data/assembly/arm.s +9 -0
  102. data/test/data/assembly/i386.s +21 -0
  103. data/test/data/assembly/mips.s +16 -0
  104. data/test/data/assembly/mips64.s +6 -0
  105. data/test/data/assembly/powerpc.s +18 -0
  106. data/test/data/assembly/powerpc64.s +36 -0
  107. data/test/data/assembly/sparc.s +33 -0
  108. data/test/data/assembly/sparc64.s +5 -0
  109. data/test/data/assembly/thumb.s +37 -0
  110. data/test/data/echo.rb +16 -0
  111. data/test/data/elfs/Makefile +24 -0
  112. data/test/data/elfs/amd64.frelro.elf +0 -0
  113. data/test/data/elfs/amd64.frelro.pie.elf +0 -0
  114. data/test/data/elfs/amd64.nrelro.elf +0 -0
  115. data/test/data/elfs/amd64.prelro.elf +0 -0
  116. data/test/data/elfs/amd64.static.elf +0 -0
  117. data/test/data/elfs/i386.frelro.pie.elf +0 -0
  118. data/test/data/elfs/i386.prelro.elf +0 -0
  119. data/test/data/elfs/source.cpp +19 -0
  120. data/test/data/flag +1 -0
  121. data/test/data/lib32/ld.so.2 +0 -0
  122. data/test/data/lib32/libc.so.6 +0 -0
  123. data/test/data/lib64/ld.so.2 +0 -0
  124. data/test/data/lib64/libc.so.6 +0 -0
  125. data/test/dynelf_test.rb +62 -25
  126. data/test/elf/elf_test.rb +147 -0
  127. data/test/ext_test.rb +4 -2
  128. data/test/files/use_pwn.rb +3 -6
  129. data/test/files/use_pwnlib.rb +2 -1
  130. data/test/full_file_test.rb +6 -0
  131. data/test/logger_test.rb +120 -0
  132. data/test/memleak_test.rb +5 -33
  133. data/test/reg_sort_test.rb +4 -1
  134. data/test/runner_test.rb +32 -0
  135. data/test/shellcraft/infloop_test.rb +27 -0
  136. data/test/shellcraft/linux/cat_test.rb +87 -0
  137. data/test/shellcraft/linux/ls_test.rb +109 -0
  138. data/test/shellcraft/linux/sh_test.rb +120 -0
  139. data/test/shellcraft/linux/sleep_test.rb +68 -0
  140. data/test/shellcraft/linux/syscalls/execve_test.rb +137 -0
  141. data/test/shellcraft/linux/syscalls/exit_test.rb +57 -0
  142. data/test/shellcraft/linux/syscalls/open_test.rb +87 -0
  143. data/test/shellcraft/linux/syscalls/syscall_test.rb +84 -0
  144. data/test/shellcraft/memcpy_test.rb +50 -0
  145. data/test/shellcraft/mov_test.rb +99 -0
  146. data/test/shellcraft/nop_test.rb +27 -0
  147. data/test/shellcraft/popad_test.rb +30 -0
  148. data/test/shellcraft/pushstr_array_test.rb +92 -0
  149. data/test/shellcraft/pushstr_test.rb +109 -0
  150. data/test/shellcraft/registers_test.rb +33 -0
  151. data/test/shellcraft/ret_test.rb +31 -0
  152. data/test/shellcraft/setregs_test.rb +63 -0
  153. data/test/shellcraft/shellcraft_test.rb +30 -0
  154. data/test/test_helper.rb +61 -2
  155. data/test/timer_test.rb +42 -0
  156. data/test/tubes/buffer_test.rb +46 -0
  157. data/test/tubes/process_test.rb +105 -0
  158. data/test/tubes/serialtube_test.rb +162 -0
  159. data/test/tubes/sock_test.rb +68 -0
  160. data/test/tubes/tube_test.rb +320 -0
  161. data/test/ui_test.rb +18 -0
  162. data/test/util/cyclic_test.rb +3 -1
  163. data/test/util/fiddling_test.rb +12 -3
  164. data/test/util/getdents_test.rb +33 -0
  165. data/test/util/hexdump_test.rb +9 -10
  166. data/test/util/lists_test.rb +22 -0
  167. data/test/util/packing_test.rb +5 -3
  168. metadata +357 -37
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pwnlib/shellcraft/generators/helper'
4
+
5
+ module Pwnlib
6
+ module Shellcraft
7
+ module Generators
8
+ module I386
9
+ # For non os-related methods.
10
+ module Common
11
+ extend ::Pwnlib::Shellcraft::Generators::Helper
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+ require 'pwnlib/shellcraft/generators/x86/common/infloop'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Common
12
+ # @overload infloop
13
+ #
14
+ # @see Generators::X86::Common#infloop
15
+ def infloop(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Common.infloop(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+ require 'pwnlib/shellcraft/generators/i386/common/setregs'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Common
12
+ # Like +memcpy+ in glibc.
13
+ #
14
+ # Copy +n+ bytes from +src+ to +dst+.
15
+ #
16
+ # @param [String, Symbol, Integer] dst
17
+ # Destination.
18
+ # @param [String, Symbol, Integer] src
19
+ # Source to be copied.
20
+ # @param [Integer] n
21
+ # The number of bytes to be copied.
22
+ #
23
+ # @see Amd64::Common#memcpy
24
+ def memcpy(dst, src, n)
25
+ cat "/* memcpy(#{pretty(dst)}, #{pretty(src)}, #{pretty(n)}) */"
26
+ cat 'cld'
27
+ cat Common.setregs({ edi: dst, esi: src, ecx: n })
28
+ cat 'rep movsb'
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,93 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+
6
+ module Pwnlib
7
+ module Shellcraft
8
+ module Generators
9
+ module I386
10
+ module Common
11
+ # Move +src+ into +dst+ without newlines and null bytes.
12
+ #
13
+ # See {Amd64::Common#mov} for parameters' details.
14
+ def mov(dst, src, stack_allowed: true)
15
+ raise ArgumentError, "#{dst} is not a register" unless register?(dst)
16
+
17
+ dst = get_register(dst)
18
+ raise ArgumentError, "cannot use #{dst} on i386" if dst.size > 32 || dst.is64bit
19
+
20
+ if register?(src)
21
+ src = get_register(src)
22
+ raise ArgumentError, "cannot use #{src} on i386" if src.size > 32 || src.is64bit
23
+ if dst.size < src.size && !dst.bigger.include?(src.name)
24
+ raise ArgumentError, "cannot mov #{dst}, #{src}: dst is smaller than src"
25
+ end
26
+ else
27
+ context.local(arch: 'i386') { src = evaluate(src) }
28
+ raise ArgumentError, format('cannot mov %s, %d: dst is smaller than src', dst, src) unless dst.fits(src)
29
+
30
+ # Calculate the packed version
31
+ srcp = pack(src & ((1 << dst.size) - 1), bits: dst.size)
32
+
33
+ # Calculate the unsigned and signed versions
34
+ srcu = unpack(srcp, bits: dst.size, signed: false)
35
+ srcs = unpack(srcp, bits: dst.size, signed: true)
36
+ srcp_neg = p32(-src)
37
+ srcp_not = p32(src ^ 0xffffffff)
38
+ end
39
+ if register?(src)
40
+ if src == dst || dst.bigger.include?(src.name)
41
+ cat "/* moving #{src} into #{dst}, but this is a no-op */"
42
+ elsif dst.size > src.size
43
+ cat "movzx #{dst}, #{src}"
44
+ else
45
+ cat "mov #{dst}, #{src}"
46
+ end
47
+ elsif src.is_a?(Numeric) # Constant or immi
48
+ xor = ->(reg) { "xor #{reg.xor}, #{reg.xor}" }
49
+ if src.zero? # special case for zeroes
50
+ cat "xor #{dst}, #{dst} /* #{src} */"
51
+ elsif stack_allowed && dst.size == 32 && src == 10
52
+ cat "push 9 /* mov #{dst}, '\\n' */"
53
+ cat "pop #{dst}"
54
+ cat "inc #{dst}"
55
+ elsif stack_allowed && dst.size == 32 && (-2**7 <= srcs && srcs < 2**7) && okay(srcp[0])
56
+ cat "push #{pretty(src)}"
57
+ cat "pop #{dst}"
58
+ elsif okay(srcp)
59
+ # Easy case. This implies that the register size and value are the same.
60
+ cat "mov #{dst}, #{pretty(src)}"
61
+ elsif srcu < 2**8 && okay(srcp[0]) && dst.sizes.include?(8)
62
+ # Move 8-bit value into reg.
63
+ cat xor[dst]
64
+ cat "mov #{dst.sizes[8]}, #{pretty(src)}"
65
+ elsif srcu == srcu & 0xff00 && okay(srcp[1]) && dst.ff00
66
+ # Target value is a 16-bit value with no data in the low 8 bits, we can use the 'AH' style register.
67
+ cat xor[dst]
68
+ cat "mov #{dst.ff00}, #{pretty(src)} >> 8"
69
+ elsif srcu < 2**16 && okay(srcp[0, 2])
70
+ # Target value is a 16-bit value, use a 16-bit mov.
71
+ cat xor[dst]
72
+ cat "mov #{dst.sizes[16]}, #{pretty(src)}"
73
+ elsif okay(srcp_neg)
74
+ cat "mov #{dst}, -#{pretty(src)}"
75
+ cat "neg #{dst}"
76
+ elsif okay(srcp_not)
77
+ cat "mov #{dst}, (-1) ^ #{pretty(src)}"
78
+ cat "not #{dst}"
79
+ else
80
+ # All else has failed. Use some XOR magic to move things around.
81
+ a, b = xor_pair(srcp, avoid: "\x00\n")
82
+ a = hex(unpack(a, bits: dst.size))
83
+ b = hex(unpack(b, bits: dst.size))
84
+ cat "mov #{dst}, #{a}"
85
+ cat "xor #{dst}, #{b} /* #{hex(src)} == #{a} ^ #{b} */"
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pwnlib/shellcraft/generators/i386/common/common'
4
+
5
+ module Pwnlib
6
+ module Shellcraft
7
+ module Generators
8
+ module I386
9
+ module Common
10
+ # A no-op instruction.
11
+ def nop
12
+ cat 'nop'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+
6
+ module Pwnlib
7
+ module Shellcraft
8
+ module Generators
9
+ module I386
10
+ module Common
11
+ # Push a string to stack.
12
+ #
13
+ # See {Amd64::Common#pushstr} for parameters' details.
14
+ def pushstr(str, append_null: true)
15
+ # This will not affect callee's +str+.
16
+ str += "\x00" if append_null && !str.end_with?("\x00")
17
+ return if str.empty?
18
+
19
+ padding = str[-1].ord >= 128 ? "\xff" : "\x00"
20
+ cat "/* push #{str.inspect} */"
21
+ group(4, str, underfull_action: :fill, fill_value: padding).reverse_each do |word|
22
+ sign = u32(word, endian: 'little', signed: true)
23
+ if [0, 0xa].include?(sign) # simple forbidden byte case
24
+ cat "push #{pretty(sign + 1)}"
25
+ cat 'dec byte ptr [esp]'
26
+ elsif sign >= -128 && sign <= 127
27
+ cat "push #{pretty(sign)}"
28
+ elsif okay(word)
29
+ cat "push #{pretty(sign)}"
30
+ else
31
+ a = u32(xor_pair(word).first, endian: 'little', signed: false)
32
+ cat "push #{pretty(a)}"
33
+ cat "xor dword ptr [esp], #{pretty(a ^ sign)} /* #{pretty(a)} ^ #{pretty(sign)} */"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+ require 'pwnlib/shellcraft/generators/x86/common/pushstr_array'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Common
12
+ # @overload pushstr_array(reg, array)
13
+ #
14
+ # @see Generators::X86::Common#pushstr_array
15
+ def pushstr_array(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Common.pushstr_array(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/common/common'
5
+ require 'pwnlib/shellcraft/generators/x86/common/setregs'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Common
12
+ # @overload setregs(reg_context, stack_allowed: true)
13
+ #
14
+ # @see Generators::X86::Common#setregs
15
+ def setregs(*args, **kwargs)
16
+ context.local(arch: :i386) do
17
+ cat X86::Common.setregs(*args, **kwargs)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/cat'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload cat(filename, fd: 1)
13
+ #
14
+ # @see Generators::X86::Linux#cat
15
+ def cat(*args, **kwargs)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.cat(*args, **kwargs)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/execve'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload execve(path, argv, envp)
13
+ #
14
+ # @see Generators::X86::Linux#execve
15
+ def execve(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.execve(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/exit'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload exit(status = 0)
13
+ #
14
+ # @see Generators::X86::Linux#exit
15
+ def exit(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.exit(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pwnlib/shellcraft/generators/helper'
4
+
5
+ module Pwnlib
6
+ module Shellcraft
7
+ module Generators
8
+ module I386
9
+ # For os-related methods.
10
+ module Linux
11
+ extend ::Pwnlib::Shellcraft::Generators::Helper
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/ls'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload ls(dir = '.')
13
+ #
14
+ # @see Generators::X86::Linux#ls
15
+ def ls(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.ls(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/open'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload open(filename, flags = 'O_RDONLY', mode = 0)
13
+ #
14
+ # @see Generators::X86::Linux#open
15
+ def open(*args)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.open(*args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: ASCII-8BIT
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwnlib/shellcraft/generators/i386/linux/linux'
5
+ require 'pwnlib/shellcraft/generators/x86/linux/sh'
6
+
7
+ module Pwnlib
8
+ module Shellcraft
9
+ module Generators
10
+ module I386
11
+ module Linux
12
+ # @overload sh(argv: false)
13
+ #
14
+ # @see Generators::X86::Linux#sh
15
+ def sh(**kwargs)
16
+ context.local(arch: :i386) do
17
+ cat X86::Linux.sh(**kwargs)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end