pwntools 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -3
- data/Rakefile +3 -1
- data/lib/pwnlib/asm.rb +172 -2
- data/lib/pwnlib/constants/constants.rb +10 -3
- data/lib/pwnlib/context.rb +1 -3
- data/lib/pwnlib/elf/elf.rb +3 -3
- data/lib/pwnlib/errors.rb +30 -0
- data/lib/pwnlib/ext/helper.rb +1 -1
- data/lib/pwnlib/logger.rb +140 -2
- data/lib/pwnlib/pwn.rb +3 -0
- data/lib/pwnlib/reg_sort.rb +1 -1
- data/lib/pwnlib/shellcraft/generators/amd64/common/infloop.rb +9 -3
- data/lib/pwnlib/shellcraft/generators/amd64/common/pushstr_array.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/amd64/common/setregs.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/amd64/linux/cat.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/execve.rb +6 -4
- data/lib/pwnlib/shellcraft/generators/amd64/linux/exit.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/ls.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/amd64/linux/open.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/amd64/linux/sh.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/amd64/linux/syscall.rb +6 -4
- data/lib/pwnlib/shellcraft/generators/i386/common/infloop.rb +9 -3
- data/lib/pwnlib/shellcraft/generators/i386/common/pushstr_array.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/i386/common/setregs.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/i386/linux/cat.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/execve.rb +8 -4
- data/lib/pwnlib/shellcraft/generators/i386/linux/exit.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/ls.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/i386/linux/open.rb +23 -0
- data/lib/pwnlib/shellcraft/generators/i386/linux/sh.rb +6 -2
- data/lib/pwnlib/shellcraft/generators/i386/linux/syscall.rb +8 -4
- data/lib/pwnlib/shellcraft/generators/x86/linux/cat.rb +53 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/exit.rb +33 -0
- data/lib/pwnlib/shellcraft/generators/x86/linux/open.rb +46 -0
- data/lib/pwnlib/shellcraft/shellcraft.rb +3 -2
- data/lib/pwnlib/timer.rb +5 -2
- data/lib/pwnlib/tubes/process.rb +153 -0
- data/lib/pwnlib/tubes/serialtube.rb +112 -0
- data/lib/pwnlib/tubes/sock.rb +24 -25
- data/lib/pwnlib/tubes/tube.rb +191 -39
- data/lib/pwnlib/util/packing.rb +3 -9
- data/lib/pwnlib/version.rb +1 -1
- data/test/asm_test.rb +85 -2
- data/test/constants/constants_test.rb +2 -2
- data/test/data/echo.rb +2 -7
- data/test/elf/elf_test.rb +10 -15
- data/test/files/use_pwn.rb +2 -6
- data/test/logger_test.rb +38 -0
- data/test/shellcraft/linux/cat_test.rb +86 -0
- data/test/shellcraft/linux/syscalls/exit_test.rb +56 -0
- data/test/shellcraft/linux/syscalls/open_test.rb +86 -0
- data/test/shellcraft/shellcraft_test.rb +5 -4
- data/test/test_helper.rb +22 -2
- data/test/timer_test.rb +19 -1
- data/test/tubes/process_test.rb +99 -0
- data/test/tubes/serialtube_test.rb +165 -0
- data/test/tubes/sock_test.rb +20 -21
- data/test/tubes/tube_test.rb +86 -16
- metadata +75 -13
data/lib/pwnlib/pwn.rb
CHANGED
@@ -8,9 +8,12 @@ require 'pwnlib/constants/constants'
|
|
8
8
|
require 'pwnlib/context'
|
9
9
|
require 'pwnlib/dynelf'
|
10
10
|
require 'pwnlib/elf/elf'
|
11
|
+
require 'pwnlib/errors'
|
11
12
|
require 'pwnlib/logger'
|
12
13
|
require 'pwnlib/reg_sort'
|
13
14
|
require 'pwnlib/shellcraft/shellcraft'
|
15
|
+
require 'pwnlib/tubes/process'
|
16
|
+
require 'pwnlib/tubes/serialtube'
|
14
17
|
require 'pwnlib/tubes/sock'
|
15
18
|
|
16
19
|
require 'pwnlib/util/cyclic'
|
data/lib/pwnlib/reg_sort.rb
CHANGED
@@ -70,7 +70,7 @@ module Pwnlib
|
|
70
70
|
first_reg, val = list.shift
|
71
71
|
# Special case for val.zero? because zeroify registers is cheaper than mov.
|
72
72
|
next if list.empty? || all_regs.include?(val) || val.zero?
|
73
|
-
list.each do |reg, _|
|
73
|
+
list.each do |(reg, _)|
|
74
74
|
hash[reg] = first_reg
|
75
75
|
in_out.delete(reg)
|
76
76
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/infloop'
|
3
5
|
|
@@ -6,9 +8,13 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module Amd64
|
8
10
|
module Common
|
9
|
-
#
|
10
|
-
|
11
|
-
|
11
|
+
# @overload infloop
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#infloop
|
14
|
+
def infloop(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Common.infloop(*args)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/pushstr_array'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module Amd64
|
8
10
|
module Common
|
9
|
-
#
|
11
|
+
# @overload pushstr_array(reg, array)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#pushstr_array
|
10
14
|
def pushstr_array(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :amd64) do
|
12
16
|
cat X86::Common.pushstr_array(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/amd64/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/setregs'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module Amd64
|
8
10
|
module Common
|
9
|
-
#
|
11
|
+
# @overload setregs(reg_context, stack_allowed: true)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#setregs
|
10
14
|
def setregs(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :amd64) do
|
12
16
|
cat X86::Common.setregs(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/cat'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Linux
|
11
|
+
# @overload cat(filename, fd: 1)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#cat
|
14
|
+
def cat(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Linux.cat(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -8,10 +8,12 @@ module Pwnlib
|
|
8
8
|
module Generators
|
9
9
|
module Amd64
|
10
10
|
module Linux
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# @overload execve(path, argv, envp)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#execve
|
14
|
+
def execve(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Linux.execve(*args)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/exit'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Linux
|
11
|
+
# @overload exit(status = 0)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#exit
|
14
|
+
def exit(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Linux.exit(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/ls'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module Amd64
|
8
10
|
module Linux
|
9
|
-
#
|
11
|
+
# @overload ls(dir = '.')
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#ls
|
10
14
|
def ls(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :amd64) do
|
12
16
|
cat X86::Linux.ls(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/open'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module Amd64
|
10
|
+
module Linux
|
11
|
+
# @overload open(filename, flags = 'O_RDONLY', mode = 0)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#open
|
14
|
+
def open(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Linux.open(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/amd64/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/sh'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module Amd64
|
8
10
|
module Linux
|
9
|
-
#
|
11
|
+
# @overload sh(argv: false)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#sh
|
10
14
|
def sh(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :amd64) do
|
12
16
|
cat X86::Linux.sh(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -8,10 +8,12 @@ module Pwnlib
|
|
8
8
|
module Generators
|
9
9
|
module Amd64
|
10
10
|
module Linux
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# @overload syscall(*arguments)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#syscall
|
14
|
+
def syscall(*args)
|
15
|
+
context.local(arch: :amd64) do
|
16
|
+
cat X86::Linux.syscall(*args)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/infloop'
|
3
5
|
|
@@ -6,9 +8,13 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Common
|
9
|
-
#
|
10
|
-
|
11
|
-
|
11
|
+
# @overload infloop
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#infloop
|
14
|
+
def infloop(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Common.infloop(*args)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/pushstr_array'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Common
|
9
|
-
#
|
11
|
+
# @overload pushstr_array(reg, array)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#pushstr_array
|
10
14
|
def pushstr_array(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :i386) do
|
12
16
|
cat X86::Common.pushstr_array(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/common/common'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/common/setregs'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Common
|
9
|
-
#
|
11
|
+
# @overload setregs(reg_context, stack_allowed: true)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Common#setregs
|
10
14
|
def setregs(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :i386) do
|
12
16
|
cat X86::Common.setregs(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/cat'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module I386
|
10
|
+
module Linux
|
11
|
+
# @overload cat(filename, fd: 1)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#cat
|
14
|
+
def cat(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Linux.cat(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/execve'
|
3
5
|
|
@@ -6,10 +8,12 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Linux
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
# @overload execve(path, argv, envp)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#execve
|
14
|
+
def execve(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Linux.execve(*args)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/exit'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module I386
|
10
|
+
module Linux
|
11
|
+
# @overload exit(status = 0)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#exit
|
14
|
+
def exit(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Linux.exit(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/ls'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Linux
|
9
|
-
#
|
11
|
+
# @overload ls(dir = '.')
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#ls
|
10
14
|
def ls(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :i386) do
|
12
16
|
cat X86::Linux.ls(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
3
|
+
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
4
|
+
require 'pwnlib/shellcraft/generators/x86/linux/open'
|
5
|
+
|
6
|
+
module Pwnlib
|
7
|
+
module Shellcraft
|
8
|
+
module Generators
|
9
|
+
module I386
|
10
|
+
module Linux
|
11
|
+
# @overload open(filename, flags = 'O_RDONLY', mode = 0)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#open
|
14
|
+
def open(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Linux.open(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/sh'
|
3
5
|
|
@@ -6,9 +8,11 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Linux
|
9
|
-
#
|
11
|
+
# @overload sh(argv: false)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#sh
|
10
14
|
def sh(*args)
|
11
|
-
context.local(arch:
|
15
|
+
context.local(arch: :i386) do
|
12
16
|
cat X86::Linux.sh(*args)
|
13
17
|
end
|
14
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
|
1
3
|
require 'pwnlib/shellcraft/generators/i386/linux/linux'
|
2
4
|
require 'pwnlib/shellcraft/generators/x86/linux/syscall'
|
3
5
|
|
@@ -6,10 +8,12 @@ module Pwnlib
|
|
6
8
|
module Generators
|
7
9
|
module I386
|
8
10
|
module Linux
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
# @overload syscall(*arguments)
|
12
|
+
#
|
13
|
+
# @see Generators::X86::Linux#syscall
|
14
|
+
def syscall(*args)
|
15
|
+
context.local(arch: :i386) do
|
16
|
+
cat X86::Linux.syscall(*args)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|