Skip to content

Bug in AES decryption agent c# code #17

Description

@antonioCoco

The agent webshell has a bug that converts the returned decrypted blob data into a string and then converts it back to an array of bytes. While it seems there are no particular problems in exchanging data, it could cause some issues for future use, e.g. Network tunneling.

This code https://github.com/antonioCoco/SharPyShell/blob/master/agent/runtime_compiler/runtime_compiler_aes.cs#L49 should be replaced with something like this:

ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV);
using (MemoryStream msDecrypt = new MemoryStream(encrypted))
{
    using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
    {
        csDecrypt.Read(encrypted, 0, encrypted.Length);
    }
    plain = msDecrypt.ToArray();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions