Skip to content

Commit 1ab9bad

Browse files
Initial readme file, with a lot of mistakes in it I guess
1 parent d15d0a4 commit 1ab9bad

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# LibBlobStamper
2+
3+
Tool for building structured data out of random input.
4+
5+
When you do fuzzing testing of a project that is complex enoght to have
6+
syntax parser, and core functionaluty behind it, your fuzzer will probably
7+
spend a lot of cpu working with syntax parser. Fuzzing syntax parser is a
8+
good thing, but it does not really help to fuzz core functionality. One of the
9+
general approaches here may be is to generate such imput data that is syntaxycally
10+
corrent from the perspectice of syntax parser, and meanwhile totally random form
11+
the perspective of core functionality.
12+
13+
LibBlobStamper is a tool for building convertors form random binary data
14+
into random data with required syntax.
15+
16+
LibBlomStamper is written in C++, can be used for genertaing both text data
17+
with desired sintax, and structured binary data (e.g. C-structures). You can
18+
build this convertor right into you binary test-unit, so this converstion will be
19+
opaque both for fuzzer, or DSE-tools.
20+
21+
## Synopsys
22+
23+
```c++
24+
Blob blob(data, data_length);
25+
StampArithm<short int> stamp; // Stamp that work with arithmetic data (integers, and floats)
26+
27+
std::string s = stamp.ExtractStr(blob); // Get integrer formatted as string
28+
std::vector<char> vec= stamp.ExtractBin(blob); // Get binary data represeted as byte array
29+
short int i = stamp.ExtractValue(blob) // Get data represented as a value, that can be used in the code
30+
```
31+
32+
```c++
33+
typedef struct // Some complex structure, e.g. complex number
34+
{
35+
float re,im;
36+
} Complex;
37+
38+
class StampComplex: public StampBaseStr, public StampBaseV<Complex> // Stamp will have String and Value result representation
39+
{
40+
private:
41+
StampArithm<float> stamp; // Substamp that is used while building result
42+
public:
43+
int maxSize() override {return stamp.maxSize()*2;}; // Should set minimum and maximum ammount of data that can be consumed by stamp
44+
int minSize() override {return stamp.minSize()*2;};
45+
virtual Complex ExtractValue(Blob &blob) override; // Method that constructs "value" representation
46+
virtual std::string ExtractStr(Blob &blob) override; // Method that constructs "string" representation
47+
};
48+
49+
Complex StampComplex::ExtractValue(Blob &blob)
50+
{
51+
Complex c;
52+
c.re = stamp.ExtractValue(blob); // Just fill the structure with float values and return it
53+
c.im = stamp.ExtractValue(blob);
54+
return c;
55+
}
56+
57+
std::string StampComplex::ExtractStr(Blob &blob)
58+
{
59+
std::string s_re = stamp.ExtractStr(blob); // Get numbers as a string
60+
std::string s_im = stamp.ExtractStr(blob);
61+
return s_re + " + i" + s_im; // Make result string out of them
62+
}
63+
64+
// ......................... Somwhere in main() function ....................................
65+
66+
Blob blob(data, data_len);
67+
68+
StampComplex stamp;
69+
std::string s = stamp.ExtractStr(blob);
70+
Complex c = stamp.ExtractValue(blob);
71+
```
72+
73+
## Basic Definitions
74+
75+
### Blob
76+
77+
Blob is a chunk of binary data that came from fuzzer, or other source, it is
78+
considered to be random. Stamps consumes data from the Blob, for costructing
79+
values and for "divination": if Stamp to make some desidion, you get some data from
80+
the Blob and iterpret it as a "prediction" telling it what to do. E.g. tell the stamp in what
81+
propotion remaining data should be split for two subordinate Stamps, that can consume any
82+
ammount of data. Since blob data is considered to be random, you will cover all possible
83+
proportions in a long run. Blob implemented as C++ onject.
84+
85+
### Stamp
86+
87+
Stamp is a C++ object that knows how to convert some chunk of data into certain structured
88+
representation.
89+
90+
Basic properties of Stamp from the perspective of data consumation:
91+
92+
* Stamp should know how much data it can consume to produce structured result. Minimanl
93+
ammount ammount and maximum ammount. These values should be available via minSize() and maxSize()
94+
methods.
95+
96+
* Stamp is greedy, it consimes as much data as it can. If your blob is long enought, the Stamp will
97+
byte maxSize() bytes from it. If you want to limit Stamp's appetite, you should wrap it in a Galley
98+
somehow.
99+
100+
All stamps iherits StampBase class.
101+
102+
103+
104+
105+
106+
107+
108+

0 commit comments

Comments
 (0)