Browse Source

Land #7156, use windows_error gem for constants

dmohanty-r7 3 years ago
parent
commit
b027176799
No account linked to committer's email address

+ 2
- 0
Gemfile.lock View File

@@ -46,6 +46,7 @@ PATH
46 46
       sshkey
47 47
       tzinfo
48 48
       tzinfo-data
49
+      windows_error
49 50
 
50 51
 GEM
51 52
   remote: https://rubygems.org/
@@ -278,6 +279,7 @@ GEM
278 279
       thread_safe (~> 0.1)
279 280
     tzinfo-data (1.2016.6)
280 281
       tzinfo (>= 1.0.0)
282
+    windows_error (0.0.2)
281 283
     xpath (2.0.0)
282 284
       nokogiri (~> 1.3)
283 285
     yard (0.9.0)

+ 2
- 0
lib/msf/core.rb View File

@@ -16,6 +16,8 @@ require 'msf/sanity'
16 16
 # The framework-core depends on Rex
17 17
 require 'rex'
18 18
 require 'rex/ui'
19
+require 'rex/arch'
20
+include Rex::Arch
19 21
 
20 22
 module Msf
21 23
   autoload :Author, 'msf/core/author'

+ 3
- 0
lib/msf/core/exploit/mixins.rb View File

@@ -120,3 +120,6 @@ require 'msf/core/exploit/kerberos/client'
120 120
 
121 121
 # Fortinet
122 122
 require 'msf/core/exploit/fortinet'
123
+
124
+# Other
125
+require 'msf/core/exploit/windows_constants'

+ 5
- 1
lib/msf/core/exploit/smb/client/psexec.rb View File

@@ -1,5 +1,9 @@
1 1
 # -*- coding: binary -*-
2 2
 require 'rex/proto/dcerpc/svcctl'
3
+require 'windows_error'
4
+require 'windows_error/win32'
5
+
6
+include WindowsError::Win32
3 7
 
4 8
 module Msf
5 9
 
@@ -13,7 +17,7 @@ module Msf
13 17
 
14 18
 module Exploit::Remote::SMB::Client::Psexec
15 19
 
16
-  include Rex::Constants::Windows
20
+  include Msf::Exploit::Windows_Constants
17 21
   include Msf::Exploit::Remote::DCERPC
18 22
   include Msf::Exploit::Remote::SMB::Client::Authenticated
19 23
 

lib/rex/constants/windows.rb → lib/msf/core/exploit/windows_constants.rb View File

@@ -1,5 +1,5 @@
1
-module Rex::Constants
2
-module Windows
1
+module Msf
2
+module Exploit::Windows_Constants
3 3
 
4 4
   ##
5 5
   #
@@ -10,18 +10,6 @@ module Windows
10 10
 
11 11
   STANDARD_RIGHTS_REQUIRED = 0x000F0000
12 12
 
13
-  ##
14
-  #
15
-  # Errors
16
-  #
17
-  ##
18
-
19
-  ERROR_SUCCESS = 0x0
20
-  ERROR_FILE_NOT_FOUND = 0x2
21
-  ERROR_ACCESS_DENIED = 0x5
22
-  ERROR_SERVICE_REQUEST_TIMEOUT = 0x41D
23
-  ERROR_SERVICE_EXISTS = 0x431
24
-
25 13
   ##
26 14
   #
27 15
   # SVCCTL Protocol Functions

+ 0
- 1
lib/msf/core/payload/uuid.rb View File

@@ -2,7 +2,6 @@
2 2
 
3 3
 require 'msf/core'
4 4
 require 'msf/core/module/platform'
5
-require 'rex/constants'
6 5
 require 'rex/text'
7 6
 
8 7
 #

+ 0
- 1
lib/rex.rb View File

@@ -59,7 +59,6 @@ require 'rex/struct2'
59 59
 require 'rex/ole'
60 60
 
61 61
 # Generic classes
62
-require 'rex/constants'
63 62
 require 'rex/exceptions'
64 63
 require 'rex/transformer'
65 64
 require 'rex/random_identifier'

+ 0
- 127
lib/rex/constants.rb View File

