-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShannonObfuscator.h
More file actions
27 lines (22 loc) · 1.26 KB
/
ShannonObfuscator.h
File metadata and controls
27 lines (22 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// Created by Eteli on 18/12/2022.
//
#include "Obfuscator.h"
#include "map"
#ifndef SHANNONOBFUSCATOR_SHANNONOBFUSCATOR_H
#define SHANNONOBFUSCATOR_SHANNONOBFUSCATOR_H
class ShannonObfuscator : public Obfuscator{
public:
std::vector<unsigned char> Obfuscate(const std::vector<unsigned char> &payload) override;
std::vector<unsigned char> Reverse(const std::vector<unsigned char> &payload) override;
private:
std::map<unsigned char, std::vector<unsigned char>> _symbolEncodings;
std::vector<unsigned char> _lowEntropyPattern;
size_t payload_original_size;
std::vector<unsigned char> divideIntoChunks(const std::vector<unsigned char> &payload, const std::vector<unsigned char>& lowEntropyPattern);
std::vector<unsigned char> insertLowEntropyPattern(const std::vector<unsigned char> &payload, const std::vector<unsigned char>& lowEntropyPattern);
std::vector<unsigned char> restoreOriginalPayload(const std::vector<unsigned char>& data, const std::vector<unsigned char>& lowEntropyPattern);
std::vector<unsigned char> createShannonEncoding(const std::vector<unsigned char>& payload);
void createEncoding(const std::map<unsigned char, double>& frequencies, std::vector<unsigned char> prefix);
};
#endif //SHANNONOBFUSCATOR_SHANNONOBFUSCATOR_H