Example of usage

from pbuster import PhantomBuster

pb = PhantomBuster()

pb.agent.list()

pbuster.agent.Agent(req)

list()

Fetch all agents (Phantoms)

Returns:
  • dict

    A dictionary containing all agents (Phantoms).

get(agent_id)

Fetch a specific agent by ID

Parameters:
  • agent_id (str) –

    Agent ID to fetch

Returns:
  • dict

    A dictionary containing the agent details.

status(agent_id)

Fetch the status of the last execution of a specific agent by ID

Parameters:
  • agent_id (str) –

    Agent ID to fetch status for

Returns:
  • str

    Status of the last agent execution. [finished killed global timeout org timeout agent timeout unknown no log timeout]

output(agent_id)

Fetch the output of a specific agent by ID

Parameters:
  • agent_id (str) –

    Agent ID to fetch output for

Returns:
  • dict

    A dictionary containing the agent's output.

launch(agent_id, arguments=None)

Run a specific agent.

Parameters:
  • agent_id (str) –

    Agent ID to launch

  • arguments (dict, default: None ) –

    Arguments to send with the launch request. Some are required, depending on the script.

Returns:
  • dict

    A dictionary containing the response with the container ID of the launched agent.

launch_and_wait(agent_id, arguments=None)

Run a specific agent and wait for it to finish and get results

Parameters:
  • agent_id (str) –

    Agent ID to launch

  • arguments (dict, default: None ) –

    Arguments to send with the launch request. Some are required, depending on the script.

Returns:
  • tuple

    A tuple containing the container ID and the results of the agent execution.

wait(agent_id)

Wait for a specific agent to finish execution

Parameters:
  • agent_id (str) –

    Agent ID to wait for

Returns:
  • dict

    A dictionary containing the agent's output after it has finished executing.

create(script_name, agent_name=None, org_name='phantombuster', arguments={})

Create a new agent

Parameters:
  • script_name (str) –

    Name of the script to associate with the agent.

  • agent_name (str, default: None ) –

    Name of the agent to create.

  • org_name (str, default: 'phantombuster' ) –

    Name of the organization that owns the script. Default is "phantombuster".

  • arguments (dict, default: {} ) –

    Optional arguments to send with the agent creation request.

Returns:
  • dict

    ID of the created agent.

stop(agent_id)

Stop a specific agent by ID

Parameters:
  • agent_id (str) –

    Agent ID to stop

Returns:
  • dict

    A dictionary containing the response from the stop request.

delete(agent_id)

Delete a specific agent by ID

Parameters:
  • agent_id (str) –

    Agent ID to delete

Returns:
  • dict

    A dictionary containing the response from the delete request.