pwn 0.4.542 → 0.4.543

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: 21ef9d6fdf6c9eccf69de573293a4cd3b1b1b8ee223886539030d13e330d9fac
4
- data.tar.gz: 71f07204cdf4432c45f12e1cebf1a0da3f41ba370e60396b833b3f8d4b752928
3
+ metadata.gz: a5d887b5d0434dcaa46ef673de80a11641844733b4589b622c8da8c3eab6e961
4
+ data.tar.gz: 3e35c91f769c6969de334f40e6c91c7f411051ddb2091bd9df0efc8c88b0b1c9
5
5
  SHA512:
6
- metadata.gz: 39b1c9849f9396e972b24f26d2ae4b7b9aead4afc9ad865231fc60828360a77c237522ff2df2fda302930e381f1c3056f1917e03fa25468aa8e722cadcf526ab
7
- data.tar.gz: 426a22f81eb171d98298c58e1176469ec623aa4e8adf35d82d78553ead7b8dddfd1eecf7aa658ffc076eccf6404c3bb93cc1b722de855f411fd3bfb463e54fb6
6
+ metadata.gz: 015c611721dd8c43fc06f4a8eb88ccbe7c3deb8f959f7c0cd56e14e61ae509c2f39c85b56fd16e6c6dc230993177818b95ac9c71614f3666d79131343971afb0
7
+ data.tar.gz: 4e475ccc1edcfcbcc5220106ecb6accd68104513b3264235bf6dadd51eb9c2d9ecc5ad58576c8954f0ae9359d258fffc543e3239f8db9125e76c685b91fbf4bb
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ rvm use ruby-3.1.2@pwn
37
37
  $ rvm list gemsets
38
38
  $ gem install --verbose pwn
39
39
  $ pwn
40
- pwn[v0.4.542]:001 >>> PWN.help
40
+ pwn[v0.4.543]: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.1.2@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.4.542]:001 >>> PWN.help
55
+ pwn[v0.4.543]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
data/bin/pwn_sast CHANGED
@@ -95,6 +95,7 @@ begin
95
95
  Logger
96
96
  OuterHTML
97
97
  Password
98
+ PHPInputMechanisms
98
99
  PHPTypeJuggling
99
100
  PomVersion
