explodethosebits 0.3.0__cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- etb/__init__.py +351 -0
- etb/__init__.pyi +976 -0
- etb/_etb.cpython-39-x86_64-linux-gnu.so +0 -0
- etb/_version.py +34 -0
- etb/py.typed +2 -0
- explodethosebits-0.3.0.dist-info/METADATA +405 -0
- explodethosebits-0.3.0.dist-info/RECORD +88 -0
- explodethosebits-0.3.0.dist-info/WHEEL +6 -0
- explodethosebits-0.3.0.dist-info/licenses/LICENSE +21 -0
- explodethosebits-0.3.0.dist-info/sboms/auditwheel.cdx.json +1 -0
- explodethosebits.libs/libcudart-c3a75b33.so.12.8.90 +0 -0
- include/etb/bit_coordinate.hpp +45 -0
- include/etb/bit_extraction.hpp +79 -0
- include/etb/bit_pruning.hpp +122 -0
- include/etb/config.hpp +284 -0
- include/etb/cuda/arch_optimizations.cuh +358 -0
- include/etb/cuda/blackwell_optimizations.cuh +300 -0
- include/etb/cuda/cuda_common.cuh +265 -0
- include/etb/cuda/etb_cuda.cuh +200 -0
- include/etb/cuda/gpu_memory.cuh +406 -0
- include/etb/cuda/heuristics_kernel.cuh +315 -0
- include/etb/cuda/path_generator_kernel.cuh +272 -0
- include/etb/cuda/prefix_pruner_kernel.cuh +370 -0
- include/etb/cuda/signature_kernel.cuh +328 -0
- include/etb/early_stopping.hpp +246 -0
- include/etb/etb.hpp +20 -0
- include/etb/heuristics.hpp +165 -0
- include/etb/memoization.hpp +285 -0
- include/etb/path.hpp +86 -0
- include/etb/path_count.hpp +87 -0
- include/etb/path_generator.hpp +175 -0
- include/etb/prefix_trie.hpp +339 -0
- include/etb/reporting.hpp +437 -0
- include/etb/scoring.hpp +269 -0
- include/etb/signature.hpp +190 -0
- include/gmock/gmock-actions.h +2297 -0
- include/gmock/gmock-cardinalities.h +159 -0
- include/gmock/gmock-function-mocker.h +518 -0
- include/gmock/gmock-matchers.h +5623 -0
- include/gmock/gmock-more-actions.h +658 -0
- include/gmock/gmock-more-matchers.h +120 -0
- include/gmock/gmock-nice-strict.h +277 -0
- include/gmock/gmock-spec-builders.h +2148 -0
- include/gmock/gmock.h +96 -0
- include/gmock/internal/custom/README.md +18 -0
- include/gmock/internal/custom/gmock-generated-actions.h +7 -0
- include/gmock/internal/custom/gmock-matchers.h +37 -0
- include/gmock/internal/custom/gmock-port.h +40 -0
- include/gmock/internal/gmock-internal-utils.h +487 -0
- include/gmock/internal/gmock-port.h +139 -0
- include/gmock/internal/gmock-pp.h +279 -0
- include/gtest/gtest-assertion-result.h +237 -0
- include/gtest/gtest-death-test.h +345 -0
- include/gtest/gtest-matchers.h +923 -0
- include/gtest/gtest-message.h +252 -0
- include/gtest/gtest-param-test.h +546 -0
- include/gtest/gtest-printers.h +1161 -0
- include/gtest/gtest-spi.h +250 -0
- include/gtest/gtest-test-part.h +192 -0
- include/gtest/gtest-typed-test.h +331 -0
- include/gtest/gtest.h +2321 -0
- include/gtest/gtest_pred_impl.h +279 -0
- include/gtest/gtest_prod.h +60 -0
- include/gtest/internal/custom/README.md +44 -0
- include/gtest/internal/custom/gtest-port.h +37 -0
- include/gtest/internal/custom/gtest-printers.h +42 -0
- include/gtest/internal/custom/gtest.h +37 -0
- include/gtest/internal/gtest-death-test-internal.h +307 -0
- include/gtest/internal/gtest-filepath.h +227 -0
- include/gtest/internal/gtest-internal.h +1560 -0
- include/gtest/internal/gtest-param-util.h +1026 -0
- include/gtest/internal/gtest-port-arch.h +122 -0
- include/gtest/internal/gtest-port.h +2481 -0
- include/gtest/internal/gtest-string.h +178 -0
- include/gtest/internal/gtest-type-util.h +220 -0
- lib/libetb_core.a +0 -0
- lib64/cmake/GTest/GTestConfig.cmake +33 -0
- lib64/cmake/GTest/GTestConfigVersion.cmake +43 -0
- lib64/cmake/GTest/GTestTargets-release.cmake +49 -0
- lib64/cmake/GTest/GTestTargets.cmake +139 -0
- lib64/libgmock.a +0 -0
- lib64/libgmock_main.a +0 -0
- lib64/libgtest.a +0 -0
- lib64/libgtest_main.a +0 -0
- lib64/pkgconfig/gmock.pc +10 -0
- lib64/pkgconfig/gmock_main.pc +10 -0
- lib64/pkgconfig/gtest.pc +9 -0
- lib64/pkgconfig/gtest_main.pc +10 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#ifndef ETB_SIGNATURE_HPP
|
|
2
|
+
#define ETB_SIGNATURE_HPP
|
|
3
|
+
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
#include <optional>
|
|
8
|
+
#include <unordered_map>
|
|
9
|
+
|
|
10
|
+
namespace etb {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents a single file signature (magic bytes).
|
|
14
|
+
*/
|
|
15
|
+
struct FileSignature {
|
|
16
|
+
std::vector<uint8_t> magic_bytes; // Magic byte sequence
|
|
17
|
+
std::vector<uint8_t> mask; // Mask for partial matches (0xFF = must match)
|
|
18
|
+
uint16_t offset; // Offset from start where signature appears
|
|
19
|
+
float base_confidence; // Base confidence for this signature [0.0, 1.0]
|
|
20
|
+
|
|
21
|
+
FileSignature() : offset(0), base_confidence(0.9f) {}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a footer/trailer signature for a format.
|
|
26
|
+
*/
|
|
27
|
+
struct FooterSignature {
|
|
28
|
+
std::vector<uint8_t> magic_bytes; // Footer magic bytes
|
|
29
|
+
bool required; // Whether footer is required for full confidence
|
|
30
|
+
|
|
31
|
+
FooterSignature() : required(false) {}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents a complete format definition with all its signatures.
|
|
36
|
+
*/
|
|
37
|
+
struct FormatDefinition {
|
|
38
|
+
std::string format_name; // e.g., "PNG", "JPEG"
|
|
39
|
+
std::string category; // e.g., "image", "archive", "executable"
|
|
40
|
+
std::vector<FileSignature> signatures; // Multiple signatures for same format
|
|
41
|
+
std::optional<FooterSignature> footer; // Optional footer signature
|
|
42
|
+
uint16_t format_id; // Unique format identifier
|
|
43
|
+
|
|
44
|
+
FormatDefinition() : format_id(0) {}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Result of a signature match operation.
|
|
49
|
+
*/
|
|
50
|
+
struct SignatureMatch {
|
|
51
|
+
bool matched; // Whether a match was found
|
|
52
|
+
std::string format_name; // Matched format name
|
|
53
|
+
std::string category; // Format category
|
|
54
|
+
uint16_t format_id; // Format identifier
|
|
55
|
+
float confidence; // Match confidence [0.0, 1.0]
|
|
56
|
+
uint32_t match_offset; // Offset where match was found
|
|
57
|
+
bool header_matched; // Whether header was matched
|
|
58
|
+
bool footer_matched; // Whether footer was matched
|
|
59
|
+
|
|
60
|
+
SignatureMatch()
|
|
61
|
+
: matched(false), format_id(0), confidence(0.0f),
|
|
62
|
+
match_offset(0), header_matched(false), footer_matched(false) {}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Signature dictionary that loads and manages file signatures.
|
|
67
|
+
* Supports JSON format for signature definitions.
|
|
68
|
+
*/
|
|
69
|
+
class SignatureDictionary {
|
|
70
|
+
public:
|
|
71
|
+
SignatureDictionary() = default;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Load signatures from a JSON file.
|
|
75
|
+
* @param filepath Path to the JSON signature file
|
|
76
|
+
* @return true if loaded successfully
|
|
77
|
+
*/
|
|
78
|
+
bool load_from_json(const std::string& filepath);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Load signatures from a JSON string.
|
|
82
|
+
* @param json_content JSON content as string
|
|
83
|
+
* @return true if parsed successfully
|
|
84
|
+
*/
|
|
85
|
+
bool load_from_json_string(const std::string& json_content);
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Add a format definition programmatically.
|
|
89
|
+
* @param format The format definition to add
|
|
90
|
+
*/
|
|
91
|
+
void add_format(const FormatDefinition& format);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get all loaded format definitions.
|
|
95
|
+
*/
|
|
96
|
+
const std::vector<FormatDefinition>& get_formats() const { return formats_; }
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get format by name.
|
|
100
|
+
* @param name Format name (case-insensitive)
|
|
101
|
+
* @return Pointer to format or nullptr if not found
|
|
102
|
+
*/
|
|
103
|
+
const FormatDefinition* get_format_by_name(const std::string& name) const;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get format by ID.
|
|
107
|
+
* @param id Format ID
|
|
108
|
+
* @return Pointer to format or nullptr if not found
|
|
109
|
+
*/
|
|
110
|
+
const FormatDefinition* get_format_by_id(uint16_t id) const;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the number of loaded formats.
|
|
114
|
+
*/
|
|
115
|
+
size_t format_count() const { return formats_.size(); }
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Clear all loaded signatures.
|
|
119
|
+
*/
|
|
120
|
+
void clear();
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Check if dictionary is empty.
|
|
124
|
+
*/
|
|
125
|
+
bool empty() const { return formats_.empty(); }
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
std::vector<FormatDefinition> formats_;
|
|
129
|
+
std::unordered_map<std::string, size_t> name_index_; // name -> index in formats_
|
|
130
|
+
std::unordered_map<uint16_t, size_t> id_index_; // id -> index in formats_
|
|
131
|
+
uint16_t next_format_id_ = 1;
|
|
132
|
+
|
|
133
|
+
// Helper to parse hex string to bytes
|
|
134
|
+
static std::vector<uint8_t> hex_to_bytes(const std::string& hex);
|
|
135
|
+
|
|
136
|
+
// Helper to normalize format name for lookup
|
|
137
|
+
static std::string normalize_name(const std::string& name);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Signature matcher that performs header and footer detection.
|
|
142
|
+
*/
|
|
143
|
+
class SignatureMatcher {
|
|
144
|
+
public:
|
|
145
|
+
explicit SignatureMatcher(const SignatureDictionary& dictionary);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Match signatures against a byte sequence.
|
|
149
|
+
* Performs sliding window header matching and footer detection.
|
|
150
|
+
* @param data Byte sequence to analyze
|
|
151
|
+
* @param length Length of the byte sequence
|
|
152
|
+
* @param max_offset Maximum offset to search for headers (default: 512)
|
|
153
|
+
* @return Best signature match found
|
|
154
|
+
*/
|
|
155
|
+
SignatureMatch match(const uint8_t* data, size_t length, size_t max_offset = 512) const;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Match signatures against a vector of bytes.
|
|
159
|
+
*/
|
|
160
|
+
SignatureMatch match(const std::vector<uint8_t>& data, size_t max_offset = 512) const;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Check if data matches a specific format's header.
|
|
164
|
+
* @param data Byte sequence
|
|
165
|
+
* @param length Data length
|
|
166
|
+
* @param format_name Format to check
|
|
167
|
+
* @return Match result for the specific format
|
|
168
|
+
*/
|
|
169
|
+
SignatureMatch match_format(const uint8_t* data, size_t length,
|
|
170
|
+
const std::string& format_name) const;
|
|
171
|
+
|
|
172
|
+
private:
|
|
173
|
+
const SignatureDictionary& dictionary_;
|
|
174
|
+
|
|
175
|
+
// Check if signature matches at given position
|
|
176
|
+
bool check_signature_at(const uint8_t* data, size_t length,
|
|
177
|
+
const FileSignature& sig, size_t position) const;
|
|
178
|
+
|
|
179
|
+
// Check if footer matches at end of data
|
|
180
|
+
bool check_footer(const uint8_t* data, size_t length,
|
|
181
|
+
const FooterSignature& footer) const;
|
|
182
|
+
|
|
183
|
+
// Calculate confidence based on match quality
|
|
184
|
+
float calculate_confidence(const FileSignature& sig, bool header_matched,
|
|
185
|
+
bool footer_matched, bool footer_required) const;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
} // namespace etb
|
|
189
|
+
|
|
190
|
+
#endif // ETB_SIGNATURE_HPP
|