pwn 0.5.23 → 0.5.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 891006d13f97eb099047b3596fef7232f66532b32431914990360d0d0274fa26
4
- data.tar.gz: a426cafcccb59fbaf64a1d728b0e45a251dd713f9684aa894f8b56d2e34acde6
3
+ metadata.gz: 833f2055842c7ea2beaaa250cbf13763b540cbdc8ee79e8b8d68a5fc14147adb
4
+ data.tar.gz: '0586ab2fb44e10f0bad1f597827368f6c9b915159545aed0a5608f125b5eefc1'
5
5
  SHA512:
6
- metadata.gz: b71a807d4441bd2b3a94a76c02d80a6505e82a87ffe8f7469f1bd88f71a89e1dfc9220606765726dea68065c4532d40c016090aeb2aceaeae6b7ba0afc2891a4
7
- data.tar.gz: c9d404cd2f07bdee5bdc6bda8f256d255997220dfc584dc5ca559b794b24f90104bec3e138cf71d49d983015a17b81b3bc2a038d72c929c361c07673ffb08e9f
6
+ metadata.gz: 3917d7c131039161725cac99d74528a31ecdb15cb28bf9dce318be2330c23ec5363876728fda087f247843d83bf3cc0fec330080c22721631f851039262008ed
7
+ data.tar.gz: ecfb3ed335b995423363f8c9de534c1bdb4422a9b485465d677e01bcb814c167080356903d0feecefd72b1430428b9f30d798db53f2a1968bd06e78a955b479a
data/Gemfile CHANGED
@@ -44,6 +44,7 @@ gem 'jwt', '2.8.0'
44
44
  gem 'libusb', '0.6.4'
45
45
  gem 'luhn', '1.0.2'
46
46
  gem 'mail', '2.8.1'
47
+ gem 'metasm', '1.0.5'
47
48
  # gem 'mongo', '2.19.3'
48
49
  gem 'msfrpc-client', '1.1.2'
49
50
  gem 'netaddr', '2.0.6'
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ cd /opt/pwn
37
37
  $ ./install.sh
38
38
  $ ./install.sh ruby-gem
39
39
  $ pwn
40
- pwn[v0.5.23]:001 >>> PWN.help
40
+ pwn[v0.5.24]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.3.0@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.5.23]:001 >>> PWN.help
55
+ pwn[v0.5.24]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
  If you're using a multi-user install of RVM do:
@@ -62,7 +62,7 @@ $ rvm use ruby-3.3.0@pwn
62
62
  $ rvmsudo gem uninstall --all --executables pwn
63
63
  $ rvmsudo gem install --verbose pwn
64
64
  $ pwn
65
- pwn[v0.5.23]:001 >>> PWN.help
65
+ pwn[v0.5.24]:001 >>> PWN.help
66
66
  ```
67
67
 
68
68
  PWN periodically upgrades to the latest version of Ruby which is reflected in `/opt/pwn/.ruby-version`. The easiest way to upgrade to the latest version of Ruby from a previous PWN installation is to run the following script:
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'metasm'
3
4
  require 'tempfile'
4
5
 
5
6
  module PWN
@@ -9,18 +10,29 @@ module PWN
9
10
  # Supported Method Parameters::
10
11
  # PWN::Plugins::Assembly.opcodes_to_asm(
11
12
  # opcodes: 'required - hex escaped opcode(s) (e.g. "\x90\x90\x90")',
12
- # arch: 'optional - objdump -i architecture (defaults to i386)'
13
+ # arch: 'optional - architecture returned from objdump --info (defaults to PWN::Plugins::DetectOS.arch)',
14
+ # endian: 'optional - endianess (defaults to :little)'
13
15
  # )
14
16
 
15
17
  public_class_method def self.opcodes_to_asm(opts = {})
16
18
  opcodes = opts[:opcodes]
17
- arch = opts[:arch] || 'i386'
19
+ arch = opts[:arch] ||= PNW::Plugins::DetectOS.arch
20
+ endian = opts[:endian] ||= :little
18
21
 
19
- opcodes_tmp = Tempfile.new('pwn_opcodes')
20
- File.binwrite(opcodes_tmp.path, opcodes)
21
- # TODO: Implement support for other architectures
22
- # for both 32bit and 64bit
23
- `objdump --disassemble-all --target binary --architecture #{arch} #{opcodes_tmp.path}`
22
+ case arch
23
+ when 'i386'
24
+ arch_obj = Metasm::Ia32.new(endian)
25
+ when 'amd64', 'x86_64'
26
+ arch_obj = Metasm::X86_64.new(endian)
27
+ when 'armv71'
28
+ arch_obj = Metasm::ARM.new(endian)
29
+ when 'aarch64'
30
+ arch_obj = Metasm::ARM64.new(endian)
31
+ else
32
+ raise "Unsupported architecture: #{arch}"
33
+ end
34
+
35
+ Metasm::Shellcode.disassemble(arch_obj, opcodes).to_s
24
36
  rescue StandardError => e
