mirror of
https://github.com/P0142/LDAP-Bof-Collection
synced 2026-06-21 13:45:06 +00:00
Updated get-computers,users,groups,attribute to accept list of attributes.
Added get-maq. Updated makefile and axscript, removed old declarations in prep for extension kit push.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# Compiled BOF object files
|
||||
_bin/
|
||||
|
||||
wip/
|
||||
|
||||
# IDE and editor folders
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
@@ -6,53 +6,55 @@ CFLAGS = -I _include -Os -masm=intel -fno-stack-protector -mno-stack-arg-probe -
|
||||
all: bof
|
||||
|
||||
bof: clean
|
||||
@mkdir -p _bin && echo '[*] Creating _bin directory'
|
||||
@mkdir -p _bin/LDAP && echo '[*] Creating _bin directory'
|
||||
@echo '[*] Building GET commands...'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-users.c -o _bin/get-users.x64.o && $(STRIP) --strip-unneeded _bin/get-users.x64.o && echo '[+] get-users'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-computers.c -o _bin/get-computers.x64.o && $(STRIP) --strip-unneeded _bin/get-computers.x64.o && echo '[+] get-computers'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-groups.c -o _bin/get-groups.x64.o && $(STRIP) --strip-unneeded _bin/get-groups.x64.o && echo '[+] get-groups'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-usergroups.c -o _bin/get-usergroups.x64.o && $(STRIP) --strip-unneeded _bin/get-usergroups.x64.o && echo '[+] get-usergroups'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-groupmembers.c -o _bin/get-groupmembers.x64.o && $(STRIP) --strip-unneeded _bin/get-groupmembers.x64.o && echo '[+] get-groupmembers'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-object.c -o _bin/get-object.x64.o && $(STRIP) --strip-unneeded _bin/get-object.x64.o && echo '[+] get-object'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-domaininfo.c -o _bin/get-domaininfo.x64.o && $(STRIP) --strip-unneeded _bin/get-domaininfo.x64.o && echo '[+] get-domaininfo'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-writable.c -o _bin/get-writable.x64.o && $(STRIP) --strip-unneeded _bin/get-writable.x64.o && echo '[+] get-writable'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-delegation.c -o _bin/get-delegation.x64.o && $(STRIP) --strip-unneeded _bin/get-delegation.x64.o && echo '[+] get-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-uac.c -o _bin/get-uac.x64.o && $(STRIP) --strip-unneeded _bin/get-uac.x64.o && echo '[+] get-uac'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-attribute.c -o _bin/get-attribute.x64.o && $(STRIP) --strip-unneeded _bin/get-attribute.x64.o && echo '[+] get-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-spn.c -o _bin/get-spn.x64.o && $(STRIP) --strip-unneeded _bin/get-spn.x64.o && echo '[+] get-spn'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-acl.c -o _bin/get-acl.x64.o && $(STRIP) --strip-unneeded _bin/get-acl.x64.o && echo '[+] get-acl'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-rbcd.c -o _bin/get-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/get-rbcd.x64.o && echo '[+] get-rbcd'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-users.c -o _bin/LDAP/get-users.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-users.x64.o && echo '[+] get-users'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-computers.c -o _bin/LDAP/get-computers.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-computers.x64.o && echo '[+] get-computers'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-groups.c -o _bin/LDAP/get-groups.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-groups.x64.o && echo '[+] get-groups'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-usergroups.c -o _bin/LDAP/get-usergroups.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-usergroups.x64.o && echo '[+] get-usergroups'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-groupmembers.c -o _bin/LDAP/get-groupmembers.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-groupmembers.x64.o && echo '[+] get-groupmembers'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-object.c -o _bin/LDAP/get-object.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-object.x64.o && echo '[+] get-object'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-domaininfo.c -o _bin/LDAP/get-domaininfo.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-domaininfo.x64.o && echo '[+] get-domaininfo'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-maq.c -o _bin/LDAP/get-maq.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-maq.x64.o && echo '[+] get-maq'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-writable.c -o _bin/LDAP/get-writable.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-writable.x64.o && echo '[+] get-writable'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-delegation.c -o _bin/LDAP/get-delegation.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-delegation.x64.o && echo '[+] get-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-uac.c -o _bin/LDAP/get-uac.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-uac.x64.o && echo '[+] get-uac'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-attribute.c -o _bin/LDAP/get-attribute.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-attribute.x64.o && echo '[+] get-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-spn.c -o _bin/LDAP/get-spn.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-spn.x64.o && echo '[+] get-spn'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-acl.c -o _bin/LDAP/get-acl.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-acl.x64.o && echo '[+] get-acl'
|
||||
@$(CC) $(CFLAGS) -c src/get/get-rbcd.c -o _bin/LDAP/get-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/get-rbcd.x64.o && echo '[+] get-rbcd'
|
||||
@echo '[*] Building ADD commands...'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-user.c -o _bin/add-user.x64.o && $(STRIP) --strip-unneeded _bin/add-user.x64.o && echo '[+] add-user'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-computer.c -o _bin/add-computer.x64.o && $(STRIP) --strip-unneeded _bin/add-computer.x64.o && echo '[+] add-computer'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-group.c -o _bin/add-group.x64.o && $(STRIP) --strip-unneeded _bin/add-group.x64.o && echo '[+] add-group'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-groupmember.c -o _bin/add-groupmember.x64.o && $(STRIP) --strip-unneeded _bin/add-groupmember.x64.o && echo '[+] add-groupmember'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-ou.c -o _bin/add-ou.x64.o && $(STRIP) --strip-unneeded _bin/add-ou.x64.o && echo '[+] add-ou'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-sidhistory.c -o _bin/add-sidhistory.x64.o && $(STRIP) --strip-unneeded _bin/add-sidhistory.x64.o && echo '[+] add-sidhistory'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-spn.c -o _bin/add-spn.x64.o && $(STRIP) --strip-unneeded _bin/add-spn.x64.o && echo '[+] add-spn'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-attribute.c -o _bin/add-attribute.x64.o && $(STRIP) --strip-unneeded _bin/add-attribute.x64.o && echo '[+] add-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-uac.c -o _bin/add-uac.x64.o && $(STRIP) --strip-unneeded _bin/add-uac.x64.o && echo '[+] add-uac'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-delegation.c -o _bin/add-delegation.x64.o && $(STRIP) --strip-unneeded _bin/add-delegation.x64.o && echo '[+] add-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-rbcd.c -o _bin/add-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/add-rbcd.x64.o && echo '[+] add-rbcd'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-ace.c -o _bin/add-ace.x64.o && $(STRIP) --strip-unneeded _bin/add-ace.x64.o && echo '[+] add-ace'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-user.c -o _bin/LDAP/add-user.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-user.x64.o && echo '[+] add-user'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-computer.c -o _bin/LDAP/add-computer.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-computer.x64.o && echo '[+] add-computer'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-group.c -o _bin/LDAP/add-group.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-group.x64.o && echo '[+] add-group'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-groupmember.c -o _bin/LDAP/add-groupmember.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-groupmember.x64.o && echo '[+] add-groupmember'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-ou.c -o _bin/LDAP/add-ou.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-ou.x64.o && echo '[+] add-ou'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-sidhistory.c -o _bin/LDAP/add-sidhistory.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-sidhistory.x64.o && echo '[+] add-sidhistory'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-spn.c -o _bin/LDAP/add-spn.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-spn.x64.o && echo '[+] add-spn'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-attribute.c -o _bin/LDAP/add-attribute.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-attribute.x64.o && echo '[+] add-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-uac.c -o _bin/LDAP/add-uac.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-uac.x64.o && echo '[+] add-uac'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-delegation.c -o _bin/LDAP/add-delegation.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-delegation.x64.o && echo '[+] add-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-rbcd.c -o _bin/LDAP/add-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-rbcd.x64.o && echo '[+] add-rbcd'
|
||||
@$(CC) $(CFLAGS) -c src/add/add-ace.c -o _bin/LDAP/add-ace.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/add-ace.x64.o && echo '[+] add-ace'
|
||||
@echo '[*] Building SET commands...'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-password.c -o _bin/set-password.x64.o && $(STRIP) --strip-unneeded _bin/set-password.x64.o && echo '[+] set-password'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-spn.c -o _bin/set-spn.x64.o && $(STRIP) --strip-unneeded _bin/set-spn.x64.o && echo '[+] set-spn'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-delegation.c -o _bin/set-delegation.x64.o && $(STRIP) --strip-unneeded _bin/set-delegation.x64.o && echo '[+] set-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-attribute.c -o _bin/set-attribute.x64.o && $(STRIP) --strip-unneeded _bin/set-attribute.x64.o && echo '[+] set-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-uac.c -o _bin/set-uac.x64.o && $(STRIP) --strip-unneeded _bin/set-uac.x64.o && echo '[+] set-uac'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-owner.c -o _bin/set-owner.x64.o && $(STRIP) --strip-unneeded _bin/set-owner.x64.o && echo '[+] set-owner'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-password.c -o _bin/LDAP/set-password.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-password.x64.o && echo '[+] set-password'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-spn.c -o _bin/LDAP/set-spn.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-spn.x64.o && echo '[+] set-spn'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-delegation.c -o _bin/LDAP/set-delegation.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-delegation.x64.o && echo '[+] set-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-attribute.c -o _bin/LDAP/set-attribute.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-attribute.x64.o && echo '[+] set-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-uac.c -o _bin/LDAP/set-uac.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-uac.x64.o && echo '[+] set-uac'
|
||||
@$(CC) $(CFLAGS) -c src/set/set-owner.c -o _bin/LDAP/set-owner.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/set-owner.x64.o && echo '[+] set-owner'
|
||||
@echo '[*] Building MOVE commands...'
|
||||
@$(CC) $(CFLAGS) -c src/move/move-object.c -o _bin/move-object.x64.o && $(STRIP) --strip-unneeded _bin/move-object.x64.o && echo '[+] move-object'
|
||||
@$(CC) $(CFLAGS) -c src/move/move-object.c -o _bin/LDAP/move-object.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/move-object.x64.o && echo '[+] move-object'
|
||||
@echo '[*] Building REMOVE commands...'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-groupmember.c -o _bin/remove-groupmember.x64.o && $(STRIP) --strip-unneeded _bin/remove-groupmember.x64.o && echo '[+] remove-groupmember'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-object.c -o _bin/remove-object.x64.o && $(STRIP) --strip-unneeded _bin/remove-object.x64.o && echo '[+] remove-object'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-delegation.c -o _bin/remove-delegation.x64.o && $(STRIP) --strip-unneeded _bin/remove-delegation.x64.o && echo '[+] remove-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-spn.c -o _bin/remove-spn.x64.o && $(STRIP) --strip-unneeded _bin/remove-spn.x64.o && echo '[+] remove-spn'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-attribute.c -o _bin/remove-attribute.x64.o && $(STRIP) --strip-unneeded _bin/remove-attribute.x64.o && echo '[+] remove-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-rbcd.c -o _bin/remove-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/remove-rbcd.x64.o && echo '[+] remove-rbcd'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-ace.c -o _bin/remove-ace.x64.o && $(STRIP) --strip-unneeded _bin/remove-ace.x64.o && echo '[+] remove-ace'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-uac.c -o _bin/remove-uac.x64.o && $(STRIP) --strip-unneeded _bin/remove-uac.x64.o && echo '[+] remove-uac'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-groupmember.c -o _bin/LDAP/remove-groupmember.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-groupmember.x64.o && echo '[+] remove-groupmember'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-object.c -o _bin/LDAP/remove-object.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-object.x64.o && echo '[+] remove-object'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-delegation.c -o _bin/LDAP/remove-delegation.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-delegation.x64.o && echo '[+] remove-delegation'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-spn.c -o _bin/LDAP/remove-spn.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-spn.x64.o && echo '[+] remove-spn'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-attribute.c -o _bin/LDAP/remove-attribute.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-attribute.x64.o && echo '[+] remove-attribute'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-rbcd.c -o _bin/LDAP/remove-rbcd.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-rbcd.x64.o && echo '[+] remove-rbcd'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-ace.c -o _bin/LDAP/remove-ace.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-ace.x64.o && echo '[+] remove-ace'
|
||||
@$(CC) $(CFLAGS) -c src/remove/remove-uac.c -o _bin/LDAP/remove-uac.x64.o && $(STRIP) --strip-unneeded _bin/LDAP/remove-uac.x64.o && echo '[+] remove-uac'
|
||||
|
||||
@echo '[*] Build complete!'
|
||||
|
||||
clean:
|
||||
|
||||
@@ -201,6 +201,7 @@ DECLSPEC_IMPORT ULONG WLDAP32$ldap_count_entries(LDAP* ld, LDAPMessage* res);
|
||||
DECLSPEC_IMPORT PCHAR WLDAP32$ldap_err2stringA(ULONG err);
|
||||
DECLSPEC_IMPORT struct berval** WLDAP32$ldap_get_values_len(LDAP* ld, LDAPMessage* entry, const PCHAR attr);
|
||||
DECLSPEC_IMPORT ULONG WLDAP32$ldap_value_free_len(struct berval** vals);
|
||||
DECLSPEC_IMPORT ULONG WLDAP32$ldap_extended_operation_sA(LDAP* ld, PCHAR Oid, struct berval* Data, PLDAPControlA* ServerControls, PLDAPControlA* ClientControls, PCHAR* ReturnedOid, struct berval** ReturnedData);
|
||||
|
||||
// Shared function declarations
|
||||
char* GetDCHostName();
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
// Group type constants
|
||||
#define GROUP_TYPE_SECURITY_GLOBAL -2147483646
|
||||
#define GROUP_TYPE_SECURITY_DOMAIN_LOCAL -2147483644
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
// Import additional MSVCRT functions needed
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -64,7 +64,6 @@ void go(char *args, int alen) {
|
||||
}
|
||||
|
||||
// Initialize LDAP connection
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "\n[*] Initializing LDAP connection...");
|
||||
char* dcHostname = NULL;
|
||||
LDAP* ld = InitializeLDAPConnection(dcAddress, useLdaps, &dcHostname);
|
||||
if (!ld) {
|
||||
@@ -132,7 +131,6 @@ void go(char *args, int alen) {
|
||||
}
|
||||
|
||||
// Get principal's objectSid
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[*] Retrieving principal's objectSid...");
|
||||
PSID pPrincipalSid = GetObjectSid(ld, principalDN);
|
||||
|
||||
if (!pPrincipalSid) {
|
||||
@@ -261,7 +259,6 @@ void go(char *args, int alen) {
|
||||
|
||||
// Create new security descriptor
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[*] Building new RBCD security descriptor...");
|
||||
|
||||
BYTE absoluteSDBuffer[SECURITY_DESCRIPTOR_MIN_LENGTH];
|
||||
PSECURITY_DESCRIPTOR pNewSD = (PSECURITY_DESCRIPTOR)absoluteSDBuffer;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
DECLSPEC_IMPORT unsigned long __cdecl MSVCRT$strtoul(const char* str, char** endptr, int base);
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -13,6 +13,9 @@ DECLSPEC_IMPORT char* __cdecl MSVCRT$strcat(char* dest, const char* src);
|
||||
DECLSPEC_IMPORT char* __cdecl MSVCRT$strchr(const char *str, int c);
|
||||
DECLSPEC_IMPORT char* __cdecl MSVCRT$strstr(const char* str, const char* substr);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$sprintf(char* buffer, const char* format, ...);
|
||||
DECLSPEC_IMPORT char* __cdecl MSVCRT$strtok(char* str, const char* delimiters);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_stricmp(const char* str1, const char* str2);
|
||||
DECLSPEC_IMPORT void* __cdecl MSVCRT$malloc(size_t size);
|
||||
DECLSPEC_IMPORT void __cdecl MSVCRT$free(void* ptr);
|
||||
DECLSPEC_IMPORT void* __cdecl MSVCRT$memcpy(void* dest, const void* src, size_t count);
|
||||
@@ -425,4 +428,113 @@ void CleanupLDAP(LDAP* ld) {
|
||||
if (ld) {
|
||||
WLDAP32$ldap_unbind_s(ld);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert binary GUID to string format
|
||||
void FormatGUID(BYTE* guidBytes, char* output) {
|
||||
MSVCRT$sprintf(output, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guidBytes[3], guidBytes[2], guidBytes[1], guidBytes[0],
|
||||
guidBytes[5], guidBytes[4],
|
||||
guidBytes[7], guidBytes[6],
|
||||
guidBytes[8], guidBytes[9],
|
||||
guidBytes[10], guidBytes[11], guidBytes[12], guidBytes[13], guidBytes[14], guidBytes[15]);
|
||||
}
|
||||
|
||||
// Convert binary SID to string format (simplified - handles common SIDs)
|
||||
void FormatSID(BYTE* sidBytes, int length, char* output) {
|
||||
if (length < 8) {
|
||||
MSVCRT$sprintf(output, "(invalid SID)");
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE revision = sidBytes[0];
|
||||
BYTE subAuthCount = sidBytes[1];
|
||||
|
||||
// Authority (6 bytes, big-endian)
|
||||
unsigned long long authority = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
authority = (authority << 8) | sidBytes[2 + i];
|
||||
}
|
||||
|
||||
// Start building the SID string
|
||||
int pos = MSVCRT$sprintf(output, "S-%d-%llu", revision, authority);
|
||||
|
||||
// SubAuthorities (32-bit values, little-endian)
|
||||
for (int i = 0; i < subAuthCount && (8 + i * 4 + 3) < length; i++) {
|
||||
unsigned long subAuth =
|
||||
(unsigned long)sidBytes[8 + i * 4] |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 1] << 8) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 2] << 16) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 3] << 24);
|
||||
pos += MSVCRT$sprintf(output + pos, "-%lu", subAuth);
|
||||
}
|
||||
}
|
||||
|
||||
// Build attribute list from comma-separated string
|
||||
// Returns number of attributes in the array
|
||||
int BuildAttributeList(char* attributesStr, char** defaultAttrs, int defaultCount, char** attrs, int maxAttrs) {
|
||||
int attrCount = 0;
|
||||
|
||||
// Always include sAMAccountName
|
||||
attrs[attrCount++] = "sAMAccountName";
|
||||
|
||||
// If attributes specified, parse comma-separated list
|
||||
if (attributesStr && MSVCRT$strlen(attributesStr) > 0) {
|
||||
char* token = MSVCRT$strtok(attributesStr, ",");
|
||||
while (token != NULL && attrCount < (maxAttrs - 1)) {
|
||||
// Trim leading spaces
|
||||
while (*token == ' ') token++;
|
||||
// Skip if it's sAMAccountName (already added)
|
||||
if (MSVCRT$_stricmp(token, "sAMAccountName") != 0) {
|
||||
attrs[attrCount++] = token;
|
||||
}
|
||||
token = MSVCRT$strtok(NULL, ",");
|
||||
}
|
||||
} else if (defaultAttrs) {
|
||||
// Add default attributes if provided and no custom attributes
|
||||
for (int i = 0; i < defaultCount && attrCount < (maxAttrs - 1); i++) {
|
||||
attrs[attrCount++] = defaultAttrs[i];
|
||||
}
|
||||
}
|
||||
|
||||
attrs[attrCount] = NULL;
|
||||
return attrCount;
|
||||
}
|
||||
|
||||
// Display attribute value (handles both string and binary attributes)
|
||||
void DisplayAttributeValue(LDAP* ld, LDAPMessage* entry, const char* attrName) {
|
||||
// Check if this is a known binary attribute (case-insensitive)
|
||||
BOOL isBinary = (MSVCRT$_stricmp(attrName, "objectGUID") == 0 ||
|
||||
MSVCRT$_stricmp(attrName, "objectSid") == 0 ||
|
||||
MSVCRT$_stricmp(attrName, "objectSID") == 0);
|
||||
|
||||
if (isBinary) {
|
||||
// Handle binary attributes
|
||||
struct berval** bvalues = WLDAP32$ldap_get_values_len(ld, entry, (char*)attrName);
|
||||
if (bvalues && bvalues[0]) {
|
||||
for (int j = 0; bvalues[j] != NULL; j++) {
|
||||
char formatted[256];
|
||||
if (MSVCRT$_stricmp(attrName, "objectGUID") == 0) {
|
||||
FormatGUID((BYTE*)bvalues[j]->bv_val, formatted);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s: %s", attrName, formatted);
|
||||
} else if (MSVCRT$_stricmp(attrName, "objectSid") == 0 ||
|
||||
MSVCRT$_stricmp(attrName, "objectSID") == 0) {
|
||||
FormatSID((BYTE*)bvalues[j]->bv_val, bvalues[j]->bv_len, formatted);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s: %s", attrName, formatted);
|
||||
}
|
||||
}
|
||||
WLDAP32$ldap_value_free_len(bvalues);
|
||||
}
|
||||
} else {
|
||||
// Handle string attributes
|
||||
char** values = WLDAP32$ldap_get_values(ld, entry, (char*)attrName);
|
||||
if (values && values[0]) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s: %s", attrName, values[0]);
|
||||
// Print additional values if multi-valued
|
||||
for (int j = 1; values[j] != NULL; j++) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s: %s", attrName, values[j]);
|
||||
}
|
||||
WLDAP32$ldap_value_free(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-86
@@ -2,58 +2,14 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$sprintf(char* buffer, const char* format, ...);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_stricmp(const char* str1, const char* str2);
|
||||
|
||||
// Convert binary GUID to string format
|
||||
void FormatGUID(BYTE* guidBytes, char* output) {
|
||||
MSVCRT$sprintf(output, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guidBytes[3], guidBytes[2], guidBytes[1], guidBytes[0],
|
||||
guidBytes[5], guidBytes[4],
|
||||
guidBytes[7], guidBytes[6],
|
||||
guidBytes[8], guidBytes[9],
|
||||
guidBytes[10], guidBytes[11], guidBytes[12], guidBytes[13], guidBytes[14], guidBytes[15]);
|
||||
}
|
||||
|
||||
// Convert binary SID to string format (simplified - handles common SIDs)
|
||||
void FormatSID(BYTE* sidBytes, int length, char* output) {
|
||||
if (length < 8) {
|
||||
MSVCRT$sprintf(output, "(invalid SID)");
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE revision = sidBytes[0];
|
||||
BYTE subAuthCount = sidBytes[1];
|
||||
|
||||
// Authority (6 bytes, big-endian)
|
||||
unsigned long long authority = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
authority = (authority << 8) | sidBytes[2 + i];
|
||||
}
|
||||
|
||||
// Start building the SID string
|
||||
int pos = MSVCRT$sprintf(output, "S-%d-%llu", revision, authority);
|
||||
|
||||
// SubAuthorities (32-bit values, little-endian)
|
||||
for (int i = 0; i < subAuthCount && (8 + i * 4 + 3) < length; i++) {
|
||||
unsigned long subAuth =
|
||||
(unsigned long)sidBytes[8 + i * 4] |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 1] << 8) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 2] << 16) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 3] << 24);
|
||||
pos += MSVCRT$sprintf(output + pos, "-%lu", subAuth);
|
||||
}
|
||||
}
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
// Parse arguments: target_identifier, is_dn, attribute, search_ou, dc_address, use_ldaps
|
||||
// Parse arguments: target_identifier, is_dn, attributes (comma-separated), search_ou, dc_address, use_ldaps
|
||||
char* targetIdentifier = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int isTargetDN = BeaconDataInt(&parser);
|
||||
char* attribute = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* attributesStr = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* searchOu = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* dcAddress = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int useLdaps = BeaconDataInt(&parser);
|
||||
@@ -63,7 +19,7 @@ void go(char *args, int alen) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!attribute || MSVCRT$strlen(attribute) == 0) {
|
||||
if (!attributesStr || MSVCRT$strlen(attributesStr) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,9 +63,12 @@ void go(char *args, int alen) {
|
||||
}
|
||||
}
|
||||
|
||||
// Query the specific attribute
|
||||
// Build attribute list
|
||||
char* attrs[64];
|
||||
int attrCount = BuildAttributeList(attributesStr, NULL, 0, attrs, 64);
|
||||
|
||||
// Query the attributes
|
||||
LDAPMessage* searchResult = NULL;
|
||||
char* attrs[] = { attribute, NULL };
|
||||
|
||||
ULONG result = WLDAP32$ldap_search_s(
|
||||
ld,
|
||||
@@ -122,8 +81,8 @@ void go(char *args, int alen) {
|
||||
);
|
||||
|
||||
if (result != LDAP_SUCCESS) {
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] Failed to query attribute");
|
||||
PrintLdapError("Query attribute", result);
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] Failed to query attributes");
|
||||
PrintLdapError("Query attributes", result);
|
||||
MSVCRT$free(targetDN);
|
||||
if (defaultNC) MSVCRT$free(defaultNC);
|
||||
if (dcHostname) MSVCRT$free(dcHostname);
|
||||
@@ -133,42 +92,11 @@ void go(char *args, int alen) {
|
||||
|
||||
LDAPMessage* entry = WLDAP32$ldap_first_entry(ld, searchResult);
|
||||
if (entry) {
|
||||
// Check if this is a known binary attribute (case-insensitive)
|
||||
BOOL isBinary = (MSVCRT$_stricmp(attribute, "objectGUID") == 0 ||
|
||||
MSVCRT$_stricmp(attribute, "objectSid") == 0 ||
|
||||
MSVCRT$_stricmp(attribute, "objectSID") == 0);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "==========================================");
|
||||
|
||||
if (isBinary) {
|
||||
// Handle binary attributes
|
||||
struct berval** bvalues = WLDAP32$ldap_get_values_len(ld, entry, attribute);
|
||||
if (bvalues && bvalues[0]) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "==========================================");
|
||||
for (int i = 0; bvalues[i] != NULL; i++) {
|
||||
char formatted[256];
|
||||
if (MSVCRT$_stricmp(attribute, "objectGUID") == 0) {
|
||||
FormatGUID((BYTE*)bvalues[i]->bv_val, formatted);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s", formatted);
|
||||
} else if (MSVCRT$_stricmp(attribute, "objectSid") == 0 ||
|
||||
MSVCRT$_stricmp(attribute, "objectSID") == 0) {
|
||||
FormatSID((BYTE*)bvalues[i]->bv_val, bvalues[i]->bv_len, formatted);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s", formatted);
|
||||
}
|
||||
}
|
||||
WLDAP32$ldap_value_free_len(bvalues);
|
||||
} else {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "==========================================");
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "(No value found)");
|
||||
}
|
||||
} else {
|
||||
// Handle string attributes
|
||||
char** values = WLDAP32$ldap_get_values(ld, entry, attribute);
|
||||
if (values) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "==========================================");
|
||||
for (int i = 0; values[i] != NULL; i++) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s", values[i]);
|
||||
}
|
||||
WLDAP32$ldap_value_free(values);
|
||||
}
|
||||
// Display all requested attributes
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
DisplayAttributeValue(ld, entry, attrs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-19
@@ -2,16 +2,15 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps, attributes
|
||||
char* searchOu = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* dcAddress = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int useLdaps = BeaconDataInt(&parser);
|
||||
char* attributesStr = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
|
||||
// Initialize LDAP connection
|
||||
char* dcHostname = NULL;
|
||||
@@ -32,9 +31,13 @@ void go(char *args, int alen) {
|
||||
|
||||
char* searchBase = (searchOu && MSVCRT$strlen(searchOu) > 0) ? searchOu : defaultNC;
|
||||
|
||||
// Build attribute list
|
||||
char* attrs[64];
|
||||
char* defaultAttrs[] = { "distinguishedName", "operatingSystem" };
|
||||
int attrCount = BuildAttributeList(attributesStr, defaultAttrs, 2, attrs, 64);
|
||||
|
||||
// Search for computer objects
|
||||
LDAPMessage* searchResult = NULL;
|
||||
char* attrs[] = { "sAMAccountName", "distinguishedName", "operatingSystem", NULL };
|
||||
|
||||
ULONG result = WLDAP32$ldap_search_s(
|
||||
ld,
|
||||
@@ -59,22 +62,13 @@ void go(char *args, int alen) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[+] Found %d computer(s):\n", compCount);
|
||||
|
||||
LDAPMessage* entry = WLDAP32$ldap_first_entry(ld, searchResult);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-25s %-30s %s", "sAMAccountName", "OperatingSystem", "DistinguishedName");
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "================================================================================");
|
||||
while (entry != NULL) {
|
||||
char** samValues = WLDAP32$ldap_get_values(ld, entry, "sAMAccountName");
|
||||
char** osValues = WLDAP32$ldap_get_values(ld, entry, "operatingSystem");
|
||||
char** dnValues = WLDAP32$ldap_get_values(ld, entry, "distinguishedName");
|
||||
|
||||
char* sam = (samValues && samValues[0]) ? samValues[0] : "";
|
||||
char* os = (osValues && osValues[0]) ? osValues[0] : "";
|
||||
char* dn = (dnValues && dnValues[0]) ? dnValues[0] : "";
|
||||
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-25s %-30s %s", sam, os, dn);
|
||||
|
||||
if (samValues) WLDAP32$ldap_value_free(samValues);
|
||||
if (osValues) WLDAP32$ldap_value_free(osValues);
|
||||
if (dnValues) WLDAP32$ldap_value_free(dnValues);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "===================================");
|
||||
|
||||
// Display all requested attributes
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
DisplayAttributeValue(ld, entry, attrs[i]);
|
||||
}
|
||||
|
||||
entry = WLDAP32$ldap_next_entry(ld, entry);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
+12
-14
@@ -2,16 +2,15 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps, attributes
|
||||
char* searchOu = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* dcAddress = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int useLdaps = BeaconDataInt(&parser);
|
||||
char* attributesStr = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
|
||||
// Initialize LDAP connection
|
||||
char* dcHostname = NULL;
|
||||
@@ -32,9 +31,13 @@ void go(char *args, int alen) {
|
||||
|
||||
char* searchBase = (searchOu && MSVCRT$strlen(searchOu) > 0) ? searchOu : defaultNC;
|
||||
|
||||
// Build attribute list
|
||||
char* attrs[64];
|
||||
char* defaultAttrs[] = { "distinguishedName" };
|
||||
int attrCount = BuildAttributeList(attributesStr, defaultAttrs, 1, attrs, 64);
|
||||
|
||||
// Search for group objects
|
||||
LDAPMessage* searchResult = NULL;
|
||||
char* attrs[] = { "sAMAccountName", "distinguishedName", NULL };
|
||||
|
||||
ULONG result = WLDAP32$ldap_search_s(
|
||||
ld,
|
||||
@@ -59,19 +62,14 @@ void go(char *args, int alen) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[+] Found %d group(s):\n", groupCount);
|
||||
|
||||
LDAPMessage* entry = WLDAP32$ldap_first_entry(ld, searchResult);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-30s %s", "sAMAccountName", "DistinguishedName");
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "===================================");
|
||||
while (entry != NULL) {
|
||||
char** samValues = WLDAP32$ldap_get_values(ld, entry, "sAMAccountName");
|
||||
char** dnValues = WLDAP32$ldap_get_values(ld, entry, "distinguishedName");
|
||||
|
||||
if (samValues && samValues[0] && dnValues) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-30s %s", samValues[0], dnValues[0]);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "===================================");
|
||||
|
||||
// Display all requested attributes
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
DisplayAttributeValue(ld, entry, attrs[i]);
|
||||
}
|
||||
|
||||
if (samValues) WLDAP32$ldap_value_free(samValues);
|
||||
if (dnValues) WLDAP32$ldap_value_free(dnValues);
|
||||
|
||||
entry = WLDAP32$ldap_next_entry(ld, entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#include <windows.h>
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
// Parse arguments: dc_address, use_ldaps
|
||||
char* dcAddress = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int useLdaps = BeaconDataInt(&parser);
|
||||
|
||||
// Initialize LDAP connection
|
||||
char* dcHostname = NULL;
|
||||
LDAP* ld = InitializeLDAPConnection(dcAddress, useLdaps, &dcHostname);
|
||||
if (!ld) {
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] Failed to initialize LDAP connection");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get default naming context
|
||||
char* defaultNC = GetDefaultNamingContext(ld, dcHostname);
|
||||
if (!defaultNC) {
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] Failed to get default naming context");
|
||||
if (dcHostname) MSVCRT$free(dcHostname);
|
||||
CleanupLDAP(ld);
|
||||
return;
|
||||
}
|
||||
|
||||
// Query domain object for ms-DS-MachineAccountQuota attribute
|
||||
LDAPMessage* searchResult = NULL;
|
||||
char* attrs[] = { "ms-DS-MachineAccountQuota", NULL };
|
||||
|
||||
ULONG result = WLDAP32$ldap_search_s(
|
||||
ld,
|
||||
defaultNC,
|
||||
LDAP_SCOPE_BASE,
|
||||
"(objectClass=*)",
|
||||
attrs,
|
||||
0,
|
||||
&searchResult
|
||||
);
|
||||
|
||||
if (result != LDAP_SUCCESS) {
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] Failed to query machine account quota");
|
||||
PrintLdapError("Query MAQ", result);
|
||||
MSVCRT$free(defaultNC);
|
||||
if (dcHostname) MSVCRT$free(dcHostname);
|
||||
CleanupLDAP(ld);
|
||||
return;
|
||||
}
|
||||
|
||||
LDAPMessage* entry = WLDAP32$ldap_first_entry(ld, searchResult);
|
||||
if (entry) {
|
||||
char** maqValues = WLDAP32$ldap_get_values(ld, entry, "ms-DS-MachineAccountQuota");
|
||||
if (maqValues && maqValues[0]) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[+] Machine Account Quota (ms-DS-MachineAccountQuota): %s", maqValues[0]);
|
||||
WLDAP32$ldap_value_free(maqValues);
|
||||
} else {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[*] Machine Account Quota attribute not found or not set");
|
||||
}
|
||||
} else {
|
||||
BeaconPrintf(CALLBACK_ERROR, "[-] No results returned");
|
||||
}
|
||||
|
||||
WLDAP32$ldap_msgfree(searchResult);
|
||||
MSVCRT$free(defaultNC);
|
||||
if (dcHostname) MSVCRT$free(dcHostname);
|
||||
CleanupLDAP(ld);
|
||||
}
|
||||
@@ -2,50 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$sprintf(char* buffer, const char* format, ...);
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_stricmp(const char* str1, const char* str2);
|
||||
|
||||
// Convert binary GUID to string format
|
||||
void FormatGUID(BYTE* guidBytes, char* output) {
|
||||
MSVCRT$sprintf(output, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guidBytes[3], guidBytes[2], guidBytes[1], guidBytes[0],
|
||||
guidBytes[5], guidBytes[4],
|
||||
guidBytes[7], guidBytes[6],
|
||||
guidBytes[8], guidBytes[9],
|
||||
guidBytes[10], guidBytes[11], guidBytes[12], guidBytes[13], guidBytes[14], guidBytes[15]);
|
||||
}
|
||||
|
||||
// Convert binary SID to string format (simplified - handles common SIDs)
|
||||
void FormatSID(BYTE* sidBytes, int length, char* output) {
|
||||
if (length < 8) {
|
||||
MSVCRT$sprintf(output, "(invalid SID)");
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE revision = sidBytes[0];
|
||||
BYTE subAuthCount = sidBytes[1];
|
||||
|
||||
// Authority (6 bytes, big-endian)
|
||||
unsigned long long authority = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
authority = (authority << 8) | sidBytes[2 + i];
|
||||
}
|
||||
|
||||
// Start building the SID string
|
||||
int pos = MSVCRT$sprintf(output, "S-%d-%llu", revision, authority);
|
||||
|
||||
// SubAuthorities (32-bit values, little-endian)
|
||||
for (int i = 0; i < subAuthCount && (8 + i * 4 + 3) < length; i++) {
|
||||
unsigned long subAuth =
|
||||
(unsigned long)sidBytes[8 + i * 4] |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 1] << 8) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 2] << 16) |
|
||||
((unsigned long)sidBytes[8 + i * 4 + 3] << 24);
|
||||
pos += MSVCRT$sprintf(output + pos, "-%lu", subAuth);
|
||||
}
|
||||
}
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#include "../common/ldap_common.c"
|
||||
#include "../common/acl_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
|
||||
// UAC flag name to value mapping
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
+12
-14
@@ -2,16 +2,15 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps
|
||||
// Parse arguments: search_ou, dc_address, use_ldaps, attributes
|
||||
char* searchOu = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
char* dcAddress = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
int useLdaps = BeaconDataInt(&parser);
|
||||
char* attributesStr = ValidateInput(BeaconDataExtract(&parser, NULL));
|
||||
|
||||
// Initialize LDAP connection
|
||||
char* dcHostname = NULL;
|
||||
@@ -32,9 +31,13 @@ void go(char *args, int alen) {
|
||||
|
||||
char* searchBase = (searchOu && MSVCRT$strlen(searchOu) > 0) ? searchOu : defaultNC;
|
||||
|
||||
// Build attribute list
|
||||
char* attrs[64];
|
||||
char* defaultAttrs[] = { "distinguishedName" };
|
||||
int attrCount = BuildAttributeList(attributesStr, defaultAttrs, 1, attrs, 64);
|
||||
|
||||
// Search for user objects
|
||||
LDAPMessage* searchResult = NULL;
|
||||
char* attrs[] = { "sAMAccountName", "distinguishedName", NULL };
|
||||
|
||||
ULONG result = WLDAP32$ldap_search_s(
|
||||
ld,
|
||||
@@ -59,19 +62,14 @@ void go(char *args, int alen) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "[+] Found %d user(s):\n", userCount);
|
||||
|
||||
LDAPMessage* entry = WLDAP32$ldap_first_entry(ld, searchResult);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-20s %s", "sAMAccountName", "DistinguishedName");
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "===================================");
|
||||
while (entry != NULL) {
|
||||
char** samValues = WLDAP32$ldap_get_values(ld, entry, "sAMAccountName");
|
||||
char** dnValues = WLDAP32$ldap_get_values(ld, entry, "distinguishedName");
|
||||
|
||||
if (samValues && samValues[0] && dnValues) {
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%-20s %s", samValues[0], dnValues[0]);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "===================================");
|
||||
|
||||
// Display all requested attributes
|
||||
for (int i = 0; i < attrCount; i++) {
|
||||
DisplayAttributeValue(ld, entry, attrs[i]);
|
||||
}
|
||||
|
||||
if (samValues) WLDAP32$ldap_value_free(samValues);
|
||||
if (dnValues) WLDAP32$ldap_value_free(dnValues);
|
||||
|
||||
entry = WLDAP32$ldap_next_entry(ld, entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
// Import additional MSVCRT functions needed
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
// Import ldap_rename_ext_s function (the actual export name)
|
||||
// ldap_rename_s is a macro that maps to ldap_rename_ext_s
|
||||
DECLSPEC_IMPORT ULONG WLDAP32$ldap_rename_ext_s(
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
// Import additional MSVCRT functions needed
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
// Import additional MSVCRT functions needed
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#include "../common/ldap_common.c"
|
||||
#include "../common/acl_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
// Import additional MSVCRT functions needed
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
|
||||
void go(char *args, int alen) {
|
||||
datap parser;
|
||||
BeaconDataParse(&parser, args, alen);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "../../_include/beacon.h"
|
||||
#include "../common/ldap_common.c"
|
||||
|
||||
DECLSPEC_IMPORT int __cdecl MSVCRT$_snprintf(char* buffer, size_t count, const char* format, ...);
|
||||
DECLSPEC_IMPORT long __cdecl MSVCRT$strtol(const char* str, char** endptr, int base);
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user