public static Task CreateTask(JToken dict) { Task task = null; switch ((string)dict["category"]) { case "file": task = new FileTask(dict); break; default: throw new Exception("Don't know category: " + dict["category"]); } return(task); }
static void Main(string[] args) { //CuckooSession session = new CuckooSession("127.0.0.1", 8090); //JObject response = session.ExecuteCommand("/cuckoo/status", "GET"); //Console.WriteLine(response.ToString()); CuckooSession session = new CuckooSession("127.0.0.1", 8090); using (CuckooManager manager = new CuckooManager(session)) { FileTask task = new FileTask(); task.Filepath = "/var/www/payload.exe"; int taskID = manager.CreateTask(task); Console.WriteLine("Created task: " + task.ID); task = (FileTask)manager.GetTaskDetails(taskID); while (task.Status == "pending" || task.Status == "running") { Console.WriteLine("Waiting 30 seconds..." + task.Status); System.Threading.Thread.Sleep(30000); task = (FileTask)manager.GetTaskDetails(taskID); } if (task.Status == "failure") { Console.Error.WriteLine("There was an error:"); foreach (var error in task.Errors) { Console.Error.WriteLine(error); } return; } string report = manager.GetTaskReport(taskID).ToString(); Console.WriteLine(report); } }