25
37
  raise e
26
38
  ensure
@@ -30,29 +42,31 @@ module PWN
30
42
  # Supported Method Parameters::
31
43
  # PWN::Plugins::Assembly.asm_to_opcodes(
32
44
  # asm: 'required - assembly instruction(s) (e.g. 'nop\nnop\nnop\njmp rsp\n)',
33
- # arch: 'optional - objdump -i architecture (defaults to i386)'
45
+ # arch: 'optional - architecture returned from objdump --info (defaults to PWN::Plugins::DetectOS.arch)',
46
+ # endian: 'optional - endianess (defaults to :little)'
34
47
  # )
35
48
 
36
49
  public_class_method def self.asm_to_opcodes(opts = {})
37
50
  asm = opts[:asm]
38
- arch = opts[:arch] || 'i386'
39
-
40
- asm_code = ".global _start\n_start:\n#{asm}"
51
+ arch = opts[:arch] ||= PNW::Plugins::DetectOS.arch
52
+ endian = opts[:endian] ||= :little
41
53
 
42
- asm_tmp = Tempfile.new('pwn_asm')
43
- asm_tmp.write(asm_code)
44
- asm_tmp.close
54
+ case arch
55
+ when 'i386'
56
+ arch_obj = Metasm::Ia32.new(endian)
57
+ when 'amd64', 'x86_64'
58
+ arch_obj = Metasm::X86_64.new(endian)
59
+ when 'armv71'
60
+ arch_obj = Metasm::ARM.new(endian)
61
+ when 'aarch64'
62
+ arch_obj = Metasm::ARM64.new(endian)
63
+ else
64
+ raise "Unsupported architecture: #{arch}"
65
+ end
45
66
 
46
- asm_tmp_o = "#{asm_tmp.path}.o"
47
- # TODO: Implement support for other architectures
48
- # for both 32bit and 64bit
49
- system('as', '-o', asm_tmp_o, asm_tmp.path)
50
- `objdump --disassemble-all #{asm_tmp.path}.o`
67
+ Metasm::Shellcode.assemble(arch_obj, asm).encode_string
51
68
  rescue StandardError => e
52
69
  raise e
53
- ensure
54
- files = [asm_tmp.path, asm_tmp_o]
55
- FileUtils.rm_f(files) if File.exist?(asm_tmp.path)
56
70
  end
57
71
 
58
72
  # Author(s):: 0day Inc. <request.pentest@0dayinc.com>
@@ -69,12 +83,14 @@ module PWN
69
83
  puts "USAGE:
70
84
  #{self}.opcodes_to_asm(
71
85
  opcodes: 'required - hex escaped opcode(s) (e.g. \"\\x90\\x90\\x90\")',
72
- arch: 'optional - objdump -i architecture (defaults to i386)'
86
+ arch: 'optional - architecture returned from objdump --info (defaults to PWN::Plugins::DetectOS.arch)',
87
+ endian: 'optional - endianess (defaults to :little)'
73
88
  )
74
89
 
75
90
  #{self}.asm_to_opcodes(
76
- asm: 'required - assembly instruction(s) (e.g. 'jmp rsp')',
77
- arch: 'optional - objdump -i architecture (defaults to i386)'
91
+ asm: 'required - assembly instruction(s) (e.g. 'nop\nnop\nnop\njmp rsp\n)',
92
+ arch: 'optional - architecture returned from objdump --info (defaults to PWN::Plugins::DetectOS.arch)',
93
+ endian: 'optional - endianess (defaults to :little)'
78
94
  )
79
95
 
80
96
  #{self}.authors
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.5.23'
4
+ VERSION = '0.5.24'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.23
4
+ version: 0.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -458,6 +458,20 @@ dependencies:
458
458
  - - '='
459
459
  - !ruby/object:Gem::Version
460
460
  version: 2.8.1
461
+ - !ruby/object:Gem::Dependency
462
+ name: metasm
463
+ requirement: !ruby/object:Gem::Requirement
464
+ requirements:
465
+ - - '='
466
+ - !ruby/object:Gem::Version
467
+ version: 1.0.5
468
+ type: :runtime
469
+ prerelease: false
470
+ version_requirements: !ruby/object:Gem::Requirement
471
+ requirements:
472
+ - - '='
473
+ - !ruby/object:Gem::Version
474
+ version: 1.0.5
461
475
  - !ruby/object:Gem::Dependency
462
476
  name: msfrpc-client
463
477
  requirement: !ruby/object:Gem::Requirement