pwn 0.5.22 → 0.5.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15749f47853a4b45e74230feed45754ace51556f464cf43f37dbb27dad3ede54
4
- data.tar.gz: fc41034c5b35f20dfa42eca23546d7fbf77e328f705f269b0a0d46169e78c48e
3
+ metadata.gz: 833f2055842c7ea2beaaa250cbf13763b540cbdc8ee79e8b8d68a5fc14147adb
4
+ data.tar.gz: '0586ab2fb44e10f0bad1f597827368f6c9b915159545aed0a5608f125b5eefc1'
5
5
  SHA512:
6
- metadata.gz: 660c31ae940155bf196aeca986719ecdc74af3e82b83a6a4a99881a04c090483665049313dbb14de645eabc937a1bb6640c198019a70e0ef71fac57c1077959c
7
- data.tar.gz: 2a9ae878f1b5ea2cd67dd76243d05470f31a299b68c9df2f3c738f17c56a21ec1657753a218204deca7162aed437e3827a188a7d30bbfacc994575629a80f122
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.22]: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.22]: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.22]: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,16 +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
- `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
22
36
  rescue StandardError => e
23
37
  raise e
24
38
  ensure
@@ -27,26 +41,32 @@ module PWN
27
41
 
28
42
  # Supported Method Parameters::
29
43
  # PWN::Plugins::Assembly.asm_to_opcodes(
30
- # asm: 'required - assembly instruction(s) (e.g. 'nop\nnop\nnop\njmp rsp\n)'
44
+ # asm: 'required - assembly instruction(s) (e.g. 'nop\nnop\nnop\njmp rsp\n)',
45
+ # arch: 'optional - architecture returned from objdump --info (defaults to PWN::Plugins::DetectOS.arch)',
46
+ # endian: 'optional - endianess (defaults to :little)'
31
47
  # )
32
48
 
33
49
  public_class_method def self.asm_to_opcodes(opts = {})
34
50
  asm = opts[:asm]
51
+ arch = opts[:arch] ||= PNW::Plugins::DetectOS.arch
52
+ endian = opts[:endian] ||= :little
35
53
 
36
- asm_code = ".global _start\n_start:\n#{asm}"
37
-
38
- asm_tmp = Tempfile.new('pwn_asm')
39
- asm_tmp.write(asm_code)
40
- 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
41
66
 
42
- asm_tmp_o = "#{asm_tmp.path}.o"
43
- system('as', '-o', asm_tmp_o, asm_tmp.path)
44
- `objdump --disassemble-all #{asm_tmp.path}.o`
67
+ Metasm::Shellcode.assemble(arch_obj, asm).encode_string
45
68
  rescue StandardError => e
46
69
  raise e
47
- ensure
48
- files = [asm_tmp.path, asm_tmp_o]
49
- FileUtils.rm_f(files) if File.exist?(asm_tmp.path)
50
70
  end
51
71
 
52
72
  # Author(s):: 0day Inc. <request.pentest@0dayinc.com>
@@ -63,11 +83,14 @@ module PWN
63
83
  puts "USAGE:
64
84
  #{self}.opcodes_to_asm(
65
85
  opcodes: 'required - hex escaped opcode(s) (e.g. \"\\x90\\x90\\x90\")',
66
- 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)'
67
88
  )
68
89
 
69
90
  #{self}.asm_to_opcodes(
70
- asm: 'required - assembly instruction(s) (e.g. 'jmp rsp')'
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)'
71
94
  )
72
95
 
73
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.22'
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.22
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