100
101
  Port
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'socket'
4
+
5
+ module PWN
6
+ module SAST
7
+ # SAST Module used to identify HTTP input
8
+ # mechanisms that exist in PHP code (e.g. $_REQUEST, $_GET, etc.)
9
+ module PHPInputMechanisms
10
+ @@logger = PWN::Plugins::PWNLogger.create
11
+
12
+ # Supported Method Parameters::
13
+ # PWN::SAST::PHPInputMechanisms.scan(
14
+ # dir_path: 'optional path to dir defaults to .'
15
+ # git_repo_root_uri: 'optional http uri of git repo scanned'
16
+ # )
17
+
18
+ public_class_method def self.scan(opts = {})
19
+ dir_path = opts[:dir_path]
20
+ git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub
21
+ result_arr = []
22
+ logger_results = ''
23
+
24
+ PWN::Plugins::FileFu.recurse_dir(dir_path: dir_path) do |entry|
25
+ if (File.file?(entry) && File.basename(entry) !~ /^pwn.+(html|json|db)$/ && File.basename(entry) !~ /\.JS-BEAUTIFIED$/) && File.extname(entry).include?('.php') && entry !~ /test/i
26
+ line_no_and_contents_arr = []
27
+ entry_beautified = false
28
+
29
+ if File.extname(entry) == '.js' && (`wc -l #{entry}`.split.first.to_i < 20 || entry.include?('.min.js') || entry.include?('-all.js'))
30
+ js_beautify = `js-beautify #{entry} > #{entry}.JS-BEAUTIFIED`.to_s.scrub
31
+ entry = "#{entry}.JS-BEAUTIFIED"
32
+ entry_beautified = true
33
+ end
34
+
35
+ test_case_filter = "
36
+ grep -Fn \
37
+ -e '$_COOKIE' \
38
+ -e '$_FILES' \
39
+ -e '$_GET' \
40
+ -e '$_POST' \
41
+ -e '$_REQUEST' \
42
+ -e '$_SERVER' \
43
+ -e '$_SESSION' #{entry}
44
+ "
45
+
46
+ str = `#{test_case_filter}`.to_s.scrub
47
+
48
+ if str.to_s.empty?
49
+ # If str length is >= 64 KB do not include results. (Due to Mongo Document Size Restrictions)
50
+ logger_results = "#{logger_results}~" # Catching bugs is good :)
51
+ else
52
+ str = "1:Result larger than 64KB -> Size: #{str.to_s.length}. Please click the \"Path\" link for more details." if str.to_s.length >= 64_000
53
+
54
+ hash_line = {
55
+ timestamp: Time.now.strftime('%Y-%m-%d %H:%M:%S.%9N %z').to_s,
56
+ security_references: security_references,
57
+ filename: { git_repo_root_uri: git_repo_root_uri, entry: entry },
58
+ line_no_and_contents: '',
59
+ raw_content: str,
60
+ test_case_filter: test_case_filter
61
+ }
62
+
63
+ # COMMMENT: Must be a better way to implement this (regex is kinda funky)
64
+ line_contents_split = str.split(/^(\d{1,}):|\n(\d{1,}):/)[1..-1]
65
+ line_no_count = line_contents_split.length # This should always be an even number
66
+ current_count = 0
67
+ while line_no_count > current_count
68
+ line_no = line_contents_split[current_count]
69
+ contents = line_contents_split[current_count + 1]
70
+ if Dir.exist?("#{dir_path}/.git") ||
71
+ Dir.exist?('.git')
72
+
73
+ repo_root = dir_path
74
+ repo_root = '.' if Dir.exist?('.git')
75
+
76
+ author = PWN::Plugins::Git.get_author(
77
+ repo_root: repo_root,
78
+ from_line: line_no,
79
+ to_line: line_no,
80
+ target_file: entry,
81
+ entry_beautified: entry_beautified
82
+ )
83
+ else
84
+ author = 'N/A'
85
+ end
86
+ hash_line[:line_no_and_contents] = line_no_and_contents_arr.push(
87
+ line_no: line_no,
88
+ contents: contents,
89
+ author: author
90
+ )
91
+
92
+ current_count += 2
93
+ end
94
+ result_arr.push(hash_line)
95
+ logger_results = "#{logger_results}x" # Seeing progress is good :)
96
+ end
97
+ end
98
+ end
99
+ logger_banner = "http://#{Socket.gethostname}:8808/doc_root/pwn-#{PWN::VERSION.to_s.scrub}/#{to_s.scrub.gsub('::', '/')}.html"
100
+ if logger_results.empty?
101
+ @@logger.info("#{logger_banner}: No files applicable to this test case.\n")
102
+ else
103
+ @@logger.info("#{logger_banner} => #{logger_results}complete.\n")
104
+ end
105
+ result_arr
106
+ rescue StandardError => e
107
+ raise e
108
+ end
109
+
110
+ # Used primarily to map NIST 800-53 Revision 4 Security Controls
111
+ # https://web.nvd.nist.gov/view/800-53/Rev4/impact?impactName=HIGH
112
+ # to PWN Exploit & Static Code Anti-Pattern Matching Modules to
113
+ # Determine the level of Testing Coverage w/ PWN.
114
+
115
+ public_class_method def self.security_references
116
+ {
117
+ sast_module: self,
118
+ section: 'DEVELOPER SECURITY AND PRIVACY ARCHITECTURE AND DESIGN',
119
+ nist_800_53_uri: 'https://csrc.nist.gov/Projects/risk-management/sp800-53-controls/release-search#/control/?version=5.1&number=SA-17',
120
+ cwe_id: '661',
121
+ cwe_uri: 'https://cwe.mitre.org/data/definitions/661.html'
122
+ }
123
+ rescue StandardError => e
124
+ raise e
125
+ end
126
+
127
+ # Author(s):: 0day Inc. <request.pentest@0dayinc.com>
128
+
129
+ public_class_method def self.authors
130
+ "AUTHOR(S):
131
+ 0day Inc. <request.pentest@0dayinc.com>
132
+ "
133
+ end
134
+
135
+ # Display Usage for this Module
136
+
137
+ public_class_method def self.help
138
+ puts "USAGE:
139
+ sast_arr = #{self}.scan(
140
+ :dir_path => 'optional path to dir defaults to .',
141
+ :git_repo_root_uri => 'optional http uri of git repo scanned'
142
+ )
143
+
144
+ #{self}.authors
145
+ "
146
+ end
147
+ end
148
+ end
149
+ end
@@ -4,13 +4,13 @@ require 'socket'
4
4
 
