通过API添加Windows用户
简介
在渗透测试过程中,如果需要白利用远程桌面等服务,往往我们还需要一个知道密码的windows账户,而这个账户通常直接由net1.exe直接添加(当然也可以直接pass the hash登录rdp,略略略),而调用这个可执行文件往往会被第三方杀软直接拦截(略略略,defender是微软自己的,不拦合法功能),这样我们就需要想另外的办法添加用户。
分析过程
查文档&google(狗头)
调用NetUserAdd添加本地用户
调用NetLocalGroupAddMembers将用户添加到组
代码
微软文档解释了这个如何通过这个函数来添加操作系统账户,第一个参数servername指定了需要添加用户的主机名,传入NULL则为本地添加,第二个参数决定了第三个参数传入的结构体,通过这个函数我们可以在windows操作系统上添加账户。
Value | Meaning |
1 | Specifies information about the user account. The buf parameter points to a USER_INFO_1 structure. When you specify this level, the call initializes certain attributes to their default values. For more information, see the following Remarks section. |
2 | Specifies level one information and additional attributes about the user account. The buf parameter points to a USER_INFO_2 structure. |
3 | Specifies level two information and additional attributes about the user account. This level is valid only on servers. The buf parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead. |
4 | Specifies level two information and additional attributes about the user account. This level is valid only on servers. The buf parameter points to a USER_INFO_4 structure. Windows 2000: This level is not supported. |
同理将该账户加入administrators组也是使用类似的函数,这里就不贴参数了。
完整代码
LINKS
最后更新于