Skip to content

Commit b239da2

Browse files
committed
bump v0.1.1
added start/stop functions for c2 profiles and ability to save c2 instances
1 parent a1f118c commit b239da2

4 files changed

Lines changed: 69 additions & 3 deletions

File tree

mythic/mythic.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,72 @@ async def send_custom_webhook_message(
21722172
"webhook_type": webhook_type})
21732173

21742174

2175+
# ####### C2 Functions #############
2176+
2177+
async def start_stop_c2_profile(
2178+
mythic: mythic_classes.Mythic,
2179+
c2_profile_name: str,
2180+
action: str = "start"
2181+
):
2182+
query = """
2183+
query getC2IdFromName($c2_name: String!) {
2184+
c2profile(where: {name: {_eq: $c2_name}}){
2185+
id
2186+
}
2187+
}
2188+
"""
2189+
resp = await mythic_utilities.graphql_post(mythic=mythic, query=query, variables={
2190+
"c2_name": c2_profile_name,
2191+
})
2192+
if len(resp["c2profile"]) == 0:
2193+
raise Exception(f"Failed to find c2 profile {c2_profile_name}")
2194+
start_stop = """
2195+
mutation startStopC2Profile($id: Int!, $action: String!){
2196+
startStopProfile(id: $id, action: $action){
2197+
status
2198+
error
2199+
output
2200+
}
2201+
}
2202+
"""
2203+
resp = await mythic_utilities.graphql_post(mythic=mythic, query=start_stop, variables={
2204+
"id": resp["c2profile"][0]["id"], "action": action,
2205+
})
2206+
return resp["startStopProfile"]
2207+
2208+
2209+
async def create_saved_c2_instance(
2210+
mythic: mythic_classes.Mythic,
2211+
instance_name: str,
2212+
c2_profile_name: str,
2213+
c2_parameters: dict
2214+
):
2215+
query = """
2216+
query getC2IdFromName($c2_name: String!) {
2217+
c2profile(where: {name: {_eq: $c2_name}}){
2218+
id
2219+
}
2220+
}
2221+
"""
2222+
resp = await mythic_utilities.graphql_post(mythic=mythic, query=query, variables={
2223+
"c2_name": c2_profile_name,
2224+
})
2225+
if len(resp["c2profile"]) == 0:
2226+
raise Exception(f"Failed to find c2 profile {c2_profile_name}")
2227+
mutation = """
2228+
mutation createNewC2Instance($instance_name: String!, $c2_instance: String!, $c2profile_id: Int!){
2229+
create_c2_instance(c2_instance: $c2_instance, instance_name: $instance_name, c2profile_id: $c2profile_id){
2230+
status
2231+
error
2232+
}
2233+
}
2234+
"""
2235+
resp = await mythic_utilities.graphql_post(mythic=mythic, query=mutation, variables={
2236+
"instance_name": instance_name, "c2profile_id": resp["c2profile"][0]["id"], "c2_instance": json.dumps(c2_parameters)
2237+
})
2238+
return resp["create_c2_instance"]
2239+
2240+
21752241
# ####### Tag Functions ############
21762242

21772243

mythic/mythic_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(
2626
self.http = "http://" if not ssl else "https://"
2727
self.ws = "ws://" if not ssl else "wss://"
2828
self.global_timeout = global_timeout if global_timeout is not None else -1
29-
self.scripting_version = "0.1.0"
29+
self.scripting_version = "0.1.1"
3030
self.current_operation_id = 0
3131
self.schema = schema
3232

mythic/mythic_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_ws_transport(mythic: mythic_classes.Mythic) -> WebsocketsTransport
7070
websocket_transport = WebsocketsTransport(
7171
url=f"{mythic.ws}{mythic.server_ip}:{mythic.server_port}/graphql/",
7272
headers=get_headers(mythic),
73-
ssl=ssl_context,
73+
ssl=ssl_context if mythic.ssl else False,
7474
)
7575
return websocket_transport
7676

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# This call to setup() does all the work
1212
setup(
1313
name="mythic",
14-
version="0.1.0",
14+
version="0.1.1",
1515
description="Interact with Mythic C2 Framework Instances",
1616
long_description=README,
1717
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)