[docs]classTuoniJob:""" A class that provides data and functionality for a job. Attributes: job_id (int): The unique identifier of the job. name (str): Name of the job. status (str): Status of the job. source (dict): Source for the job. supportedActions (list): What actions are allowed on the job. openResources (list): What resources are open related to this job. messages (list): Messages related to job. createEvent (TuoniEvent): Event about job creation. lastUpdateEvent (TuoniEvent): Event about last job update. """def__init__(self,conf,c2):""" Constructor for the job class. Args: conf (dict): Data from the server. c2 (TuoniC2): The related server object that manages communication. """self._load_conf(conf)self.c2=c2def_load_conf(self,conf):self.job_id=conf["id"]self.name=conf["name"]self.status=conf["status"]self.source=conf["source"]self.supportedActions=conf["supportedActions"]self.openResources=conf["openResources"]self.messages=conf["messages"]self.createEvent=TuoniEvent(conf["createEvent"])if(conf["createEvent"]isnotNone)elseNoneself.lastUpdateEvent=TuoniEvent(conf["lastUpdateEvent"])if(conf["lastUpdateEvent"]isnotNone)elseNone
[docs]defreload(self):""" Reload the command data from the C2 server. """ifself.command_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_get(f"/api/v1/job/{self.job_id}")self._load_conf(data)
[docs]defrestart(self):""" Run restart operation on the job. """ifself.command_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_get(f"/api/v1/job/{self.job_id}/restart")
[docs]defpause(self):""" Run pause operation on the job. """ifself.command_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_get(f"/api/v1/job/{self.job_id}/pause")
[docs]defresume(self):""" Run resume operation on the job. """ifself.command_idisNone:raiseExceptionTuoniDeleted("")data=self.c2.request_get(f"/api/v1/job/{self.job_id}/resume")