@@ -1,127 +0,0 @@
1
-# -*- coding: binary -*-
2
-
3
-#
4
-# Log severities
5
-#
6
-LOG_ERROR = 'error'
7
-LOG_DEBUG = 'debug'
8
-LOG_INFO  = 'info'
9
-LOG_WARN  = 'warn'
10
-LOG_RAW   = 'raw'
11
-
12
-##
13
-#
14
-# Log levels
15
-#
16
-##
17
-
18
-#
19
-# LEV_0 - Default
20
-#
21
-# This log level is the default log level if none is specified.  It should be
22
-# used when a log message should always be displayed when logging is enabled.
23
-# Very few log messages should occur at this level aside from necessary
24
-# information logging and error/warning logging.  Debug logging at level zero
25
-# is not advised.
26
-#
27
-LEV_0     = 0
28
-
29
-#
30
-# LEV_1 - Extra
31
-#
32
-# This log level should be used when extra information may be needed to
33
-# understand the cause of an error or warning message or to get debugging
34
-# information that might give clues as to why something is happening.  This
35
-# log level should be used only when information may be useful to understanding
36
-# the behavior of something at a basic level.  This log level should not be
37
-# used in an exhaustively verbose fashion.
38
-#
39
-LEV_1     = 1
40
-
41
-#
42
-# LEV_2 - Verbose
43
-#
44
-# This log level should be used when verbose information may be needed to
45
-# analyze the behavior of the framework.  This should be the default log
46
-# level for all detailed information not falling into LEV_0 or LEV_1.
47
-# It is recommended that this log level be used by default if you are
48
-# unsure.
49
-#
50
-LEV_2     = 2
51
-
52
-#
53
-# LEV_3 - Insanity
54
-#
55
-# This log level should contain very verbose information about the
56
-# behavior of the framework, such as detailed information about variable
57
-# states at certain phases including, but not limited to, loop iterations,
58
-# function calls, and so on.  This log level will rarely be displayed,
59
-# but when it is the information provided should make it easy to analyze
60
-# any problem.
61
-#
62
-LEV_3     = 3
63
-
64
-
65
-#
66
-# Architecture constants
67
-#
68
-ARCH_ANY     = '_any_'
69
-ARCH_X86     = 'x86'
70
-ARCH_X86_64  = 'x86_64'
71
-ARCH_X64     = 'x64' # To be used for compatability with ARCH_X86_64
72
-ARCH_MIPS    = 'mips'
73
-ARCH_MIPSLE  = 'mipsle'
74
-ARCH_MIPSBE  = 'mipsbe'
75
-ARCH_PPC     = 'ppc'
76
-ARCH_PPC64   = 'ppc64'
77
-ARCH_CBEA    = 'cbea'
78
-ARCH_CBEA64  = 'cbea64'
79
-ARCH_SPARC   = 'sparc'
80
-ARCH_CMD     = 'cmd'
81
-ARCH_PHP     = 'php'
82
-ARCH_TTY     = 'tty'
83
-ARCH_ARMLE   = 'armle'
84
-ARCH_ARMBE   = 'armbe'
85
-ARCH_JAVA    = 'java'
86
-ARCH_RUBY    = 'ruby'
87
-ARCH_DALVIK  = 'dalvik'
88
-ARCH_PYTHON  = 'python'
89
-ARCH_NODEJS  = 'nodejs'
90
-ARCH_FIREFOX = 'firefox'
91
-ARCH_ZARCH   = 'zarch'
92
-ARCH_TYPES   =
93
-  [
94
-    ARCH_X86,
95
-    ARCH_X86_64,
96
-    ARCH_MIPS,
97
-    ARCH_MIPSLE,
98
-    ARCH_MIPSBE,
99
-    ARCH_PPC,
100
-    ARCH_PPC64,
101
-    ARCH_CBEA,
102
-    ARCH_CBEA64,
103
-    ARCH_SPARC,
104
-    ARCH_ARMLE,
105
-    ARCH_ARMBE,
106
-    ARCH_CMD,
107
-    ARCH_PHP,
108
-    ARCH_TTY,
109
-    ARCH_JAVA,
110
-    ARCH_RUBY,
111
-    ARCH_DALVIK,
112
-    ARCH_PYTHON,
113
-    ARCH_NODEJS,
114
-    ARCH_FIREFOX,
115
-    ARCH_ZARCH,
116
-  ]
117
-
118
-ARCH_ALL = ARCH_TYPES
119
-
120
-#
121
-# Endian constants
122
-#
123
-ENDIAN_LITTLE = 0
124
-ENDIAN_BIG    = 1
125
-
126
-IS_ENDIAN_LITTLE = ( [1].pack('s') == "\x01\x00" ) ? true : false
127
-IS_ENDIAN_BIG    = ( not IS_ENDIAN_LITTLE )

