-
-
Notifications
You must be signed in to change notification settings - Fork 574
Open
Description
Hi,
I am trying to get my head around custom EKE.
Simple DH.
I end up with Unknown action for IterateAndAct: decrypt with value:
comming from
| err = errors.New(fmt.Sprintf("Unknown action for IterateAndAct: %s with value: %s", action, keyOpt.Value)) |
So apparently
"crypto_type": 'aes256_hmac' is lost somewhere.Also, returning a list of bytes in the JSON seems odd.
As does wrapping the message manually with
b64encode(UUID+AES(<data>))
def wire_msg(crypt_key, data):
"""crypt if needed the mythic way"""
from Crypto.Cipher import AES
from hashlib import sha256
from hmac import new as hmac
from Crypto.Util.Padding import unpad, pad
#SendMythicRPCCallbackEncryptBytes
if crypt_key.Value == "aes256_hmac":
iv = urandom(16)
key = crypt_key.EncKey
aescbc = AES.new(key, AES.MODE_CBC, iv)
e = aescbc.encrypt(pad(data,16))
data = iv + e + hmac(key, iv+e, sha256).digest()
return data
else:
return data
def c22mythic(data: bytes) -> dict:
"""turn c2 bytes into mythics dict with action and so on"""
# [...]
def mythic2c2(m: dict) -> bytes:
"""turn dict with action and so on into c2 bytes"""
# [...]
class myPythonTranslation(TranslationContainer):
name = "test"
# [...]
async def translate_from_c2_format(self, inputMsg: TrCustomMessageToMythicC2FormatMessage) -> TrCustomMessageToMythicC2FormatMessageResponse:
# [...]
m = c22mythic(inputMsg.Message)
if m['action'] == 'eke_dh':
# [...]
from uuid import uuid4
tmp = uuid4()
bob_public = # [...]
new_aes_key = # [...]
m = {
"action": "staging_translation",
"session_id": "",#some string session id you want to save
"enc_key": list(new_aes_key),#the bytes of an encryption key for the next message
"dec_key": list(new_aes_key),#the bytes of a decryption key for the next message
"crypto_type": 'aes256_hmac',
"next_uuid": str(tmp),
"message": list(b64encode(UUID(inputMsg.UUID).bytes+wire_msg(
inputMsg.CryptoKeys[0],
mythic2c2({
'action':'eke_dh',
'tmp': tmp.bytes,
'public':bob_public
}))))
}
response = TrCustomMessageToMythicC2FormatMessageResponse(Success=True)
response.Message = m
return responseReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels