Skip to content

Commit

Permalink
fixed a bug where re-adding deleted c2/build parameters of the same n…
Browse files Browse the repository at this point in the history
…ame wouldn't clear the deleted flag and wouldn't be visible in the UI
  • Loading branch information
its-a-feature committed Dec 20, 2022
1 parent 832a9ef commit a0ef642
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mythic-docker/app/api/c2profiles_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,7 @@ async def import_c2_profile_func(data, operator, rabbitmqName):
# print("Created new c2 profile: {}".format(data['name']))
curr_parameters = await app.db_objects.execute(
db_model.c2profileparameters_query.where(
(db_model.C2ProfileParameters.c2_profile == profile) &
(db_model.C2ProfileParameters.deleted == False)
(db_model.C2ProfileParameters.c2_profile == profile)
)
)
curr_parameters_dict = {c.name: c for c in curr_parameters}
Expand All @@ -721,6 +720,7 @@ async def import_c2_profile_func(data, operator, rabbitmqName):
c2_profile_param.parameter_type = param["parameter_type"]
c2_profile_param.verifier_regex = param["verifier_regex"]
c2_profile_param.crypto_type = param["crypto_type"]
c2_profile_param.deleted = False
await app.db_objects.update(c2_profile_param)
except Exception as e:
print(str(e))
Expand Down
7 changes: 3 additions & 4 deletions mythic-docker/app/api/payloadtype_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ async def import_payload_type_func(ptype, operator, rabbitmqName):
current_params = await app.db_objects.execute(
db_model.buildparameter_query.where(
(db_model.BuildParameter.payload_type == payload_type)
& (db_model.BuildParameter.deleted == False)
)
)
build_param_dict = {b.name: b for b in current_params}
Expand All @@ -331,14 +330,14 @@ async def import_payload_type_func(ptype, operator, rabbitmqName):
buildparam = await app.db_objects.get(
db_model.buildparameter_query,
payload_type=payload_type,
name=bp["name"],
deleted=False,
name=bp["name"]
)
buildparam.parameter_type = bp["parameter_type"]
buildparam.description = bp["description"]
buildparam.required = bp["required"]
buildparam.verifier_regex = bp["verifier_regex"]
buildparam.parameter = bp["parameter"]
buildparam.deleted = False
await app.db_objects.update(buildparam)
build_param_dict.pop(bp["name"], None)
except Exception as e:
Expand Down Expand Up @@ -512,7 +511,6 @@ async def import_command_func(payload_type, operator, command_list):
current_commands = await app.db_objects.execute(
db_model.command_query.where(
(db_model.Command.payload_type == payload_type)
& (db_model.Command.deleted == False)
)
)
for command in current_commands:
Expand All @@ -527,6 +525,7 @@ async def import_command_func(payload_type, operator, command_list):
command.author = cmd["author"]
command.attributes = js.dumps(cmd["attributes"])
command.script_only = cmd["script_only"]
command.deleted = False
await add_update_opsec_for_command(command, cmd)
await app.db_objects.update(command)

Expand Down

0 comments on commit a0ef642

Please sign in to comment.