5
5
  module PWN
6
6
  module SAST
7
- # SAST Module used to identify command
8
- # execution residing within Java source code.
7
+ # SAST Module used to identify loose comparisons
8
+ # (i.e. == instead of ===) within PHP source code.
9
9
  module PHPTypeJuggling
10
10
  @@logger = PWN::Plugins::PWNLogger.create
11
11
 
12
12
  # Supported Method Parameters::
13
- # PWN::SAST::Log4J.scan(
13
+ # PWN::SAST::PHPTypeJuggling.scan(
14
14
  # dir_path: 'optional path to dir defaults to .'
15
15
  # git_repo_root_uri: 'optional http uri of git repo scanned'
16
16
  # )
@@ -34,7 +34,8 @@ module PWN
34
34
 
35
35
  test_case_filter = "
36
36
  grep -Fn \
37
- -e '==' #{entry}
37
+ -e '==' #{entry} \ |
38
+ grep -v '==='
38
39
  "
39
40
 
40
41
  str = `#{test_case_filter}`.to_s.scrub
data/lib/pwn/sast.rb CHANGED
@@ -29,6 +29,7 @@ module PWN
29
29
  autoload :Logger, 'pwn/sast/logger'
30
30
  autoload :OuterHTML, 'pwn/sast/outer_html'
31
31
  autoload :Password, 'pwn/sast/password'
32
+ autoload :PHPInputMechanisms, 'pwn/sast/php_input_mechanisms'
32
33
  autoload :PHPTypeJuggling, 'pwn/sast/php_type_juggling'
33
34
  autoload :PomVersion, 'pwn/sast/pom_version'
34
35
  autoload :Port, 'pwn/sast/port'
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.4.542'
4
+ VERSION = '0.4.543'
5
5
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe PWN::SAST::PHPInputMechanisms do
6
+ it 'scan method should exist' do
7
+ scan_response = PWN::SAST::PHPInputMechanisms
8
+ expect(scan_response).to respond_to :scan
9
+ end
10
+
11
+ it 'should display information for security_references' do
12
+ security_references_response = PWN::SAST::PHPInputMechanisms
13
+ expect(security_references_response).to respond_to :security_references
14
+ end
15
+
16
+ it 'should display information for authors' do
17
+ authors_response = PWN::SAST::PHPInputMechanisms
18
+ expect(authors_response).to respond_to :authors
19
+ end
20
+
21
+ it 'should display information for existing help method' do
22
+ help_response = PWN::SAST::PHPInputMechanisms
23
+ expect(help_response).to respond_to :help
24
+ end
25
+ 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.4.542
4
+ version: 0.4.543
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -1641,6 +1641,7 @@ files:
1641
1641
  - lib/pwn/sast/logger.rb
1642
1642
  - lib/pwn/sast/outer_html.rb
1643
1643
  - lib/pwn/sast/password.rb
1644
+ - lib/pwn/sast/php_input_mechanisms.rb
1644
1645
  - lib/pwn/sast/php_type_juggling.rb
1645
1646
  - lib/pwn/sast/pom_version.rb
1646
1647
  - lib/pwn/sast/port.rb
@@ -1939,6 +1940,7 @@ files:
1939
1940
  - spec/lib/pwn/sast/log4j_spec.rb
1940
1941
  - spec/lib/pwn/sast/logger_spec.rb
1941
1942
  - spec/lib/pwn/sast/password_spec.rb
1943
+ - spec/lib/pwn/sast/php_input_mechanisms_spec.rb
1942
1944
  - spec/lib/pwn/sast/php_type_juggling_spec.rb
1943
1945
  - spec/lib/pwn/sast/pom_version_spec.rb
1944
1946
  - spec/lib/pwn/sast/port_spec.rb