Mythic. This means you need to create a new
mythic = Mythic(username="blah" ...) and then call these functions like
ALLtasks in the operation and continue to listen for new ones. This is slightly different than the
listen_for_new_tasksfunction which simply starts listening for new tasking and doesn't give historic data.
create_taskfunction takes in the Task you want to create. At a simple example, let's look at issuing the
shell whoamicommand that you'd typically type out on the command line. We need to specify a few things:
Callbackobject or just the
idassociated with the callback). This tells Mythic which callback we're wanting to interact with. Then we need to specify the command we want to issue. This can be either a
Commandobject, or simply the string of the name of the command we want to execute,
shellin this instance. The last piece here is specifying the parameters we need to send down.
paramswill either be a string or you can specify the JSON associated with the command as well. In this case, the parameters for our
shellcommand is simply the string
whoami. At this point, we've described the Task we want to create. Now we can issue it with
create_tasktakes an interesting parameter though -
return_on. This specifies when you want to return from this function call. If you've used the interface before, you've noticed that as you go through the tasking life cycle, the status changes between a few status -
error, and sometimes
return_onfunction allows you to specify when you're ready to return. For example, if you don't specify this, the function will return as soon as Mythic gets your RESTful request (i.e. your tasking is in the
preprocessingstatus). The different status types mean:
preprocessing- Mythic got the Task request and set it off to the payload type's Docker container
submitted- Everything went well with creating Tasking and it's ready for an agent to pick up
processing- An agent picked up the tasking, but hasn't returned anything
processed- An agent sent back at least one response, but hasn't indicated that the tasking is done
completed- An agent indicated that the tasking is completed
error- An agent indicated that something went wrong after picking up the tasking.
return_on, if the task switches to
error, then it will return. You can also specify a
timeoutin seconds of how long to wait for your status to match. This is helpful for scripting so that you don't wait indefinitely for a
completedstatus if your agent is dead for example.
submitted, so there are no responses yet. In this case, we only want to continue on with our function when we have all of the tasking responses, not when we're only partially done. To facilitate this, we have an additional helper function:
uploadcommand. Let's take that as an example. The
apfellupload command takes two parameters:
remote_path- a parameter of type
Stringthat indicates the remote path of where the file will be uploaded to
file- a parameter of type
Filethat indicates the actual file we upload. If you do this in the UI, then you'll se a popup modal with a button for you to select a file from disk. Obviously, this isn't available for scripting, so we need to do something else.
issue_shell_whoamiexample above, except for one addition - the
filesparameter. This is an array of
TaskFileobject takes in a few parameters:
content- this is the binary data that we're trying to upload
filename- this is the filename we want associated with this binary content in the UI
param_name- this is the name of the parameter we're referencing with the file content. In our
uploadexample, this parameter was simply called
file, so that's what you see here. In other commands, that parameter could be called anything though.
filesparameter is an array of entries. Otherwise, you call the
mythic.create_taskjust like any other tasking function.