Module: Msf::Auxiliary::ManageEngineXnode::BasicChecks

Includes:
Action, Interact
Included in:
Msf::Auxiliary::ManageEngineXnode
Defined in:
lib/msf/core/auxiliary/manage_engine_xnode/basic_checks.rb

Instance Method Summary collapse

Methods included from Interact

#create_socket_for_xnode, #get_response, #send_to_sock

Methods included from Action

#action_admin_health, #action_authenticate, #action_dr_search, #action_xnode_info

Instance Method Details

#xnode_authenticate(sock, username, password) ⇒ Array

Performs an Xnode authentication attempt and parses the response

Parameters:

  • sock (Socket)

    Socket to use for the request

  • username (String)

    Username

  • password (String)

    Password

Returns:

  • (Array)

    Array containing a response code (Integer) and a status message (String)



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/msf/core/auxiliary/manage_engine_xnode/basic_checks.rb', line 51

def xnode_authenticate(sock, username, password)
  res = send_to_sock(sock, action_authenticate(username, password))

  unless res.instance_of?(Hash) && res.keys.include?('response') && res['response'].instance_of?(Hash)
    return [2, 'Received unexpected response when trying to authenticate.']
  end

  if res['response']['status'] == 'authentication_success'
    return [0, 'Successfully authenticated to the Xnode server.']
  end

  if res['response'].include?('error_msg')
    case res['response']['error_msg']
    when 'Authentication failed!'
      return [1, 'Failed to authenticate to the Xnode server.']
    when 'Remote request-processing disabled!!'
      return [1, 'Remote request-processing is disabled on the Xnode server.']
    end
  end

  [2, 'Received unexpected response when trying to authenticate.']
end

#xnode_check(sock, username, password) ⇒ Array

Performs a sanity check and an authentication attempt against Xnode to verify if the target is Xnode and if we can authenticate

Parameters:

  • sock (Socket)

    Socket to use for the request

  • username (String)

    Username

  • password (String)

    Password

Returns:

  • (Array)

    Array containing a response code (Integer) and a status message (String)



12
13
14
15
16
17
18
19
20
# File 'lib/msf/core/auxiliary/manage_engine_xnode/basic_checks.rb', line 12

def xnode_check(sock, username, password)
  res_code, res_msg = xnode_sanity_check(sock)
  if res_code != 0
    return [res_code, res_msg]
  end

  print_status(res_msg)
  xnode_authenticate(sock, username, password)
end

#xnode_sanity_check(sock) ⇒ Array

Checks if a target is likely Xnode by sending an empty JSON hash and parsing the response

Parameters:

  • sock (Socket)

    Socket to use for the request

Returns:

  • (Array)

    Array containing a response code (Integer) and a status message (String)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/msf/core/auxiliary/manage_engine_xnode/basic_checks.rb', line 26

def xnode_sanity_check(sock)
  # sanity check: send empty request to see if we get the expected `Authentication failed!` response
  vprint_status('Attempting to verify if the target is Xnode by sending an empty JSON hash')
  res = send_to_sock(sock, {})
  unless res.instance_of?(Hash) && res.keys.include?('response') && res['response'].instance_of?(Hash) && res['response'].include?('error_msg')
    return [2, 'Received unexpected response. The target does not seem to be an Xnode server.']
  end

  error_msg = res['response']['error_msg']
  case error_msg
  when 'Authentication failed!'
    return [0, 'Target seems to be Xnode.']
  when 'Remote request-processing disabled!!'
    return [1, 'Target is Xnode, but remote request-processing is disabled.']
  else
    return [2, "Received the following unexpected error message from Xnode: #{error_msg}"]
  end
end