pwn 0.5.448 → 0.5.449
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 +4 -4
- data/README.md +3 -3
- data/bin/pwn_sast +1 -0
- data/lib/pwn/plugins/pwn_logger.rb +1 -1
- data/lib/pwn/sast/test_case_engine.rb +2 -1
- data/lib/pwn/sast/use_after_free.rb +82 -0
- data/lib/pwn/sast.rb +1 -0
- data/lib/pwn/version.rb +1 -1
- data/spec/lib/pwn/sast/use_after_free_spec.rb +25 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026f4db44d2df46a90735ae2a51c22ae0d990686d2dc3bdc51c73343ce5ce002
|
4
|
+
data.tar.gz: a6ef1a6d4b9ed9d8d3614272dc94d55a7fd41cd14d27f6c01b7e8906b86bce81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c61a6bb8c18a1b9c76d651c8122604f52c3a0af803f2f0261ade38a749f9e57df9ee1a2a59e7c0a57e5e7dcaac92598690341f97286c06a7d6a89abf3448fbd
|
7
|
+
data.tar.gz: 1ed45d4b0decc713199b3aaacb2ffa726a675e61a3efab194dccb4a80a070f91bb2697f63f434bf7a908366c4b97a7ba71f715ebb0b303e184cf760b886d2111
|
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.
|
40
|
+
pwn[v0.5.449]:001 >>> PWN.help
|
41
41
|
```
|
42
42
|
|
43
43
|
[](https://youtu.be/G7iLUY4FzsI)
|
@@ -52,7 +52,7 @@ $ rvm use ruby-3.4.4@pwn
|
|
52
52
|
$ gem uninstall --all --executables pwn
|
53
53
|
$ gem install --verbose pwn
|
54
54
|
$ pwn
|
55
|
-
pwn[v0.5.
|
55
|
+
pwn[v0.5.449]: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.4.4@pwn
|
|
62
62
|
$ rvmsudo gem uninstall --all --executables pwn
|
63
63
|
$ rvmsudo gem install --verbose pwn
|
64
64
|
$ pwn
|
65
|
-
pwn[v0.5.
|
65
|
+
pwn[v0.5.449]: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:
|
data/bin/pwn_sast
CHANGED
@@ -29,7 +29,7 @@ module PWN
|
|
29
29
|
logger.level = Logger::INFO
|
30
30
|
end
|
31
31
|
|
32
|
-
logger.datetime_format = '%Y-%m-%d %H:%M:%S.%N'
|
32
|
+
logger.datetime_format = '%Y-%m-%d %H:%M:%S.%N%z'
|
33
33
|
|
34
34
|
logger.formatter = proc do |severity, _datetime, _progname, msg|
|
35
35
|
# TODO: Include datetime & progname vars
|
@@ -148,7 +148,8 @@ module PWN
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
151
|
+
sast_module = security_references[:sast_module].to_s.scrub.gsub('::', '/')
|
152
|
+
logger_banner = "http://#{Socket.gethostname}:8808/doc_root/pwn-#{PWN::VERSION.to_s.scrub}/#{sast_module}.html"
|
152
153
|
if logger_results.empty?
|
153
154
|
@@logger.info("#{logger_banner}: No files applicable to this test case.\n")
|
154
155
|
else
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
module PWN
|
7
|
+
module SAST
|
8
|
+
# SAST Module used to identify banned function
|
9
|
+
# calls in C & C++ code per:
|
10
|
+
# https://msdn.microsoft.com/en-us/library/bb288454.aspx
|
11
|
+
module UseAfterFree
|
12
|
+
# Supported Method Parameters::
|
13
|
+
# PWN::SAST::UseAfterFree.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
|
+
|
22
|
+
test_case_filter = "
|
23
|
+
grep -Fn \
|
24
|
+
-e 'calloc(' \
|
25
|
+
-e 'free(' \
|
26
|
+
-e 'malloc(' \
|
27
|
+
-e 'realloc(' {PWN_SAST_SRC_TARGET} 2> /dev/null
|
28
|
+
"
|
29
|
+
|
30
|
+
include_extensions = %w[.c .cats .idc .cpp .cc .cxx .c++ .cp .CPP .C .cppm .ixx .h .hpp .hxx .hh .h++ .inc .inl .ipp .tcc .tpp .txx .i .s .asm .o .obj .a .so .lib .dll .exe .pdb .vcxproj .sln .dsp .dsw .cbp .cmake .make .mk]
|
31
|
+
|
32
|
+
PWN::SAST::TestCaseEngine.execute(
|
33
|
+
test_case_filter: test_case_filter,
|
34
|
+
security_references: security_references,
|
35
|
+
dir_path: dir_path,
|
36
|
+
include_extensions: include_extensions,
|
37
|
+
git_repo_root_uri: git_repo_root_uri
|
38
|
+
)
|
39
|
+
rescue StandardError => e
|
40
|
+
raise e
|
41
|
+
end
|
42
|
+
|
43
|
+
# Used primarily to map NIST 800-53 Revision 4 Security Controls
|
44
|
+
# https://web.nvd.nist.gov/view/800-53/Rev4/impact?impactName=HIGH
|
45
|
+
# to PWN Exploit & Static Code Anti-Pattern Matching Modules to
|
46
|
+
# Determine the level of Testing Coverage w/ PWN.
|
47
|
+
|
48
|
+
public_class_method def self.security_references
|
49
|
+
{
|
50
|
+
sast_module: self,
|
51
|
+
section: 'MEMORY PROTECTION',
|
52
|
+
nist_800_53_uri: 'https://csrc.nist.gov/projects/cprt/catalog#/cprt/framework/version/SP_800_53_5_1_1/home?element=SI-16',
|
53
|
+
cwe_id: '416',
|
54
|
+
cwe_uri: 'https://cwe.mitre.org/data/definitions/416.html'
|
55
|
+
}
|
56
|
+
rescue StandardError => e
|
57
|
+
raise e
|
58
|
+
end
|
59
|
+
|
60
|
+
# Author(s):: 0day Inc. <support@0dayinc.com>
|
61
|
+
|
62
|
+
public_class_method def self.authors
|
63
|
+
"AUTHOR(S):
|
64
|
+
0day Inc. <support@0dayinc.com>
|
65
|
+
"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Display Usage for this Module
|
69
|
+
|
70
|
+
public_class_method def self.help
|
71
|
+
puts "USAGE:
|
72
|
+
sast_arr = #{self}.scan(
|
73
|
+
:dir_path => 'optional path to dir defaults to .',
|
74
|
+
:git_repo_root_uri => 'optional http uri of git repo scanned'
|
75
|
+
)
|
76
|
+
|
77
|
+
#{self}.authors
|
78
|
+
"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/pwn/sast.rb
CHANGED
@@ -54,6 +54,7 @@ module PWN
|
|
54
54
|
autoload :ThrowErrors, 'pwn/sast/throw_errors'
|
55
55
|
autoload :Token, 'pwn/sast/token'
|
56
56
|
autoload :TypeScriptTypeJuggling, 'pwn/sast/type_script_type_juggling'
|
57
|
+
autoload :UseAfterFree, 'pwn/sast/use_after_free'
|
57
58
|
autoload :Version, 'pwn/sast/version'
|
58
59
|
autoload :WindowLocationHash, 'pwn/sast/window_location_hash'
|
59
60
|
|
data/lib/pwn/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe PWN::SAST::UseAfterFree do
|
6
|
+
it 'scan method should exist' do
|
7
|
+
scan_response = PWN::SAST::UseAfterFree
|
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::UseAfterFree
|
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::UseAfterFree
|
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::UseAfterFree
|
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.5.
|
4
|
+
version: 0.5.449
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
@@ -1974,6 +1974,7 @@ files:
|
|
1974
1974
|
- lib/pwn/sast/throw_errors.rb
|
1975
1975
|
- lib/pwn/sast/token.rb
|
1976
1976
|
- lib/pwn/sast/type_script_type_juggling.rb
|
1977
|
+
- lib/pwn/sast/use_after_free.rb
|
1977
1978
|
- lib/pwn/sast/version.rb
|
1978
1979
|
- lib/pwn/sast/window_location_hash.rb
|
1979
1980
|
- lib/pwn/version.rb
|
@@ -2325,6 +2326,7 @@ files:
|
|
2325
2326
|
- spec/lib/pwn/sast/throw_errors_spec.rb
|
2326
2327
|
- spec/lib/pwn/sast/token_spec.rb
|
2327
2328
|
- spec/lib/pwn/sast/type_script_type_juggling_spec.rb
|
2329
|
+
- spec/lib/pwn/sast/use_after_free_spec.rb
|
2328
2330
|
- spec/lib/pwn/sast/version_spec.rb
|
2329
2331
|
- spec/lib/pwn/sast/window_location_hash_spec.rb
|
2330
2332
|
- spec/lib/pwn/sast_spec.rb
|