Feature: Implement initial macOS SimpleRemoter client
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
This is an implementation of the AES algorithm, specifically ECB, CTR and CBC mode.
|
||||
This is an implementation of the AES algorithm, specifically ECB, AES_MODE_CTR and CBC mode.
|
||||
Block size can be chosen in aes.h - available choices are AES128, AES192, AES256.
|
||||
|
||||
The implementation is verified against the test vectors in:
|
||||
@@ -221,7 +221,7 @@ void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key)
|
||||
{
|
||||
KeyExpansion(ctx->RoundKey, key);
|
||||
}
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(AES_MODE_CTR) && (AES_MODE_CTR == 1))
|
||||
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv)
|
||||
{
|
||||
KeyExpansion(ctx->RoundKey, key);
|
||||
@@ -528,7 +528,7 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
|
||||
|
||||
|
||||
|
||||
#if defined(CTR) && (CTR == 1)
|
||||
#if defined(AES_MODE_CTR) && (AES_MODE_CTR == 1)
|
||||
|
||||
/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */
|
||||
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
|
||||
@@ -560,5 +560,5 @@ void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if defined(CTR) && (CTR == 1)
|
||||
#endif // #if defined(AES_MODE_CTR) && (AES_MODE_CTR == 1)
|
||||
|
||||
|
||||
14
common/aes.h
14
common/aes.h
@@ -7,7 +7,7 @@
|
||||
// #define the macros below to 1/0 to enable/disable the mode of operation.
|
||||
//
|
||||
// CBC enables AES encryption in CBC-mode of operation.
|
||||
// CTR enables encryption in counter-mode.
|
||||
// AES_MODE_CTR enables encryption in counter-mode.
|
||||
// ECB enables the basic ECB 16-byte block algorithm. All can be enabled simultaneously.
|
||||
|
||||
// The #ifndef-guard allows it to be configured before #include'ing or at compile time.
|
||||
@@ -19,8 +19,8 @@
|
||||
#define ECB 1
|
||||
#endif
|
||||
|
||||
#ifndef CTR
|
||||
#define CTR 1
|
||||
#ifndef AES_MODE_CTR
|
||||
#define AES_MODE_CTR 1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
|
||||
struct AES_ctx {
|
||||
uint8_t RoundKey[AES_keyExpSize];
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(AES_MODE_CTR) && (AES_MODE_CTR == 1))
|
||||
uint8_t Iv[AES_BLOCKLEN];
|
||||
#endif
|
||||
};
|
||||
|
||||
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||
#if (defined(CBC) && (CBC == 1)) || (defined(AES_MODE_CTR) && (AES_MODE_CTR == 1))
|
||||
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
|
||||
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);
|
||||
#endif
|
||||
@@ -75,7 +75,7 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
#endif // #if defined(CBC) && (CBC == 1)
|
||||
|
||||
|
||||
#if defined(CTR) && (CTR == 1)
|
||||
#if defined(AES_MODE_CTR) && (AES_MODE_CTR == 1)
|
||||
|
||||
// Same function for encrypting as for decrypting.
|
||||
// IV is incremented for every block, and used after encryption as XOR-compliment for output
|
||||
@@ -84,7 +84,7 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
// no IV should ever be reused with the same key
|
||||
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
|
||||
#endif // #if defined(CTR) && (CTR == 1)
|
||||
#endif // #if defined(AES_MODE_CTR) && (AES_MODE_CTR == 1)
|
||||
|
||||
|
||||
#endif // _AES_H_
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
typedef int64_t __int64;
|
||||
typedef uint16_t WORD;
|
||||
typedef uint32_t DWORD;
|
||||
typedef int BOOL, SOCKET;
|
||||
#ifndef BOOL
|
||||
typedef bool BOOL;
|
||||
#endif
|
||||
typedef int SOCKET;
|
||||
typedef unsigned int ULONG;
|
||||
typedef unsigned int UINT;
|
||||
typedef void VOID;
|
||||
@@ -533,6 +536,7 @@ enum {
|
||||
CLIENT_TYPE_SHELLCODE = 4, // Shellcode
|
||||
CLIENT_TYPE_MEMDLL = 5, // 内存DLL运行
|
||||
CLIENT_TYPE_LINUX = 6, // LINUX 客户端
|
||||
CLIENT_TYPE_MACOS = 7, // MACOS 客户端
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -558,6 +562,8 @@ inline const char* GetClientType(int typ)
|
||||
return "MDLL";
|
||||
case CLIENT_TYPE_LINUX:
|
||||
return "LNX";
|
||||
case CLIENT_TYPE_MACOS:
|
||||
return "MAC";
|
||||
default:
|
||||
return "DLL";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user