+ 61
- 1
lib/rex/logging.rb View File

@@ -1,4 +1,64 @@
1 1
 # -*- coding: binary -*-
2 2
 
3
-require 'rex/constants' # for LEV_'s
3
+#
4
+# Log severities
5
+#
6
+LOG_ERROR = 'error'
7
+LOG_DEBUG = 'debug'
8
+LOG_INFO  = 'info'
9
+LOG_WARN  = 'warn'
10
+LOG_RAW   = 'raw'
11
+
12
+##
13
+#
14
+# Log levels
15
+#
16
+##
17
+
18
+#
19
+# LEV_0 - Default
20
+#
21
+# This log level is the default log level if none is specified.  It should be
22
+# used when a log message should always be displayed when logging is enabled.
23
+# Very few log messages should occur at this level aside from necessary
24
+# information logging and error/warning logging.  Debug logging at level zero
25
+# is not advised.
26
+#
27
+LEV_0     = 0
28
+
29
+#
30
+# LEV_1 - Extra
31
+#
32
+# This log level should be used when extra information may be needed to
33
+# understand the cause of an error or warning message or to get debugging
34
+# information that might give clues as to why something is happening.  This
35
+# log level should be used only when information may be useful to understanding
36
+# the behavior of something at a basic level.  This log level should not be
37
+# used in an exhaustively verbose fashion.
38
+#
39
+LEV_1     = 1
40
+
41
+#
42
+# LEV_2 - Verbose
43
+#
44
+# This log level should be used when verbose information may be needed to
45
+# analyze the behavior of the framework.  This should be the default log
46
+# level for all detailed information not falling into LEV_0 or LEV_1.
47
+# It is recommended that this log level be used by default if you are
48
+# unsure.
49
+#
50
+LEV_2     = 2
51
+
52
+#
53
+# LEV_3 - Insanity
54
+#
55
+# This log level should contain very verbose information about the
56
+# behavior of the framework, such as detailed information about variable
57
+# states at certain phases including, but not limited to, loop iterations,
58
+# function calls, and so on.  This log level will rarely be displayed,
59
+# but when it is the information provided should make it easy to analyze
60
+# any problem.
61
+#
62
+LEV_3     = 3
63
+
4 64
 require 'rex/logging/log_dispatcher'

+ 0
- 1
lib/rex/logging/log_sink.rb View File

@@ -1,5 +1,4 @@
1 1
 # -*- coding: binary -*-
2
-require 'rex/constants'
3 2
 
4 3
 module Rex
5 4
 module Logging

+ 5
- 2
lib/rex/proto/dcerpc/svcctl/packet.rb View File

@@ -7,13 +7,16 @@ module Rex
7 7
 ###
8 8
 module Proto::DCERPC::SVCCTL
9 9
 
10
-  require 'rex/constants/windows'
10
+  require 'windows_error'
11
+  require 'windows_error/win32'
12
+  require 'msf/core/exploit/windows_constants'
11 13
   NDR = Rex::Encoder::NDR
12 14
 
13 15
 
14 16
 class Client
15 17
 
16
-  include Rex::Constants::Windows
18
+  include WindowsError::Win32
19
+  include Msf::Exploit::Windows_Constants
17 20
 
18 21
   attr_accessor :dcerpc_client
19 22
 

+ 2
- 0
metasploit-framework.gemspec View File

@@ -102,6 +102,8 @@ Gem::Specification.new do |spec|
102 102
   spec.add_runtime_dependency 'sshkey'
103 103
   # BitStruct Library used for handling certain Protocol Header/Packet construction
104 104
   spec.add_runtime_dependency 'bit-struct'
105
+  # Library for interpreting Windows error codes and strings
106
+  spec.add_runtime_dependency 'windows_error'
105 107
 
106 108
   #
107 109
   # Protocol Libraries

Loading…
Cancel
Save