Goal: Reverse the latest Trickbot’s module called “DomainGabber,” also known as “domainDll32,” used for LDAP harvesting of domain controller configuration.
While analyzing one of the latest Trickbot group tag “ser1812/tt0002” (version 1000105-1000106) loaders shared by @dvk01uk found an interesting a Trickbot module titled “domainDll” module. (Tip: the “tt0002” group tag is known as a “Trick Test” tag; it is oftentimes deployed to update the existing config on the victim machine.)
Trickbot “DomainGrabber” outline:
I. Lightweight Directory Access Protocol (LDAP) query for domain controllers
II. Connection to “SYSVOL” domain controller
III. Harvesting domain controller XML configuration
As usual, the decoded module contains four Trickbot exported functions:
The observed Trickbot main config module was as follows (version 1000106):
“domainDll32,” compiled via ‘GCC: (Rev1, Built by MSYS2 project) 7.2.0,’ allows Trickbot operators to collect domain controller information once they are already on the compromised machine. This module is internally called “DomainGrabber” and accepts command “getdata” in order to start harvest domain information. domainDll appears to be aimed at exploiting networks with unsecured domain controllers.
More specifically, this module targets “SYSVOL” for domain configuration information data. According to Microsoft, “SYSVOL is simply a folder which resides on each and every domain controller within the domain. It contains the domains public files that need to be accessed by clients and kept synchronised between domain controllers. The default location for the SYSVOL is C:\Windows\SYSVOL although it can be moved to another location during the promotion of a domain controller. It’s possible but not recommended to relocate the SYSVOL after DC promotion as there is potential for error. The SYSVOL folder can be accessed through its share \\domainname.com\sysvol or the local share name on the server \\servername\sysvol.”
What is more, SYSVOL stores various logon scripts, group policy and domain configuration XML data that is synchronized among all domain controllers in the network. Essentially, Trickbot grabs credential and group policy information stored in SYSVOL as follows:
Sean Metcalf has an interesting write-up on how LDAP can be exploited for credential and information harvesting highlighting this similar approach leveraged by the Trickbot gang.
https://platform.twitter.com/widgets.jsI. This Trickbot module was programmed leveraging Active Directory Service Interfaces (ADSI) APIs to query LDAP.
IID_IADsContainer is defined as 001677D0-FD16-11CE-ABC4-02608C9E7553
ads_open = ADsOpenObject(“G”, 0, 0, 1u, &iid, &v11);
DsOpenObject function binds to an ADSI object using explicit user name and password starting with the letter “G”
The GUID associated with the IEnumVARIANT interface
-IID_IDirectorySearch is defined as 109BA8EC-92F0-11D0-A790-00C04FD8D5A8
The module queries all domain controllers as follows:
II. Trickbot connects to domain controller and queries SYSVOL leveraging parsing the aforementioned LDAP query.
The relevant pseudocoded C++ function is as follows:
str_func((int)&name, 260, “%ls”, *(_DWORD *)(v6 + 8));
v26 = gethostbyname(&name);
if ( v26 )
v25 = (struct in_addr *)*v26->h_addr_list;
v2 = inet_ntoa(*v25);
MultiByteToWideChar(0, 1u, v2, -1, &WideCharStr, 32);
v30 = DsRoleGetPrimaryDomainInformation(0, DsRolePrimaryDomainInfoBasic, &Buffer);
if ( v30 )
snwprintf_s(&DstBuf, 260u, 260u, L”\\\\%ls\\SYSVOL\\%ls“, &WideCharStr, *((_DWORD *)Buffer + 3));
memset(&Dst, 0, 0x20u);
lpName = &DstBuf;
v30 = WNetAddConnection2W((LPNETRESOURCEW)&Dst, 0, 0, 0);
if ( !v30 )
WNetCancelConnection2W(lpName, 0, 0);
III. Finally, Trickbot queries stored domain controller for sensitive XML configurations such as scheduledtasks.xml, datasources.xml printers.xml, and etc.
Some of the mitigations against LDAP exploitation are well-documented in Metcalf’s article listed above. As a general rule of thumb, such configuration files should be secured from any unauthorized access in SYSVOL, and access to them should be monitored.