Native LDAP Server (Example) - Metasploit
This page contains detailed information about how to use the auxiliary/server/ldap metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Native LDAP Server (Example)
Module: auxiliary/server/ldap
Source code: modules/auxiliary/server/ldap.rb
Disclosure date: -
Last modification time: 2022-03-10 10:28:25 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module provides a Rex based LDAP service to expose the native Rex LDAP server functionality created during log4shell development.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
msf > use auxiliary/server/ldap
msf auxiliary(ldap) > show targets
... a list of targets ...
msf auxiliary(ldap) > set TARGET target-id
msf auxiliary(ldap) > show options
... show and set options ...
msf auxiliary(ldap) > exploit
Knowledge Base
Vulnerable Application
This module demonstrates setting up and running a basic LDAP server in Metasploit. The data it hosts is provided by the
LDIF_FILE
.
Verification Steps
- Start msfconsole
- Do:
use auxiliary/server/ldap
- Do:
set LDIF_FILE data/exploits/ldap/msf.ldif
- This assumes the working directory is the top-level Metasploit Framework directory and configures the module to use the included template.
- Do:
run
- From a new shell, do:
ldapsearch -x -H ldap://192.168.159.128 -b "dc=metasploit,dc=com" "(objectClass=*)"
- This runs a query using the
ldapsearch
utility to show the server is responsive.
- This runs a query using the
Options
LDIF_FILE
Directory LDIF file path.
Scenarios
Metasploit Server Demonstration
msf6 > use auxiliary/server/ldap
msf6 auxiliary(server/ldap) > set LDIF_FILE data/exploits/ldap/msf.ldif
LDIF_FILE => data/exploits/ldap/msf.ldif
msf6 auxiliary(server/ldap) > show options
Module options (auxiliary/server/ldap):
Name Current Setting Required Description
---- --------------- -------- -----------
LDIF_FILE data/exploits/ldap/msf.ldif no Directory LDIF file path
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 389 yes The local port to listen on.
Auxiliary action:
Name Description
---- -----------
Service Run LDAP server
msf6 auxiliary(server/ldap) > run
[*] Auxiliary module running as background job 0.
msf6 auxiliary(server/ldap) >
From another shell:
$ ldapsearch -x -H ldap://192.168.159.128 -b "dc=metasploit,dc=com" "(objectClass=*)"
# extended LDIF
#
# LDAPv3
# base with scope subtree
# filter: (objectClass=*)
# requesting: ALL
#
# metasploit.com
dn: dc=metasploit,dc=com
objectClass: dcObject
objectClass: organization
o: Metasploit Framework
dc: metasploit
# search result
search: 2
result: 0 Success
text: Success
# numResponses: 2
# numEntries: 1
Go back to menu.
Msfconsole Usage
Here is how the server/ldap auxiliary module looks in the msfconsole:
msf6 > use auxiliary/server/ldap
msf6 auxiliary(server/ldap) > show info
Name: Native LDAP Server (Example)
Module: auxiliary/server/ldap
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
RageLtMan <rageltman@sempervictus>
Spencer McIntyre
Available actions:
Name Description
---- -----------
Service Run LDAP server
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
LDIF_FILE no Directory LDIF file path
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all
addresses.
SRVPORT 389 yes The local port to listen on.
Description:
This module provides a Rex based LDAP service to expose the native
Rex LDAP server functionality created during log4shell development.
Module Options
This is a complete list of options available in the server/ldap auxiliary module:
msf6 auxiliary(server/ldap) > show options
Module options (auxiliary/server/ldap):
Name Current Setting Required Description
---- --------------- -------- -----------
LDIF_FILE no Directory LDIF file path
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all
addresses.
SRVPORT 389 yes The local port to listen on.
Auxiliary action:
Name Description
---- -----------
Service Run LDAP server
Advanced Options
Here is a complete list of advanced options supported by the server/ldap auxiliary module:
msf6 auxiliary(server/ldap) > show advanced
Module advanced options (auxiliary/server/ldap):
Name Current Setting Required Description
---- --------------- -------- -----------
LdapServerTcp true yes Serve TCP LDAP requests
LdapServerUdp true yes Serve UDP LDAP requests
ListenerComm no The specific communication channel to use for this service
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the server/ldap module can do:
msf6 auxiliary(server/ldap) > show actions
Auxiliary actions:
Name Description
---- -----------
Service Run LDAP server
Evasion Options
Here is the full list of possible evasion options supported by the server/ldap auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(server/ldap) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Failed to bind to port <SRVPORT>: <E.MESSAGE>
Here is a relevant code snippet related to the "Failed to bind to port <SRVPORT>: <E.MESSAGE>" error message:
43: #
44: def run
45: start_service
46: service.wait
47: rescue Rex::BindFailed => e
48: print_error "Failed to bind to port #{datastore['SRVPORT']}: #{e.message}"
49: ensure
50: stop_service
51: end
52:
53: #
Failed to handle LDAP request due to <E>
Here is a relevant code snippet related to the "Failed to handle LDAP request due to <E>" error message:
107: Net::LDAP::PDU::SearchResult
108: )
109: end
110: resp.nil? ? client.close : on_send_response(client, resp)
111: rescue StandardError => e
112: print_error("Failed to handle LDAP request due to #{e}")
113: client.close
114: end
115: end
116:
117: end
Go back to menu.
Related Pull Requests
Go back to menu.
See Also
Check also the following modules related to this module:
- auxiliary/gather/ldap_esc_vulnerable_cert_finder
- auxiliary/gather/ldap_hashdump
- auxiliary/gather/ldap_query
- auxiliary/admin/ldap/rbcd
- auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass
- exploit/windows/ldap/imail_thc
- exploit/windows/ldap/pgp_keyserver7
- auxiliary/dos/wireshark/cldap
- auxiliary/dos/wireshark/ldap
- auxiliary/gather/vmware_vcenter_vmdir_ldap
- auxiliary/gather/xerox_workcentre_5xxx_ldap
- auxiliary/scanner/http/symantec_brightmail_ldapcreds
- exploit/linux/http/pineapp_ldapsyncnow_exec
- exploit/linux/misc/jenkins_ldap_deserialize
- exploit/windows/http/apache_mod_rewrite_ldap
- exploit/multi/http/phpldapadmin_query_engine
Authors
- RageLtMan <rageltman[at]sempervictus>
- Spencer McIntyre
Version
This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.