@@ -54,7 +54,7 @@ async def login(
5454 log_format = log_format ,
5555 schema = None ,
5656 )
57- #logging.basicConfig(format="%(levelname)s:%(message)s", level=logging_level)
57+ # logging.basicConfig(format="%(levelname)s:%(message)s", level=logging_level)
5858 if apitoken is None :
5959 url = f"{ mythic .http } { mythic .server_ip } :{ mythic .server_port } /auth"
6060 data = {
@@ -1245,7 +1245,8 @@ async def waitfor_for_task_output(
12451245 final_output = b""
12461246 for output in aggregated_output :
12471247 final_output += base64 .b64decode (output ["response_text" ])
1248- subtaskIds = await get_all_subtask_ids (mythic = mythic , task_display_id = task_display_id , fetch_display_id_instead = True )
1248+ subtaskIds = await get_all_subtask_ids (mythic = mythic , task_display_id = task_display_id ,
1249+ fetch_display_id_instead = True )
12491250 for subtask in subtaskIds :
12501251 subtaskOutput = await get_all_task_output_by_id (mythic = mythic , task_display_id = subtask )
12511252 for r in subtaskOutput :
@@ -1359,7 +1360,8 @@ async def get_all_task_and_subtask_output_by_id(
13591360 initial = await mythic_utilities .graphql_post (
13601361 mythic = mythic , query = query , variables = {"task_display_id" : task_display_id }
13611362 )
1362- subtaskIds = await get_all_subtask_ids (mythic = mythic , task_display_id = task_display_id , fetch_display_id_instead = True )
1363+ subtaskIds = await get_all_subtask_ids (mythic = mythic , task_display_id = task_display_id ,
1364+ fetch_display_id_instead = True )
13631365 for subtask in subtaskIds :
13641366 subtaskOutput = await get_all_task_output_by_id (mythic = mythic , task_display_id = subtask )
13651367 for r in subtaskOutput :
@@ -1408,7 +1410,6 @@ async def subscribe_new_task_output(
14081410 return
14091411
14101412
1411-
14121413async def subscribe_all_task_output (
14131414 mythic : mythic_classes .Mythic ,
14141415 timeout : int = None ,
@@ -2569,6 +2570,7 @@ async def create_tag(mythic: mythic_classes.Mythic,
25692570 response_ids : List [int ] = None ,
25702571 task_ids : List [int ] = None ,
25712572 taskartifact_ids : List [int ] = None ) -> List [dict ]:
2573+ # this will create a new instance of a tag for every id listed in every group
25722574 def get_mutation (target_object : str ) -> str :
25732575 return f"""
25742576 mutation createTag($tagtype_id: Int!, $source: String!, $url: String!, $data: jsonb!, ${ target_object } : Int!) {{
@@ -2623,3 +2625,44 @@ def get_mutation(target_object: str) -> str:
26232625 })
26242626 output .append (resp )
26252627 return output
2628+
2629+
2630+ async def create_tag_for_multiple_objects (mythic : mythic_classes .Mythic ,
2631+ tag_type_id : int ,
2632+ source : str = "" ,
2633+ url : str = "" ,
2634+ data : str = "" ,
2635+ credential_id : int = None ,
2636+ filemeta_id : int = None ,
2637+ keylog_id : int = None ,
2638+ mythictree_id : int = None ,
2639+ response_id : int = None ,
2640+ task_id : int = None ,
2641+ taskartifact_id : int = None ) -> dict :
2642+ # This will create a single tag instance and associate it with multiple objects within Mythic
2643+ add_tag_query = f"""
2644+ mutation createTag($tagtype_id: Int!, $source: String!, $url: String!, $data: jsonb!, $credential_id: Int, $filemeta_id: Int, $keylog_id: Int, $mythictree_id: Int, $response_id: Int, $task_id: Int, $taskartifact_id: Int) {{
2645+ insert_tag_one(object: {{data: $data, source: $source, tagtype_id: $tagtype_id, url: $url, credential_id: $credential_id, filemeta_id: $filemeta_id, keylog_id: $keylog_id, mythictree_id: $mythictree_id, response_id:$response_id, task_id:$task_id, taskartifact_id: $taskartifact_id }}) {{
2646+ id
2647+ }}
2648+ }}
2649+ """
2650+ return await mythic_utilities .graphql_post (mythic = mythic , query = add_tag_query , variables = {
2651+ "tagtype_id" : tag_type_id , "source" : source , "url" : url , "data" : data , "credential_id" : credential_id ,
2652+ "filemeta_id" : filemeta_id , "keylog_id" : keylog_id , "mythictree_id" : mythictree_id , "response_id" : response_id ,
2653+ "task_id" : task_id , "taskartifact_id" : taskartifact_id
2654+ })
2655+
2656+
2657+ async def remove_tag (mythic : mythic_classes .Mythic , tag_id : int ) -> dict :
2658+ # This deletes a tag from Mythic by its tag id (this doesn't remove the type of tag, just a single instance of a tag)
2659+ remove_tag_query = f"""
2660+ mutation removeTag($tag_id: Int!) {{
2661+ delete_tag_by_pk(id: $tag_id) {{
2662+ id
2663+ }}
2664+ }}
2665+ """
2666+ return await mythic_utilities .graphql_post (mythic = mythic , query = remove_tag_query , variables = {
2667+ "tag_id" : tag_id ,
2668+ })
0 commit comments