Compare commits
553 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a98805b4ca | ||
![]() |
68e7b203f5 | ||
![]() |
57a64e805f | ||
![]() |
78060ea308 | ||
![]() |
63e1523358 | ||
![]() |
ef8ebd5239 | ||
![]() |
2726a59711 | ||
![]() |
7894efe728 | ||
![]() |
fce5fd9a2b | ||
![]() |
a0a4dd60bb | ||
![]() |
ee447468c6 | ||
![]() |
2f036b72e4 | ||
![]() |
002656b076 | ||
![]() |
c2db7ad162 | ||
![]() |
b336411516 | ||
![]() |
686d29a3cb | ||
![]() |
fad59987d9 | ||
![]() |
210315da0f | ||
![]() |
108c04a8d2 | ||
![]() |
517d6962bd | ||
![]() |
5d83c9399a | ||
![]() |
bc458864f1 | ||
![]() |
5d5ee40329 | ||
![]() |
c84629a2f8 | ||
![]() |
1545514ed8 | ||
![]() |
00740190a7 | ||
![]() |
84a87f1da8 | ||
![]() |
bd12e060ca | ||
![]() |
16af5debbe | ||
![]() |
b4e987a640 | ||
![]() |
f1aee3c376 | ||
![]() |
43c9100f59 | ||
![]() |
28f34e076e | ||
![]() |
903a242e3e | ||
![]() |
4a94bcb806 | ||
![]() |
cad2ff6319 | ||
![]() |
9a1173d4a6 | ||
![]() |
9345b80256 | ||
![]() |
ba394c4acc | ||
![]() |
379e2ae89b | ||
![]() |
86cb187ef1 | ||
![]() |
281524dbf9 | ||
![]() |
1e96652ed2 | ||
![]() |
aa69436b64 | ||
![]() |
a278357ed9 | ||
![]() |
a013ad6085 | ||
![]() |
57296a6750 | ||
![]() |
cc1ebb29f7 | ||
![]() |
d606d9f4f6 | ||
![]() |
d7825851e9 | ||
![]() |
0750a6c3ca | ||
![]() |
b1888e12c9 | ||
![]() |
7acdeacae8 | ||
![]() |
8c62d339a2 | ||
![]() |
1138e6a341 | ||
![]() |
6300c5f493 | ||
![]() |
d53503b73e | ||
![]() |
c97d0fa7fc | ||
![]() |
6089cc21ce | ||
![]() |
c9e147de8c | ||
![]() |
8545778780 | ||
![]() |
65ddfa6acf | ||
![]() |
8a18ee4ece | ||
![]() |
1aede04af7 | ||
![]() |
bae24d9072 | ||
![]() |
56b37bb4bd | ||
![]() |
fd98eabfbf | ||
![]() |
2e980ca08d | ||
![]() |
745326ee26 | ||
![]() |
976d6b2e97 | ||
![]() |
ad33ea086b | ||
![]() |
c6c93b5785 | ||
![]() |
fdfa5b2d48 | ||
![]() |
f34bab2486 | ||
![]() |
406e77faa9 | ||
![]() |
02cd260af0 | ||
![]() |
c9403cbd00 | ||
![]() |
0db67dfc9a | ||
![]() |
0b38fabeb0 | ||
![]() |
77dfc7a26a | ||
![]() |
1b7e1da809 | ||
![]() |
cb9ace52e1 | ||
![]() |
f6ba9de044 | ||
![]() |
4c17da00b0 | ||
![]() |
67aa5b12c1 | ||
![]() |
35e387773c | ||
![]() |
6986317a03 | ||
![]() |
47cd4dfea6 | ||
![]() |
31f4669794 | ||
![]() |
bbb999f4d5 | ||
![]() |
c94c26cb56 | ||
![]() |
bc91436ef4 | ||
![]() |
0bba8535b8 | ||
![]() |
30686a2d28 | ||
![]() |
2ade1ee1f6 | ||
![]() |
f17e49e9aa | ||
![]() |
74783c2027 | ||
![]() |
cffbf069d2 | ||
![]() |
d4e9107fc2 | ||
![]() |
7f68f66d70 | ||
![]() |
cce25d0a94 | ||
![]() |
fc16b70a65 | ||
![]() |
a9014a9419 | ||
![]() |
25409119ff | ||
![]() |
20f1119bab | ||
![]() |
a27553daec | ||
![]() |
f35c59131d | ||
![]() |
b20fda2a4a | ||
![]() |
583c84ab4e | ||
![]() |
5854fd0c5b | ||
![]() |
ee9eb3eef1 | ||
![]() |
60b3408737 | ||
![]() |
d2ff88f6ff | ||
![]() |
2474691623 | ||
![]() |
f31c2cc4ce | ||
![]() |
70b75e7fdb | ||
![]() |
0932421020 | ||
![]() |
6f67919622 | ||
![]() |
5b0e3dd3bc | ||
![]() |
d3a4b726d8 | ||
![]() |
9755d189dd | ||
![]() |
78fd4e0d39 | ||
![]() |
9c3f8f4511 | ||
![]() |
19aac2fc04 | ||
![]() |
652c24cb2a | ||
![]() |
7cb1080e35 | ||
![]() |
4e6ad397ec | ||
![]() |
fd229328eb | ||
![]() |
b3483ddd42 | ||
![]() |
324db072a2 | ||
![]() |
74435e1461 | ||
![]() |
c1006c4d38 | ||
![]() |
c1eef33b5d | ||
![]() |
dc7d561621 | ||
![]() |
aa7993de10 | ||
![]() |
c103444396 | ||
![]() |
6251ad0051 | ||
![]() |
a092aed538 | ||
![]() |
f70a16a09a | ||
![]() |
761a77fce0 | ||
![]() |
0e149afd7a | ||
![]() |
7f0a4f1d7e | ||
![]() |
fdd2f53871 | ||
![]() |
3625e881a3 | ||
![]() |
8f6efe993d | ||
![]() |
27333f9ce8 | ||
![]() |
6d0d4e287a | ||
![]() |
d4f47340a3 | ||
![]() |
acecf46fb9 | ||
![]() |
b3e82ad36e | ||
![]() |
0b889312ae | ||
![]() |
defe9084ae | ||
![]() |
84beb61c3f | ||
![]() |
5311ce705a | ||
![]() |
b090bc7b4b | ||
![]() |
04aecd97f6 | ||
![]() |
c791a23456 | ||
![]() |
4c0e01c4aa | ||
![]() |
9645dca274 | ||
![]() |
2076fc0722 | ||
![]() |
a0bcdfa005 | ||
![]() |
1b6ef52a4e | ||
![]() |
f27107c5e4 | ||
![]() |
7e5a1dba05 | ||
![]() |
256d010981 | ||
![]() |
134fe6a992 | ||
![]() |
d0d378c174 | ||
![]() |
00033426e7 | ||
![]() |
d68c70b0f5 | ||
![]() |
bca14c041b | ||
![]() |
09295ae819 | ||
![]() |
81bdbc0dde | ||
![]() |
9149d69699 | ||
![]() |
5710c8b28a | ||
![]() |
51e4d814fb | ||
![]() |
c91fc9a521 | ||
![]() |
61ad4a6ee8 | ||
![]() |
ab837cbbf5 | ||
![]() |
638d315b57 | ||
![]() |
f3a4f4f664 | ||
![]() |
7d2c854b71 | ||
![]() |
e66eb33e96 | ||
![]() |
062ae9d544 | ||
![]() |
7dd7c1a485 | ||
![]() |
b45985c76b | ||
![]() |
1357b9f310 | ||
![]() |
0a0c4639a6 | ||
![]() |
6a2d6fa66d | ||
![]() |
713f0c5913 | ||
![]() |
fc6df5ef47 | ||
![]() |
8d8fcdd8db | ||
![]() |
6df415438d | ||
![]() |
760edbf0d2 | ||
![]() |
04c8d5208b | ||
![]() |
4a96354276 | ||
![]() |
209d38a768 | ||
![]() |
9aa40c0734 | ||
![]() |
f7c94f9a85 | ||
![]() |
9208531951 | ||
![]() |
862de53cf6 | ||
![]() |
f68fe95f09 | ||
![]() |
e89e8dbaab | ||
![]() |
c84c105fb9 | ||
![]() |
20cee8cd33 | ||
![]() |
2f840ef92d | ||
![]() |
454142c29e | ||
![]() |
d338b30c08 | ||
![]() |
8f27b14eb8 | ||
![]() |
65ec23fd35 | ||
![]() |
1922cb0a65 | ||
![]() |
942c6a42ac | ||
![]() |
174b852e0a | ||
![]() |
389c7c6554 | ||
![]() |
0b43711dc9 | ||
![]() |
a14363f1fc | ||
![]() |
6e5d102673 | ||
![]() |
a426b6fc3d | ||
![]() |
c31ca2c9f7 | ||
![]() |
c6bfb07832 | ||
![]() |
1d746b4074 | ||
![]() |
173b14258b | ||
![]() |
0eceafe0c5 | ||
![]() |
35fa881ff0 | ||
![]() |
b0179b4498 | ||
![]() |
b5774b2275 | ||
![]() |
5c05b3d32d | ||
![]() |
bc42880274 | ||
![]() |
0be4847cb7 | ||
![]() |
8f16001c47 | ||
![]() |
698ebb6b35 | ||
![]() |
dcdfa978a4 | ||
![]() |
b02592c5c7 | ||
![]() |
9650e06b45 | ||
![]() |
e0d90aa67f | ||
![]() |
b9879a8bfc | ||
![]() |
a55d40cd00 | ||
![]() |
ff2f325d68 | ||
![]() |
8ca2df8819 | ||
![]() |
4bee9a9039 | ||
![]() |
418d0dba91 | ||
![]() |
b877ed7e0e | ||
![]() |
51e2f64e5b | ||
![]() |
3bf3172928 | ||
![]() |
dfaf06a22e | ||
![]() |
a0c03fccc5 | ||
![]() |
83f739f010 | ||
![]() |
5dd5b1efa8 | ||
![]() |
dbba687b9b | ||
![]() |
f752acc2a4 | ||
![]() |
febb154e49 | ||
![]() |
e9e9c457d6 | ||
![]() |
d69cde896c | ||
![]() |
f4f55088e3 | ||
![]() |
fc809ccb33 | ||
![]() |
006dcac00c | ||
![]() |
90e9f3c786 | ||
![]() |
ac4a0e7330 | ||
![]() |
fc9caa8314 | ||
![]() |
37bfead4e5 | ||
![]() |
eae6f0436f | ||
![]() |
cb24b5dc2d | ||
![]() |
993eb62bb8 | ||
![]() |
81e9a9a60f | ||
![]() |
b064eb3994 | ||
![]() |
f0563475c3 | ||
![]() |
36b1d8aea2 | ||
![]() |
003b219826 | ||
![]() |
eb362c5c77 | ||
![]() |
11fc57a5d7 | ||
![]() |
f76331eac7 | ||
![]() |
a95b322b1c | ||
![]() |
1609960244 | ||
![]() |
72e54ac2f4 | ||
![]() |
3e0e753e9f | ||
![]() |
2002bbca35 | ||
![]() |
109755208e | ||
![]() |
1ad1b7cb17 | ||
![]() |
65368408dd | ||
![]() |
cbf0952ec7 | ||
![]() |
2885b10f70 | ||
![]() |
33aa012bdd | ||
![]() |
3f8c5f585b | ||
![]() |
2712430f93 | ||
![]() |
fe6daecf0b | ||
![]() |
52ab8c02d6 | ||
![]() |
44bbaf7d22 | ||
![]() |
8cca87f2bd | ||
![]() |
e5b3e5a677 | ||
![]() |
829b5049e6 | ||
![]() |
07f4c42ecf | ||
![]() |
4897c3f205 | ||
![]() |
c0e1236a07 | ||
![]() |
6f4955619a | ||
![]() |
07047cb3bb | ||
![]() |
97b3d3c7c7 | ||
![]() |
c6062889d5 | ||
![]() |
871dfa0a01 | ||
![]() |
71aa0221a0 | ||
![]() |
07530fea57 | ||
![]() |
dad8217c38 | ||
![]() |
dec202e6d6 | ||
![]() |
c66c3ff2b8 | ||
![]() |
f858e1a247 | ||
![]() |
751d96f45a | ||
![]() |
62b1bde7a9 | ||
![]() |
fa63493cee | ||
![]() |
7d67fc77b5 | ||
![]() |
60c1990f4a | ||
![]() |
747a636f4f | ||
![]() |
fa1e3fd504 | ||
![]() |
356698c24b | ||
![]() |
8445ae54b3 | ||
![]() |
0336eae908 | ||
![]() |
594ce420fc | ||
![]() |
53dd6c6be6 | ||
![]() |
258780370f | ||
![]() |
89876f2d89 | ||
![]() |
5a6d683fed | ||
![]() |
aa6d331110 | ||
![]() |
dc82a53bec | ||
![]() |
2be9686a80 | ||
![]() |
b9b70b0d51 | ||
![]() |
0d7d52decf | ||
![]() |
6f21cb3848 | ||
![]() |
cba9df9a28 | ||
![]() |
4029069640 | ||
![]() |
52557aefdd | ||
![]() |
3fd5671909 | ||
![]() |
66127d8492 | ||
![]() |
efc5756e3f | ||
![]() |
b7c1591b00 | ||
![]() |
20f8cb10eb | ||
![]() |
d2e4b9f206 | ||
![]() |
6d2284d8b9 | ||
![]() |
1da621456f | ||
![]() |
659e91fb68 | ||
![]() |
b9a540561b | ||
![]() |
91b10f8c40 | ||
![]() |
6883c776ef | ||
![]() |
a2719cf559 | ||
![]() |
0c7d42d28b | ||
![]() |
52d557aa8f | ||
![]() |
be1d3da159 | ||
![]() |
8bd18ef007 | ||
![]() |
fe8c06dd8f | ||
![]() |
721c02cd2c | ||
![]() |
a8e64be169 | ||
![]() |
53659f8a5c | ||
![]() |
6929c89b86 | ||
![]() |
c8c5d89f33 | ||
![]() |
abd8efabd3 | ||
![]() |
f9c74ed5d6 | ||
![]() |
cf79d13d17 | ||
![]() |
5b02fb420d | ||
![]() |
c8fad7833d | ||
![]() |
95d1069393 | ||
![]() |
b2f9e23975 | ||
![]() |
8ff8ae41f1 | ||
![]() |
dde7bc9b5c | ||
![]() |
f248a061ef | ||
![]() |
037b9551ea | ||
![]() |
eab7c32e9f | ||
![]() |
8ade809588 | ||
![]() |
39c0a2040b | ||
![]() |
e2f4e83890 | ||
![]() |
fc23782dc3 | ||
![]() |
96e24d1c8b | ||
![]() |
fd68c8a81f | ||
![]() |
fafa27a7e9 | ||
![]() |
c881dc996d | ||
![]() |
cdd3d8ace0 | ||
![]() |
863a6b8b7c | ||
![]() |
1b9ffcec74 | ||
![]() |
aa3f126100 | ||
![]() |
21ee8d2cae | ||
![]() |
b519d24981 | ||
![]() |
f73e2006fc | ||
![]() |
0f633962ff | ||
![]() |
6523341c4d | ||
![]() |
0d446bab20 | ||
![]() |
807a534121 | ||
![]() |
1bd21509af | ||
![]() |
ccd1211cd2 | ||
![]() |
590d3655cd | ||
![]() |
ea512f70f8 | ||
![]() |
a01863696e | ||
![]() |
702f163c13 | ||
![]() |
0c9933c3e4 | ||
![]() |
ae2caff990 | ||
![]() |
620b2861e3 | ||
![]() |
66b2867ba2 | ||
![]() |
a659dd821c | ||
![]() |
c9ea6ee6aa | ||
![]() |
76e4f6031d | ||
![]() |
02c6cab744 | ||
![]() |
d98384e582 | ||
![]() |
3f7d35bfdc | ||
![]() |
7c514c3669 | ||
![]() |
38ea17b426 | ||
![]() |
c9a78f154b | ||
![]() |
8f8e74d670 | ||
![]() |
f4f23de32b | ||
![]() |
bbe4e85768 | ||
![]() |
104c170ade | ||
![]() |
fd95560512 | ||
![]() |
d6ee2dbe12 | ||
![]() |
8245c7eda9 | ||
![]() |
306cdcd800 | ||
![]() |
b9970cbdac | ||
![]() |
a351e7a509 | ||
![]() |
08fe6ab791 | ||
![]() |
3c331e5a9b | ||
![]() |
51bc1d0328 | ||
![]() |
6c98945fc3 | ||
![]() |
0fa815f2b8 | ||
![]() |
c38405ef83 | ||
![]() |
8dfdee6fce | ||
![]() |
460787196a | ||
![]() |
6894a37ceb | ||
![]() |
44b798c07e | ||
![]() |
e8d99b9975 | ||
![]() |
786af9f6a9 | ||
![]() |
b72bf55555 | ||
![]() |
4d778dd64d | ||
![]() |
2ed6583041 | ||
![]() |
e8838ebebe | ||
![]() |
3ac439b345 | ||
![]() |
20c32316eb | ||
![]() |
3ffec79a17 | ||
![]() |
b96e194812 | ||
![]() |
c8254dbd0e | ||
![]() |
9df95bd936 | ||
![]() |
4f7b59aca4 | ||
![]() |
35e5b87188 | ||
![]() |
5b4ae61cdd | ||
![]() |
2a3f1d68f5 | ||
![]() |
672f4d1668 | ||
![]() |
2a926f6546 | ||
![]() |
452ca7a672 | ||
![]() |
df6271a0f3 | ||
![]() |
31357aa7e2 | ||
![]() |
3e7322e395 | ||
![]() |
fbe8cce1b8 | ||
![]() |
d36296c654 | ||
![]() |
dc800f0814 | ||
![]() |
59bf118a5a | ||
![]() |
0727c80347 | ||
![]() |
c0f229ec23 | ||
![]() |
cf02553ea7 | ||
![]() |
3dbea91a63 | ||
![]() |
95004aab7e | ||
![]() |
b3020d7296 | ||
![]() |
672d25e5ac | ||
![]() |
92842c8b04 | ||
![]() |
ff4e2f4192 | ||
![]() |
64a57ad3e3 | ||
![]() |
9e88e5734e | ||
![]() |
1b0cdab3e4 | ||
![]() |
b7296db406 | ||
![]() |
20958a979f | ||
![]() |
bdac876dd4 | ||
![]() |
46b75747ef | ||
![]() |
f454d17482 | ||
![]() |
8bffd28b4c | ||
![]() |
e7ef6ae8b7 | ||
![]() |
26aace6073 | ||
![]() |
e42cd9c12f | ||
![]() |
e61ac10656 | ||
![]() |
71d367af30 | ||
![]() |
fb0d3b07ea | ||
![]() |
cf0a0a0698 | ||
![]() |
44b69666da | ||
![]() |
f8a4a020e8 | ||
![]() |
53dba5f49d | ||
![]() |
30b51bb810 | ||
![]() |
bd2de16b4e | ||
![]() |
a74e5da268 | ||
![]() |
4d78878c02 | ||
![]() |
b7a0b823c6 | ||
![]() |
0173d722c6 | ||
![]() |
30e296968b | ||
![]() |
4e15be182e | ||
![]() |
4d5a759955 | ||
![]() |
e75f65080e | ||
![]() |
5d76707ede | ||
![]() |
48caffb802 | ||
![]() |
eaf5ff9de0 | ||
![]() |
86ab682e5a | ||
![]() |
db62c26eda | ||
![]() |
71f106be20 | ||
![]() |
d0b4c39acd | ||
![]() |
2a88a776bf | ||
![]() |
b77c0b78cc | ||
![]() |
f9dd67b59b | ||
![]() |
cc53da85fb | ||
![]() |
fdf579bcd5 | ||
![]() |
d73fb92ddf | ||
![]() |
fc8c92514f | ||
![]() |
7c4acb3b22 | ||
![]() |
2cd3fb8fea | ||
![]() |
ff9208f107 | ||
![]() |
afa506c0c8 | ||
![]() |
33ddce2cea | ||
![]() |
b927fc9b06 | ||
![]() |
e5c220519e | ||
![]() |
92c0c5eeab | ||
![]() |
00ec7e143c | ||
![]() |
fe51286586 | ||
![]() |
3b68399cc9 | ||
![]() |
7fd9ac0952 | ||
![]() |
5cdb7f7b05 | ||
![]() |
ebc886032f | ||
![]() |
333a51aeaa | ||
![]() |
3c8a00bc42 | ||
![]() |
1446692f02 | ||
![]() |
15c1c0fb5e | ||
![]() |
7cf7d545a6 | ||
![]() |
97e88af0c5 | ||
![]() |
28786c943a | ||
![]() |
ec84c71eae | ||
![]() |
3345727c94 | ||
![]() |
17cb317429 | ||
![]() |
159e6ea480 | ||
![]() |
266677bb88 | ||
![]() |
f27ca843e1 | ||
![]() |
1bb37e4b98 | ||
![]() |
7d412693c8 | ||
![]() |
d2985c5b2e | ||
![]() |
43425cf103 | ||
![]() |
9458549fef | ||
![]() |
3e38862837 | ||
![]() |
676a149497 | ||
![]() |
2b092f40fa | ||
![]() |
476cb7e7dc | ||
![]() |
75f12bd0eb | ||
![]() |
3a1e499d9d | ||
![]() |
de6ee8b161 | ||
![]() |
d77d9d5f31 | ||
![]() |
4d8b566a87 | ||
![]() |
3c7dcac41d | ||
![]() |
038732bd92 | ||
![]() |
f1b25fed65 | ||
![]() |
b0df0a26a1 | ||
![]() |
7ed1ac9c9b | ||
![]() |
e56d5318e4 | ||
![]() |
ccf6cc708a | ||
![]() |
016a4c3778 | ||
![]() |
d04346c870 | ||
![]() |
664e87809e | ||
![]() |
55e220f0e8 | ||
![]() |
162de0ceaf | ||
![]() |
9e4a0513c6 | ||
![]() |
08be5f732e |
259
.github/workflows/build_and_test.yml
vendored
259
.github/workflows/build_and_test.yml
vendored
@ -2,10 +2,10 @@ name: build and test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ main, 'pr/**' ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
workflow_dispatch:
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
@ -16,6 +16,9 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Install mimetype
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get install libfile-mimeinfo-perl
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
@ -31,9 +34,6 @@ jobs:
|
||||
crate: mdbook-linkcheck
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Install mimetype
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get install libfile-mimeinfo-perl
|
||||
- name: Check for binary blobs
|
||||
if: runner.os == 'Linux'
|
||||
run: ./scripts/check_for_blobs.sh
|
||||
@ -49,6 +49,8 @@ jobs:
|
||||
run: cargo test
|
||||
- name: Test libafl no_std
|
||||
run: cd libafl && cargo test --no-default-features
|
||||
- name: Test libafl_bolts no_std no_alloc
|
||||
run: cd libafl_bolts && cargo test --no-default-features
|
||||
- name: Test libafl_targets no_std
|
||||
run: cd libafl_targets && cargo test --no-default-features
|
||||
|
||||
@ -61,18 +63,18 @@ jobs:
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: set mold linker as default linker
|
||||
uses: rui314/setup-mold@v1
|
||||
- name: Remove existing clang and LLVM
|
||||
run: sudo apt purge llvm* clang*
|
||||
- name: Install and cache deps
|
||||
uses: awalsh128/cache-apt-pkgs-action@v1.1.0
|
||||
with:
|
||||
packages: llvm llvm-dev clang ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev
|
||||
packages: llvm-15 llvm-15-dev clang-15 ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
|
||||
- name: get clang version
|
||||
run: command -v llvm-config && clang -v
|
||||
- name: Install cargo-hack
|
||||
run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
|
||||
run: command -v llvm-config-15 && clang-15 -v
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
|
||||
- name: Install ucd-generate
|
||||
run: cargo install -f ucd-generate
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
@ -82,6 +84,8 @@ jobs:
|
||||
run: cargo check --features=sancov_pcguard_edges
|
||||
- name: Format
|
||||
run: cargo fmt -- --check
|
||||
- name: Cleanup
|
||||
run: cargo clean
|
||||
- name: Run clang-format style check for C/C++ programs.
|
||||
run: clang-format-13 -n -Werror --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c' | grep -v 'QEMU-Nyx')
|
||||
- name: run shellcheck
|
||||
@ -91,23 +95,64 @@ jobs:
|
||||
|
||||
# ---- doc check ----
|
||||
- name: Build Docs
|
||||
run: cargo doc
|
||||
run: RUSTFLAGS="--cfg docsrs" cargo +nightly doc --all-features
|
||||
- name: Test Docs
|
||||
run: cargo +nightly test --doc --all-features
|
||||
|
||||
# ---- build and feature check ----
|
||||
run: RUSTFLAGS="--cfg docsrs" cargo +nightly test --doc --all-features
|
||||
# ---- build normal and examples ----
|
||||
- name: Run a normal build
|
||||
run: cargo build --verbose
|
||||
- name: Build examples
|
||||
run: cargo build --examples --verbose
|
||||
|
||||
# --- miri undefined behavior test --
|
||||
- name: Run miri tests
|
||||
run: RUST_BACKTRACE=1 MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test
|
||||
|
||||
# Clean up files to save up disk space
|
||||
- name: Cleanup
|
||||
run: cargo clean
|
||||
|
||||
# --- test embedding the libafl_libfuzzer_runtime library
|
||||
# Fix me plz
|
||||
# - name: Test Build libafl_libfuzzer with embed
|
||||
# run: cargo +nightly test --features=embed-runtime --manifest-path libafl_libfuzzer/Cargo.toml
|
||||
|
||||
ubuntu-check:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Remove Dotnet & Haskell
|
||||
run: rm -rf /usr/share/dotnet && rm -rf /opt/ghc
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: llvm-tools
|
||||
- name: Remove existing clang and LLVM
|
||||
run: sudo apt purge llvm* clang*
|
||||
- name: Install and cache deps
|
||||
uses: awalsh128/cache-apt-pkgs-action@v1.1.0
|
||||
with:
|
||||
packages: llvm-15 llvm-15-dev clang-15 ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
|
||||
- name: get clang version
|
||||
run: command -v llvm-config-15 && clang-15 -v
|
||||
- name: Install cargo-hack
|
||||
run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
|
||||
- name: Install ucd-generate
|
||||
run: cargo install -f ucd-generate
|
||||
- name: Add nightly
|
||||
run: rustup toolchain install nightly --allow-downgrade
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
# ---- build and feature check ----
|
||||
# cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs
|
||||
- name: Check each feature
|
||||
# Skipping `python` as it has to be built with the `maturin` tool
|
||||
# `agpl`, `nautilus` require nightly
|
||||
# `sancov_pcguard_edges` is tested seperately
|
||||
run: cargo hack check --each-feature --clean-per-run --exclude-features=prelude,agpl,nautilus,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode --no-dev-deps
|
||||
run: LLVM_CONFIG=llvm-config-15 cargo hack check --workspace --each-feature --clean-per-run --exclude-features=prelude,agpl,nautilus,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode,whole_archive --no-dev-deps --exclude libafl_libfuzzer
|
||||
- name: Check nightly features
|
||||
run: cargo +nightly check --features=agpl && cargo +nightly check --features=nautilus
|
||||
- name: Build examples
|
||||
run: cargo build --examples --verbose
|
||||
|
||||
ubuntu-concolic:
|
||||
runs-on: ubuntu-latest
|
||||
@ -130,45 +175,63 @@ jobs:
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: set mold linker as default linker
|
||||
uses: rui314/setup-mold@v1
|
||||
- name: Remove existing clang and LLVM
|
||||
run: sudo apt purge llvm* clang*
|
||||
- name: Install deps
|
||||
run: sudo apt-get install -y llvm llvm-dev clang ninja-build python3-dev python3-pip python3-venv
|
||||
run: sudo apt-get install -y llvm-15 llvm-15-dev clang-15 ninja-build python3-dev python3-pip python3-venv libz3-dev
|
||||
- name: Install maturin
|
||||
run: python3 -m pip install maturin
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Run a maturin build
|
||||
run: cd ./bindings/pylibafl && maturin build
|
||||
run: export LLVM_CONFIG=llvm-config-15 && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh
|
||||
- name: Run python test
|
||||
run: . ./bindings/pylibafl/.env/bin/activate && cd ./fuzzers/baby_fuzzer && python3 baby_fuzzer.py 2>&1 | grep "Bye"
|
||||
|
||||
fuzzers:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: set mold linker as default linker
|
||||
if: runner.os == 'Linux' # mold only support linux until now
|
||||
uses: rui314/setup-mold@v1
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
# this might remove tools that are actually needed,
|
||||
# if set to "true" but frees about 6 GB
|
||||
tool-cache: false
|
||||
|
||||
# all of these default to true, but feel free to set to
|
||||
# "false" if necessary for your workflow
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: false
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
- name: Add no_std toolchain
|
||||
run: rustup toolchain install nightly-x86_64-unknown-linux-gnu ; rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
|
||||
- name: Install python
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install --force-bottle --overwrite python@3.11
|
||||
- name: Add wasm target
|
||||
run: rustup target add wasm32-unknown-unknown
|
||||
- name: Install ucd-generate
|
||||
run: cargo install -f ucd-generate
|
||||
- name: Remove obsolete llvm (Linux)
|
||||
run: sudo apt purge llvm* clang*
|
||||
- uses: lyricwulf/abc@v1
|
||||
with:
|
||||
# todo: remove afl++-clang when nyx support samcov_pcguard
|
||||
linux: llvm llvm-dev clang nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgtk-3-dev afl++-clang pax-utils
|
||||
# update bash for macos to support `declare -A` command`
|
||||
macos: llvm libpng nasm coreutils z3 bash
|
||||
with:
|
||||
linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev
|
||||
- name: Set clang version
|
||||
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
|
||||
- name: Set clang++ version
|
||||
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
|
||||
- name: pip install
|
||||
run: python3 -m pip install msgpack jinja2
|
||||
run: python3 -m pip install msgpack jinja2 find_libpython
|
||||
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
|
||||
- name: enable mult-thread for `make`
|
||||
run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)"
|
||||
@ -176,16 +239,105 @@ jobs:
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: cargo-make
|
||||
- name: install wasm-pack
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: wasm-pack
|
||||
- name: install chrome
|
||||
uses: browser-actions/setup-chrome@v1
|
||||
with:
|
||||
chrome-version: stable
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true # recursively checkout submodules
|
||||
fetch-depth: 0 # to diff with origin/main
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Symlink Headers
|
||||
if: runner.os == 'Linux'
|
||||
# We can't install gcc-multilib which would usually do this for us due to collisions with other packages
|
||||
run: sudo ln -s /usr/include/asm-generic /usr/include/asm
|
||||
- name: Build and run example fuzzers (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: ./scripts/test_all_fuzzers.sh
|
||||
- name: Build and run example fuzzers (macOS)
|
||||
if: runner.os == 'macOS' # use bash v4
|
||||
run: /usr/local/bin/bash ./scripts/test_all_fuzzers.sh
|
||||
run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh
|
||||
|
||||
qemu_fuzzers:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
if: runner.os == 'Linux'
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
# this might remove tools that are actually needed,
|
||||
# if set to "true" but frees about 6 GB
|
||||
tool-cache: false
|
||||
|
||||
# all of these default to true, but feel free to set to
|
||||
# "false" if necessary for your workflow
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: false
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
- name: Add no_std toolchain
|
||||
run: rustup toolchain install nightly-x86_64-unknown-linux-gnu ; rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
|
||||
- name: Add wasm target
|
||||
run: rustup target add wasm32-unknown-unknown
|
||||
- name: Install ucd-generate
|
||||
run: cargo install -f ucd-generate
|
||||
- name: Remove obsolete llvm (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt purge llvm* clang*
|
||||
- uses: lyricwulf/abc@v1
|
||||
with:
|
||||
linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev
|
||||
# update bash for macos to support `declare -A` command`
|
||||
macos: llvm@15 libpng nasm coreutils z3 bash wget
|
||||
- name: Set clang version
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
|
||||
- name: Set clang++ version
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
|
||||
- name: pip install
|
||||
run: python3 -m pip install msgpack jinja2 find_libpython
|
||||
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
|
||||
- name: enable mult-thread for `make`
|
||||
run: export MAKEFLAGS="-j$(expr $(nproc) \+ 1)"
|
||||
- name: install cargo-make
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: cargo-make
|
||||
- name: install wasm-pack
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: wasm-pack
|
||||
- name: install chrome
|
||||
uses: browser-actions/setup-chrome@v1
|
||||
with:
|
||||
chrome-version: stable
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true # recursively checkout submodules
|
||||
fetch-depth: 0 # to diff with origin/main
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Symlink Headers
|
||||
if: runner.os == 'Linux'
|
||||
# We can't install gcc-multilib which would usually do this for us due to collisions with other packages
|
||||
run: sudo ln -s /usr/include/asm-generic /usr/include/asm
|
||||
- name: Build and run example fuzzers (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh
|
||||
|
||||
|
||||
nostd-build:
|
||||
runs-on: ubuntu-latest
|
||||
@ -208,6 +360,8 @@ jobs:
|
||||
run: cd ./libafl && cargo test --no-default-features
|
||||
- name: libafl armv6m-none-eabi (32 bit no_std) clippy
|
||||
run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
|
||||
- name: Build no_std no_alloc bolts
|
||||
run: cd ./libafl_bolts && cargo +nightly build -Zbuild-std=core --target aarch64-unknown-none --no-default-features -v --release && cd ../
|
||||
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
@ -238,10 +392,16 @@ jobs:
|
||||
- name: install cargo-make
|
||||
run: cargo install --force cargo-make
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: install cxx bridge
|
||||
run: cargo install cxxbridge-cmd
|
||||
- name: Build fuzzers/libfuzzer_stb_image
|
||||
run: cd fuzzers/libfuzzer_stb_image && cargo build --release
|
||||
- name: Build fuzzers/frida_libpng
|
||||
run: cd fuzzers/frida_libpng/ && cargo make test
|
||||
- name: Build fuzzers/frida_gdiplus
|
||||
run: cd fuzzers/frida_gdiplus/ && cargo make test
|
||||
- name: Build fuzzers/tinyinst_simple
|
||||
run: cd fuzzers/tinyinst_simple/ && cargo make test
|
||||
|
||||
macos:
|
||||
runs-on: macOS-latest
|
||||
@ -252,8 +412,12 @@ jobs:
|
||||
toolchain: stable
|
||||
- name: Add nightly rustfmt and clippy
|
||||
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade
|
||||
- name: Install ucd-generate
|
||||
run: cargo install -f ucd-generate
|
||||
- name: Install deps
|
||||
run: brew install z3 gtk+3
|
||||
- name: Install cxxbridge
|
||||
run: cargo install cxxbridge-cmd
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: MacOS Build
|
||||
@ -274,7 +438,7 @@ jobs:
|
||||
toolchain: stable
|
||||
- uses: nttld/setup-ndk@v1
|
||||
with:
|
||||
ndk-version: r21e
|
||||
ndk-version: r25b
|
||||
- name: install ios
|
||||
run: rustup target add aarch64-apple-ios
|
||||
- name: install android
|
||||
@ -284,7 +448,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Build iOS
|
||||
run: cargo build --target aarch64-apple-ios
|
||||
run: cargo build --target aarch64-apple-ios && cd libafl_frida && cargo build --target aarch64-apple-ios && cd ..
|
||||
- name: Build Android
|
||||
run: cargo ndk -t arm64-v8a build --release
|
||||
#run: cargo build --target aarch64-linux-android
|
||||
@ -298,28 +462,29 @@ jobs:
|
||||
# run: C:\Rust\.cargo\bin\cargo.exe test --verbose
|
||||
|
||||
freebsd:
|
||||
runs-on: macos-12
|
||||
runs-on: ubuntu-22.04
|
||||
name: Simple build in FreeBSD
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v0
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
sync: rsync
|
||||
copyback: false
|
||||
mem: 2048
|
||||
release: 13.1
|
||||
release: 13.2
|
||||
prepare: |
|
||||
pkg install -y curl bash sudo llvm14
|
||||
pkg install -y curl bash sudo llvm16
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
|
||||
run: |
|
||||
freebsd-version
|
||||
. "$HOME/.cargo/env"
|
||||
rustup toolchain install nightly
|
||||
export LLVM_CONFIG=/usr/local/bin/llvm-config14
|
||||
cargo install -f ucd-generate
|
||||
export LLVM_CONFIG=/usr/local/bin/llvm-config16
|
||||
pwd
|
||||
ls -lah
|
||||
echo "local/bin"
|
||||
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -21,6 +21,8 @@ vendor
|
||||
*.obj
|
||||
|
||||
.cur_input
|
||||
.cur_input_*
|
||||
cur_input
|
||||
.venv
|
||||
|
||||
crashes
|
||||
@ -32,6 +34,8 @@ perf.data.old
|
||||
.vscode
|
||||
test.dict
|
||||
|
||||
.idea/
|
||||
|
||||
# Ignore all built fuzzers
|
||||
fuzzer_*
|
||||
AFLplusplus
|
||||
@ -46,6 +50,7 @@ a
|
||||
forkserver_test
|
||||
__pycache__
|
||||
*.lafl_lock
|
||||
*.metadata
|
||||
|
||||
*atomic_file_testfile*
|
||||
**/libxml2
|
||||
@ -53,4 +58,11 @@ __pycache__
|
||||
**/libxml2-*.tar.gz
|
||||
|
||||
libafl_nyx/QEMU-Nyx
|
||||
libafl_nyx/packer
|
||||
libafl_nyx/packer
|
||||
|
||||
.z3-trace
|
||||
|
||||
# No gdb history
|
||||
.gdb_history
|
||||
# No llvm IR
|
||||
*.ll
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "libafl_concolic/symcc_runtime/symcc"]
|
||||
path = libafl_concolic/symcc_runtime/symcc
|
||||
url = https://github.com/AFLplusplus/symcc.git
|
34
Cargo.toml
34
Cargo.toml
@ -1,42 +1,48 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"libafl",
|
||||
"libafl_derive",
|
||||
"libafl_bolts",
|
||||
"libafl_cc",
|
||||
"libafl_targets",
|
||||
"libafl_frida",
|
||||
"libafl_qemu",
|
||||
"libafl_tinyinst",
|
||||
"libafl_sugar",
|
||||
"libafl_nyx",
|
||||
"libafl_concolic/symcc_runtime",
|
||||
"libafl_concolic/symcc_libafl",
|
||||
"libafl_concolic/test/dump_constraints",
|
||||
"libafl_concolic/test/runtime_test",
|
||||
"libafl_derive",
|
||||
"libafl_frida",
|
||||
"libafl_libfuzzer",
|
||||
"libafl_nyx",
|
||||
"libafl_qemu",
|
||||
"libafl_sugar",
|
||||
"libafl_targets",
|
||||
"libafl_tinyinst",
|
||||
"utils/build_and_test_fuzzers",
|
||||
"utils/deexit",
|
||||
"utils/gramatron/construct_automata",
|
||||
"utils/libafl_benches",
|
||||
"utils/gramatron/construct_automata",
|
||||
]
|
||||
default-members = [
|
||||
"libafl",
|
||||
"libafl_derive",
|
||||
"libafl_bolts",
|
||||
"libafl_cc",
|
||||
"libafl_derive",
|
||||
"libafl_targets",
|
||||
]
|
||||
exclude = [
|
||||
"fuzzers",
|
||||
"bindings",
|
||||
"scripts",
|
||||
"fuzzers",
|
||||
"libafl_qemu/libafl_qemu_build",
|
||||
"libafl_qemu/libafl_qemu_sys"
|
||||
"libafl_qemu/libafl_qemu_sys",
|
||||
"utils/noaslr",
|
||||
"utils/gdb_qemu",
|
||||
"scripts",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
|
23
Dockerfile
23
Dockerfile
@ -1,5 +1,5 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
FROM rust:bullseye AS libafl
|
||||
FROM rust:1.73.0 AS libafl
|
||||
LABEL "maintainer"="afl++ team <afl@aflplus.plus>"
|
||||
LABEL "about"="LibAFL Docker image"
|
||||
|
||||
@ -17,9 +17,11 @@ RUN sh -c 'echo set encoding=utf-8 > /root/.vimrc' \
|
||||
echo "[build]\nrustc-wrapper = \"${RUSTC_WRAPPER}\"" >> ~/.cargo/config
|
||||
|
||||
RUN rustup component add rustfmt clippy
|
||||
RUN rustup default nightly
|
||||
|
||||
# Install clang 11, common build tools
|
||||
RUN apt update && apt install -y build-essential gdb git wget clang clang-tools libc++-11-dev libc++abi-11-dev llvm
|
||||
RUN apt update && apt install -y build-essential gdb git wget python3-venv ninja-build lsb-release software-properties-common gnupg
|
||||
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 15
|
||||
|
||||
# Copy a dummy.rs and Cargo.toml first, so that dependencies are cached
|
||||
WORKDIR /libafl
|
||||
@ -28,10 +30,13 @@ COPY Cargo.toml README.md ./
|
||||
COPY libafl_derive/Cargo.toml libafl_derive/Cargo.toml
|
||||
COPY scripts/dummy.rs libafl_derive/src/lib.rs
|
||||
|
||||
COPY libafl/Cargo.toml libafl/build.rs libafl/
|
||||
COPY libafl/examples libafl/examples
|
||||
COPY libafl/Cargo.toml libafl/build.rs libafl/README.md libafl/
|
||||
COPY scripts/dummy.rs libafl/src/lib.rs
|
||||
|
||||
COPY libafl_bolts/Cargo.toml libafl_bolts/build.rs libafl_bolts/README.md libafl_bolts/
|
||||
COPY libafl_bolts/examples libafl_bolts/examples
|
||||
COPY scripts/dummy.rs libafl_bolts/src/lib.rs
|
||||
|
||||
COPY libafl_frida/Cargo.toml libafl_frida/build.rs libafl_frida/
|
||||
COPY scripts/dummy.rs libafl_frida/src/lib.rs
|
||||
COPY libafl_frida/src/gettls.c libafl_frida/src/gettls.c
|
||||
@ -75,6 +80,10 @@ COPY scripts/dummy.rs libafl_nyx/src/lib.rs
|
||||
COPY libafl_tinyinst/Cargo.toml libafl_tinyinst/
|
||||
COPY scripts/dummy.rs libafl_tinyinst/src/lib.rs
|
||||
|
||||
# avoid pulling in the runtime, as this is quite an expensive build, until later
|
||||
COPY libafl_libfuzzer/Cargo.toml libafl_libfuzzer/
|
||||
COPY scripts/dummy.rs libafl_libfuzzer/src/lib.rs
|
||||
|
||||
COPY utils utils
|
||||
|
||||
RUN cargo build && cargo build --release
|
||||
@ -95,6 +104,8 @@ COPY libafl_cc/src libafl_cc/src
|
||||
RUN touch libafl_cc/src/lib.rs
|
||||
COPY libafl_derive/src libafl_derive/src
|
||||
RUN touch libafl_derive/src/lib.rs
|
||||
COPY libafl_bolts/src libafl_bolts/src
|
||||
RUN touch libafl_bolts/src/lib.rs
|
||||
COPY libafl/src libafl/src
|
||||
RUN touch libafl/src/lib.rs
|
||||
COPY libafl_targets/src libafl_targets/src
|
||||
@ -112,6 +123,10 @@ COPY libafl_concolic/symcc_runtime libafl_concolic/symcc_runtime
|
||||
COPY libafl_concolic/test libafl_concolic/test
|
||||
COPY libafl_nyx/src libafl_nyx/src
|
||||
RUN touch libafl_nyx/src/lib.rs
|
||||
COPY libafl_libfuzzer/src libafl_libfuzzer/src
|
||||
COPY libafl_libfuzzer/libafl_libfuzzer_runtime libafl_libfuzzer/libafl_libfuzzer_runtime
|
||||
COPY libafl_libfuzzer/build.rs libafl_libfuzzer/build.rs
|
||||
RUN touch libafl_libfuzzer/src/lib.rs
|
||||
RUN cargo build && cargo build --release
|
||||
|
||||
# Copy fuzzers over
|
||||
|
25
README.md
25
README.md
@ -1,6 +1,6 @@
|
||||
# LibAFL, the fuzzer library.
|
||||
|
||||
<img align="right" src="https://github.com/AFLplusplus/Website/raw/master/static/logo_256x256.png" alt="AFL++ Logo">
|
||||
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/main/static/libafl_logo.svg" alt="LibAFL logo" width="250" heigh="250">
|
||||
|
||||
Advanced Fuzzing Library - Slot your own fuzzers together and extend their features using Rust.
|
||||
|
||||
@ -10,6 +10,7 @@ LibAFL is written and maintained by
|
||||
* [Dominik Maier](https://twitter.com/domenuk) <dominik@aflplus.plus>
|
||||
* [s1341](https://twitter.com/srubenst1341) <github@shmarya.net>
|
||||
* [Dongjia Zhang](https://github.com/tokatoka) <toka@aflplus.plus>
|
||||
* [Addison Crump](https://github.com/addisoncrump) <me@addisoncrump.info>
|
||||
|
||||
## Why LibAFL?
|
||||
|
||||
@ -33,7 +34,7 @@ LibAFL offers integrations with popular instrumentation frameworks. At the momen
|
||||
|
||||
+ SanitizerCoverage, in [libafl_targets](./libafl_targets)
|
||||
+ Frida, in [libafl_frida](./libafl_frida)
|
||||
+ QEMU user-mode, in [libafl_qemu](./libafl_qemu)
|
||||
+ QEMU user-mode and system mode, including hooks for emulation, in [libafl_qemu](./libafl_qemu)
|
||||
+ TinyInst, in [libafl_tinyinst](./libafl_tinyinst) by [elbiazo](https://github.com/elbiazo)
|
||||
|
||||
## Getting started
|
||||
@ -44,36 +45,36 @@ We highly recommend *not* to use e.g. your Linux distribition package as this is
|
||||
Rust directly, instructions can be found [here](https://www.rust-lang.org/tools/install).
|
||||
|
||||
- LLVM tools
|
||||
The LLVM tools are needed (newer than LLVM 11.0.0 but older than LLVM 15.0.0)
|
||||
The LLVM tools (including clang, clang++) are needed (newer than LLVM 11.0.0 up to LLVM 17.0.0)
|
||||
|
||||
- Cargo-make
|
||||
We use cargo-make to build the fuzzers in `fuzzers/` directory. You can install it with
|
||||
|
||||
```
|
||||
```sh
|
||||
cargo install cargo-make
|
||||
```
|
||||
|
||||
2. Clone the LibAFL repository with
|
||||
|
||||
```
|
||||
```sh
|
||||
git clone https://github.com/AFLplusplus/LibAFL
|
||||
```
|
||||
|
||||
3. Build the library using
|
||||
|
||||
```
|
||||
```sh
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
4. Build the API documentation with
|
||||
|
||||
```
|
||||
```sh
|
||||
cargo doc
|
||||
```
|
||||
|
||||
5. Browse the LibAFL book (WIP!) with (requires [mdbook](https://github.com/rust-lang/mdBook))
|
||||
5. Browse the LibAFL book (WIP!) with (requires [mdbook](https://rust-lang.github.io/mdBook/index.html))
|
||||
|
||||
```
|
||||
```sh
|
||||
cd docs && mdbook serve
|
||||
```
|
||||
|
||||
@ -81,9 +82,11 @@ We collect all example fuzzers in [`./fuzzers`](./fuzzers/).
|
||||
Be sure to read their documentation (and source), this is *the natural way to get started!*
|
||||
|
||||
You can run each example fuzzer with
|
||||
```
|
||||
|
||||
```sh
|
||||
cargo make run
|
||||
```
|
||||
|
||||
as long as the fuzzer directory has `Makefile.toml` file.
|
||||
|
||||
The best-tested fuzzer is [`./fuzzers/libfuzzer_libpng`](./fuzzers/libfuzzer_libpng), a multicore libfuzzer-like fuzzer using LibAFL for a libpng harness.
|
||||
@ -106,6 +109,8 @@ The best-tested fuzzer is [`./fuzzers/libfuzzer_libpng`](./fuzzers/libfuzzer_lib
|
||||
|
||||
+ Blogpost on binary-only fuzzing lib libaf_qemu, [Hacking TMNF - Fuzzing the game server](https://blog.bricked.tech/posts/tmnf/part1/), by [RickdeJager](https://github.com/RickdeJager).
|
||||
|
||||
+ [A LibAFL Introductory Workshop](https://www.atredis.com/blog/2023/12/4/a-libafl-introductory-workshop), by [Jordan Whitehead](https://github.com/jordan9001)
|
||||
|
||||
## Contributing
|
||||
|
||||
For bugs, feel free to open issues or contact us directly. Thank you for your support. <3
|
||||
|
17
TROPHIES.md
Normal file
17
TROPHIES.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Bugs found by `libafl` and `libafl_libfuzzer`
|
||||
|
||||
* pdf-rs
|
||||
* <https://github.com/pdf-rs/pdf/issues/183>
|
||||
* <https://github.com/pdf-rs/pdf/issues/184>
|
||||
* <https://github.com/pdf-rs/pdf/issues/185>
|
||||
* <https://github.com/pdf-rs/pdf/issues/186>
|
||||
* <https://github.com/pdf-rs/pdf/issues/187>
|
||||
* <https://github.com/pdf-rs/pdf/issues/189>
|
||||
* nu-shell
|
||||
* https://github.com/nushell/nushell/issues/10365
|
||||
* https://github.com/nushell/nushell/issues/9417
|
||||
* exrs
|
||||
* https://github.com/johannesvollmer/exrs/pull/221
|
||||
* pcre2
|
||||
* https://github.com/PCRE2Project/pcre2/issues/275
|
||||
|
1
bindings/pylibafl/.gitignore
vendored
Normal file
1
bindings/pylibafl/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
dist/
|
@ -1,13 +1,15 @@
|
||||
[package]
|
||||
name = "pylibafl"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { version = "0.17", features = ["extension-module"] }
|
||||
libafl_qemu = { path = "../../libafl_qemu", version = "0.8.2", features = ["python"] }
|
||||
libafl_sugar = { path = "../../libafl_sugar", version = "0.8.2", features = ["python"] }
|
||||
libafl = { path = "../../libafl", version = "0.8.2", features = ["python"] }
|
||||
pyo3 = { version = "0.18.3", features = ["extension-module"] }
|
||||
pyo3-log = "0.8.1"
|
||||
libafl_qemu = { path = "../../libafl_qemu", version = "0.11.2", features = ["python"] }
|
||||
libafl_sugar = { path = "../../libafl_sugar", version = "0.11.2", features = ["python"] }
|
||||
libafl = { path = "../../libafl", version = "0.11.2", features = ["python"] }
|
||||
libafl_bolts = { path = "../../libafl_bolts", version = "0.11.2", features = ["python"] }
|
||||
|
||||
[build-dependencies]
|
||||
pyo3-build-config = { version = "0.17" }
|
||||
|
26
bindings/pylibafl/pyproject.toml
Normal file
26
bindings/pylibafl/pyproject.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[build-system]
|
||||
requires = ["maturin[patchelf]>=0.14.10,<0.15"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[project]
|
||||
name = "PyLibAFL"
|
||||
version = "0.10.1"
|
||||
description = "Advanced Fuzzing Library for Python"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
license = {text = "Apache-2.0"}
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Rust",
|
||||
"Topic :: Security",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
repository = "https://github.com/AFLplusplus/LibAFL.git"
|
||||
|
||||
[tool.maturin]
|
||||
bindings = "pylibafl"
|
||||
manifest-path = "Cargo.toml"
|
||||
python-source = "python"
|
||||
all-features = true
|
@ -1,4 +1,5 @@
|
||||
use libafl;
|
||||
use libafl_bolts;
|
||||
#[cfg(target_os = "linux")]
|
||||
use libafl_qemu;
|
||||
use libafl_sugar;
|
||||
@ -26,7 +27,7 @@ class BaseFeedback:
|
||||
pass
|
||||
def is_interesting(self, state, mgr, input, observers, exit_kind) -> bool:
|
||||
return False
|
||||
def append_metadata(self, state, testcase):
|
||||
def append_metadata(self, state, observers, testcase):
|
||||
pass
|
||||
def discard_metadata(self, state, input):
|
||||
pass
|
||||
@ -84,23 +85,27 @@ def feedback_or_fast(a, b):
|
||||
#[pymodule]
|
||||
#[pyo3(name = "pylibafl")]
|
||||
pub fn python_module(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
pyo3_log::init();
|
||||
|
||||
let modules = py.import("sys")?.getattr("modules")?;
|
||||
|
||||
let sugar_module = PyModule::new(py, "sugar")?;
|
||||
libafl_sugar::python_module(py, sugar_module)?;
|
||||
m.add_submodule(sugar_module)?;
|
||||
|
||||
modules.set_item("pylibafl.sugar", sugar_module)?;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let qemu_module = PyModule::new(py, "qemu")?;
|
||||
#[cfg(target_os = "linux")]
|
||||
libafl_qemu::python_module(py, qemu_module)?;
|
||||
#[cfg(target_os = "linux")]
|
||||
m.add_submodule(qemu_module)?;
|
||||
{
|
||||
let qemu_module = PyModule::new(py, "qemu")?;
|
||||
libafl_qemu::python_module(py, qemu_module)?;
|
||||
m.add_submodule(qemu_module)?;
|
||||
modules.set_item("pylibafl.qemu", qemu_module)?;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
modules.set_item("pylibafl.qemu", qemu_module)?;
|
||||
let bolts_module = PyModule::new(py, "libafl_bolts")?;
|
||||
libafl_bolts::pybind::python_module(py, bolts_module)?;
|
||||
m.add_submodule(bolts_module)?;
|
||||
modules.set_item("pylibafl.libafl_bolts", bolts_module)?;
|
||||
|
||||
let libafl_module = PyModule::new(py, "libafl")?;
|
||||
libafl::pybind::python_module(py, libafl_module)?;
|
||||
@ -114,7 +119,6 @@ pub fn python_module(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
}
|
||||
|
||||
m.add_submodule(libafl_module)?;
|
||||
|
||||
modules.set_item("pylibafl.libafl", libafl_module)?;
|
||||
|
||||
Ok(())
|
||||
|
@ -1,5 +1,8 @@
|
||||
from pylibafl.libafl import *
|
||||
import ctypes
|
||||
import platform
|
||||
|
||||
MAP_SIZE = 4096
|
||||
|
||||
|
||||
class FooObserver(BaseObserver):
|
||||
@ -33,11 +36,16 @@ class FooExecutor(BaseExecutor):
|
||||
return (self.h)(input)
|
||||
|
||||
|
||||
libc = ctypes.cdll.LoadLibrary("libc.so.6")
|
||||
if platform.system() == "Darwin":
|
||||
libc = ctypes.cdll.LoadLibrary("libc.dylib")
|
||||
else:
|
||||
libc = ctypes.cdll.LoadLibrary("libc.so.6")
|
||||
|
||||
area_ptr = libc.calloc(1, 4096)
|
||||
# Get a buffer to use for our map observer
|
||||
libc.calloc.restype = ctypes.c_void_p
|
||||
area_ptr = libc.calloc(1, MAP_SIZE)
|
||||
|
||||
observer = StdMapObserverI8("mymap", area_ptr, 4096)
|
||||
observer = StdMapObserverI8("mymap", area_ptr, MAP_SIZE)
|
||||
|
||||
m = observer.as_map_observer()
|
||||
|
||||
@ -69,7 +77,12 @@ mgr = SimpleEventManager(monitor.as_monitor())
|
||||
|
||||
|
||||
def harness(buf) -> ExitKind:
|
||||
"""
|
||||
The harness fn that the fuzzer will execute in a loop
|
||||
"""
|
||||
# print(buf)
|
||||
|
||||
# set the observer map byte from python
|
||||
m[0] = 1
|
||||
if len(buf) > 0 and buf[0] == ord("a"):
|
||||
m[1] = 1
|
||||
@ -91,4 +104,6 @@ stage_tuple_list = StagesTuple([stage.as_stage()])
|
||||
|
||||
fuzzer.add_input(state, executor.as_executor(), mgr.as_manager(), b"\0\0")
|
||||
|
||||
print("Starting to fuzz from python!")
|
||||
|
||||
fuzzer.fuzz_loop(executor.as_executor(), state, mgr.as_manager(), stage_tuple_list)
|
||||
|
11
bindings/pylibafl/test.sh
Executable file
11
bindings/pylibafl/test.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
timeout 10 python3 ./test.py
|
||||
export exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
# 124 = timeout happened. All good.
|
||||
exit 0
|
||||
else
|
||||
exit $exit_code
|
||||
fi
|
||||
|
1
docs/.gitignore
vendored
1
docs/.gitignore
vendored
@ -1 +1,2 @@
|
||||
book
|
||||
!listings/**/*
|
||||
|
9
docs/listings/baby_fuzzer/listing-01/Cargo.toml
Normal file
9
docs/listings/baby_fuzzer/listing-01/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_01"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
docs/listings/baby_fuzzer/listing-01/src/main.rs
Normal file
3
docs/listings/baby_fuzzer/listing-01/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
21
docs/listings/baby_fuzzer/listing-02/Cargo.toml
Normal file
21
docs/listings/baby_fuzzer/listing-02/Cargo.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_02"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
libafl_bolts = { path = "path/to/libafl_bolts/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
3
docs/listings/baby_fuzzer/listing-02/src/main.rs
Normal file
3
docs/listings/baby_fuzzer/listing-02/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
24
docs/listings/baby_fuzzer/listing-03/Cargo.toml
Normal file
24
docs/listings/baby_fuzzer/listing-03/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_03"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
libafl_bolts = { path = "path/to/libafl_bolts/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
panic = []
|
26
docs/listings/baby_fuzzer/listing-03/src/main.rs
Normal file
26
docs/listings/baby_fuzzer/listing-03/src/main.rs
Normal file
@ -0,0 +1,26 @@
|
||||
extern crate libafl;
|
||||
extern crate libafl_bolts;
|
||||
use libafl::{
|
||||
executors::ExitKind,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
};
|
||||
use libafl_bolts::AsSlice;
|
||||
|
||||
fn main() {
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
// To test the panic:
|
||||
let input = BytesInput::new(Vec::from("abc"));
|
||||
#[cfg(feature = "panic")]
|
||||
harness(&input);
|
||||
}
|
24
docs/listings/baby_fuzzer/listing-04/Cargo.toml
Normal file
24
docs/listings/baby_fuzzer/listing-04/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_04"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
libafl_bolts = { path = "path/to/libafl_bolts/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
panic = []
|
86
docs/listings/baby_fuzzer/listing-04/src/main.rs
Normal file
86
docs/listings/baby_fuzzer/listing-04/src/main.rs
Normal file
@ -0,0 +1,86 @@
|
||||
/* ANCHOR: use */
|
||||
extern crate libafl;
|
||||
extern crate libafl_bolts;
|
||||
|
||||
use libafl::{
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
fuzzer::StdFuzzer,
|
||||
generators::RandPrintablesGenerator,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
schedulers::QueueScheduler,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, AsSlice};
|
||||
use std::path::PathBuf;
|
||||
/* ANCHOR_END: use */
|
||||
|
||||
fn main() {
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
// To test the panic:
|
||||
let input = BytesInput::new(Vec::from("abc"));
|
||||
#[cfg(feature = "panic")]
|
||||
harness(&input);
|
||||
|
||||
/* ANCHOR: state */
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
&mut (),
|
||||
&mut (),
|
||||
)
|
||||
.unwrap();
|
||||
/* ANCHOR_END: state */
|
||||
|
||||
/* ANCHOR: event_manager */
|
||||
// The Monitor trait defines how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handles the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
/* ANCHOR_END: event_manager */
|
||||
|
||||
/* ANCHOR: scheduler_fuzzer */
|
||||
// A queue policy to get testcases from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, (), ());
|
||||
/* ANCHOR_END: scheduler_fuzzer */
|
||||
|
||||
/* ANCHOR: executor */
|
||||
// Create the executor for an in-process function
|
||||
let mut executor = InProcessExecutor::new(&mut harness, (), &mut fuzzer, &mut state, &mut mgr)
|
||||
.expect("Failed to create the Executor");
|
||||
/* ANCHOR_END: executor */
|
||||
|
||||
/* ANCHOR: generator */
|
||||
// Generator of printable bytearrays of max size 32
|
||||
let mut generator = RandPrintablesGenerator::new(32);
|
||||
|
||||
// Generate 8 initial inputs
|
||||
state
|
||||
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
|
||||
.expect("Failed to generate the initial corpus");
|
||||
/* ANCHOR_END: generator */
|
||||
}
|
23
docs/listings/baby_fuzzer/listing-05/Cargo.toml
Normal file
23
docs/listings/baby_fuzzer/listing-05/Cargo.toml
Normal file
@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_05"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
panic = []
|
116
docs/listings/baby_fuzzer/listing-05/src/main.rs
Normal file
116
docs/listings/baby_fuzzer/listing-05/src/main.rs
Normal file
@ -0,0 +1,116 @@
|
||||
/* ANCHOR: use */
|
||||
extern crate libafl;
|
||||
extern crate libafl_bolts;
|
||||
|
||||
use libafl::{
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
feedbacks::{CrashFeedback, MaxMapFeedback},
|
||||
fuzzer::StdFuzzer,
|
||||
generators::RandPrintablesGenerator,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
observers::StdMapObserver,
|
||||
schedulers::QueueScheduler,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
use std::path::PathBuf;
|
||||
/* ANCHOR_END: use */
|
||||
|
||||
/* ANCHOR: signals */
|
||||
// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
signals_set(0); // set SIGNALS[0]
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
signals_set(1); // set SIGNALS[1]
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
signals_set(2); // set SIGNALS[2]
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
/* ANCHOR_END: signals */
|
||||
// To test the panic:
|
||||
let input = BytesInput::new(Vec::from("abc"));
|
||||
#[cfg(feature = "panic")]
|
||||
harness(&input);
|
||||
|
||||
/* ANCHOR: observer */
|
||||
// Create an observation channel using the signals map
|
||||
let observer = unsafe { StdMapObserver::new("signals", &mut SIGNALS) };
|
||||
/* ANCHOR_END: observer */
|
||||
|
||||
/* ANCHOR: state_with_feedback_and_objective */
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
&mut feedback,
|
||||
&mut objective,
|
||||
)
|
||||
.unwrap();
|
||||
/* ANCHOR_END: state_with_feedback_and_objective */
|
||||
|
||||
// The Monitor trait defines how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handles the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
|
||||
// A queue policy to get testcasess from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
/* ANCHOR: state_with_feedback_and_objective */
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
|
||||
/* ANCHOR_END: state_with_feedback_and_objective */
|
||||
|
||||
/* ANCHOR: executor_with_observer */
|
||||
// Create the executor for an in-process function with just one observer
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
tuple_list!(observer),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor");
|
||||
/* ANCHOR_END: executor_with_observer */
|
||||
|
||||
// Generator of printable bytearrays of max size 32
|
||||
let mut generator = RandPrintablesGenerator::new(32);
|
||||
|
||||
// Generate 8 initial inputs
|
||||
state
|
||||
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
|
||||
.expect("Failed to generate the initial corpus");
|
||||
/* ANCHOR: signals */
|
||||
}
|
||||
/* ANCHOR_END: signals */
|
24
docs/listings/baby_fuzzer/listing-06/Cargo.toml
Normal file
24
docs/listings/baby_fuzzer/listing-06/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_listing_06"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
libafl_bolts = { path = "path/to/libafl_bolts/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
panic = []
|
116
docs/listings/baby_fuzzer/listing-06/src/main.rs
Normal file
116
docs/listings/baby_fuzzer/listing-06/src/main.rs
Normal file
@ -0,0 +1,116 @@
|
||||
/* ANCHOR: use */
|
||||
extern crate libafl;
|
||||
extern crate libafl_bolts;
|
||||
|
||||
use libafl::{
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
feedbacks::{CrashFeedback, MaxMapFeedback},
|
||||
fuzzer::{Fuzzer, StdFuzzer},
|
||||
generators::RandPrintablesGenerator,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
|
||||
observers::StdMapObserver,
|
||||
schedulers::QueueScheduler,
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
use std::path::PathBuf;
|
||||
/* ANCHOR_END: use */
|
||||
|
||||
// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
signals_set(0); // set SIGNALS[0]
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
signals_set(1); // set SIGNALS[1]
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
signals_set(2); // set SIGNALS[2]
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
// To test the panic:
|
||||
let input = BytesInput::new(Vec::from("abc"));
|
||||
#[cfg(feature = "panic")]
|
||||
harness(&input);
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = unsafe { StdMapObserver::new("signals", &mut SIGNALS) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
&mut feedback,
|
||||
&mut objective,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait defines how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handles the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
|
||||
// A queue policy to get testcasess from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
|
||||
|
||||
// Create the executor for an in-process function with just one observer
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
tuple_list!(observer),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor");
|
||||
|
||||
// Generator of printable bytearrays of max size 32
|
||||
let mut generator = RandPrintablesGenerator::new(32);
|
||||
|
||||
// Generate 8 initial inputs
|
||||
state
|
||||
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
|
||||
.expect("Failed to generate the initial corpus");
|
||||
|
||||
/* ANCHOR: mutational_stage */
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::new(havoc_mutations());
|
||||
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
|
||||
|
||||
fuzzer
|
||||
.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)
|
||||
.expect("Error in the fuzzing loop");
|
||||
/* ANCHOR_END: mutational_stage */
|
||||
}
|
@ -25,6 +25,7 @@
|
||||
- [Architecture](./design/architecture.md)
|
||||
- [Metadata](./design/metadata.md)
|
||||
- [Migrating from LibAFL <0.9 to 0.9](./design/migration-0.9.md)
|
||||
- [Migrating from LibAFL <0.11 to 0.11](./design/migration-0.11.md)
|
||||
|
||||
- [Message Passing](./message_passing/message_passing.md)
|
||||
- [Spawning Instances](./message_passing/spawn_instances.md)
|
||||
|
@ -1,7 +1,8 @@
|
||||
# Concolic Tracing and Hybrid Fuzzing
|
||||
|
||||
LibAFL has support for concolic tracing based on the [SymCC](https://github.com/eurecom-s3/symcc) instrumenting compiler.
|
||||
|
||||
For those uninitiated, the following attempts to describe concolic tracing from the ground up using an example.
|
||||
For those uninitiated, the following text attempts to describe concolic tracing from the ground up using an example.
|
||||
Then, we'll go through the relationship of SymCC and LibAFL concolic tracing.
|
||||
Finally, we'll walk through building a basic hybrid fuzzer using LibAFL.
|
||||
|
||||
@ -92,18 +93,18 @@ In hybrid fuzzing, we combine this tracing + solving approach with more traditio
|
||||
The concolic tracing support in LibAFL is implemented using SymCC.
|
||||
SymCC is a compiler plugin for clang that can be used as a drop-in replacement for a normal C or C++ compiler.
|
||||
SymCC will instrument the compiled code with callbacks into a runtime that can be supplied by the user.
|
||||
These callbacks allow the runtime to construct a trace that similar to the previous example.
|
||||
These callbacks allow the runtime to construct a trace that is similar to the previous example.
|
||||
|
||||
### SymCC and its Runtimes
|
||||
|
||||
SymCC ships with 2 runtimes:
|
||||
SymCC ships with 2 runtimes:
|
||||
|
||||
* a 'simple' runtime that attempts to solve any branches it comes across using [Z3](https://github.com/Z3Prover/z3/wiki) and
|
||||
* a [QSym](https://github.com/sslab-gatech/qsym)-based runtime, which does a bit more filtering on the expressions and also solves using Z3.
|
||||
* A 'simple' runtime that attempts to negate and analytically solve any branch conditions it comes across using [Z3](https://github.com/Z3Prover/z3/wiki) and
|
||||
* A [QSym](https://github.com/sslab-gatech/qsym)-based runtime, which does a bit more filtering on the expressions and also solves them using Z3.
|
||||
|
||||
The integration with LibAFL, however, requires you to **BYORT** (_bring your own runtime_) using the [`symcc_runtime`](https://docs.rs/symcc_runtime/0.1/symcc_runtime) crate.
|
||||
This crate allows you to easily build a custom runtime out of the built-in building blocks or create entirely new runtimes with full flexibility.
|
||||
Checkout out the `symcc_runtime` docs for more information on how to build your own runtime.
|
||||
Check out the `symcc_runtime` docs for more information on how to build your own runtime.
|
||||
|
||||
### SymQEMU
|
||||
|
||||
@ -123,7 +124,7 @@ There are three main steps involved with building a hybrid fuzzer using LibAFL:
|
||||
3. building the fuzzer.
|
||||
|
||||
Note that the order of these steps is important.
|
||||
For example, we need to have runtime ready before we can do instrumentation with SymCC.
|
||||
For example, we need to have a runtime ready before we can do instrumentation with SymCC.
|
||||
|
||||
### Building a Runtime
|
||||
|
||||
@ -134,10 +135,12 @@ Check out the [example hybrid fuzzer's runtime](https://github.com/AFLplusplus/L
|
||||
### Instrumentation
|
||||
|
||||
There are two main instrumentation methods to make use of concolic tracing in LibAFL:
|
||||
* Using an **compile-time** instrumented target with **SymCC**.
|
||||
|
||||
* Using a **compile-time** instrumented target with **SymCC**.
|
||||
This only works when the source is available for the target and the target is reasonably easy to build using the SymCC compiler wrapper.
|
||||
* Using **SymQEMU** to dynamically instrument the target at **runtime**.
|
||||
This avoids a separate instrumented target with concolic tracing instrumentation and does not require source code.
|
||||
This avoids building a separate instrumented target with concolic tracing instrumentation and so does not require source code.
|
||||
|
||||
It should be noted, however, that the 'quality' of the generated expressions can be significantly worse and SymQEMU generally produces significantly more and significantly more convoluted expressions than SymCC.
|
||||
Therefore, it is recommended to use SymCC over SymQEMU when possible.
|
||||
|
||||
@ -158,23 +161,23 @@ Make sure you satisfy the [build requirements](https://github.com/eurecom-s3/sym
|
||||
|
||||
Build SymQEMU according to its [build instructions](https://github.com/eurecom-s3/symqemu#readme).
|
||||
By default, SymQEMU looks for the runtime in a sibling directory.
|
||||
Since we don't have a runtime there, we need to let it know the path to your runtime by setting `--symcc-build` argument of the `configure` script to the path of your runtime.
|
||||
Since we don't have a runtime there, we need to explicitly set the `--symcc-build` argument of the `configure` script to the path of your runtime.
|
||||
|
||||
### Building the Fuzzer
|
||||
|
||||
No matter the instrumentation method, the interface between the fuzzer and the instrumented target should now be consistent.
|
||||
The only difference between using SymCC and SymQEMU should be the binary that represents the target:
|
||||
In the case of SymCC it will be the binary that was build with instrumentation and with SymQEMU it will be the emulator binary (eg. `x86_64-linux-user/symqemu-x86_64`), followed by your uninstrumented target binary and arguments.
|
||||
In the case of SymCC it will be the binary that was build with instrumentation and with SymQEMU it will be the emulator binary (eg. `x86_64-linux-user/symqemu-x86_64`), followed by your uninstrumented target binary and its arguments.
|
||||
|
||||
You can use the [`CommandExecutor`](https://docs.rs/libafl/0.6.0/libafl/executors/command/struct.CommandExecutor.html) to execute your target ([example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs#L244)).
|
||||
When configuring the command, make sure you pass the `SYMCC_INPUT_FILE` environment variable the input file path, if your target reads input from a file (instead of standard input).
|
||||
When configuring the command, make sure you pass the `SYMCC_INPUT_FILE` environment variable (set to the input file path), if your target reads input from a file (instead of standard input).
|
||||
|
||||
#### Serialization and Solving
|
||||
|
||||
While it is perfectly possible to build a custom runtime that also performs the solving step of hybrid fuzzing in the context of the target process, the intended use of the LibAFL concolic tracing support is to serialize the (filtered and pre-processed) branch conditions using the [`TracingRuntime`](https://docs.rs/symcc_runtime/0.1/symcc_runtime/tracing/struct.TracingRuntime.html).
|
||||
This serialized representation can be deserialized in the fuzzer process for solving using a [`ConcolicObserver`](https://docs.rs/libafl/0.6.0/libafl/observers/concolic/struct.ConcolicObserver.html) wrapped in a [`ConcolicTracingStage`](https://docs.rs/libafl/0.6.0/libafl/stages/concolic/struct.ConcolicTracingStage.html), which will attach a [`ConcolicMetadata`](https://docs.rs/libafl/0.6.0/libafl/observers/concolic/struct.ConcolicMetadata.html) to every [`TestCase`](https://docs.rs/libafl/0.6.0/libafl/corpus/testcase/struct.Testcase.html).
|
||||
|
||||
The `ConcolicMetadata` can be used to replay the concolic trace and solved using an SMT-Solver.
|
||||
The `ConcolicMetadata` can be used to replay the concolic trace and to solve the conditions using an SMT-Solver.
|
||||
Most use-cases involving concolic tracing, however, will need to define some policy around which branches they want to solve.
|
||||
The [`SimpleConcolicMutationalStage`](https://docs.rs/libafl/0.6.0//libafl/stages/concolic/struct.SimpleConcolicMutationalStage.html) can be used for testing purposes.
|
||||
It will attempt to solve all branches, like the original simple backend from SymCC, using Z3.
|
||||
|
@ -17,7 +17,7 @@ If you are on Windows, you'll need to install llvm tools.
|
||||
LibAFL uses Frida's [__Stalker__](https://frida.re/docs/stalker/) to trace the execution of your program and instrument your harness.
|
||||
Thus, you have to compile your harness to a dynamic library. Frida instruments your PUT after dynamically loading it.
|
||||
|
||||
For example in our `frida_libpng` example, we load the dynamic library and find the symbol to harness as follows:
|
||||
In our `frida_libpng` example, we load the dynamic library and find the symbol to harness as follows:
|
||||
|
||||
```rust,ignore
|
||||
let lib = libloading::Library::new(module_name).unwrap();
|
||||
@ -28,9 +28,9 @@ For example in our `frida_libpng` example, we load the dynamic library and find
|
||||
|
||||
## `FridaInstrumentationHelper` and Runtimes
|
||||
|
||||
To use functionalities that Frida offers, we'll first need to obtain `Gum` object by `Gum::obtain()`.
|
||||
To use functionalities that Frida offers, we'll first need to obtain a `Gum` object by `Gum::obtain()`.
|
||||
|
||||
In LibAFL, we use the `FridaInstrumentationHelper` struct to manage frida-related state. `FridaInstrumentationHelper` is a key component that sets up the [__Transformer__](https://frida.re/docs/stalker/#transformer) that is used to generate the instrumented code. It also initializes the `Runtimes` that offer various instrumentation.
|
||||
In LibAFL, we use the `FridaInstrumentationHelper` struct to manage frida-related state. `FridaInstrumentationHelper` is a key component that sets up the [__Transformer__](https://frida.re/docs/stalker/#transformer) that is used to generate the instrumented code. It also initializes the `Runtimes` that offer various instrumentations.
|
||||
|
||||
We have `CoverageRuntime` that can track the edge coverage, `AsanRuntime` for address sanitizer, `DrCovRuntime` that uses [__DrCov__](https://dynamorio.org/page_drcov.html) for coverage collection (to be imported in coverage tools like Lighthouse, bncov, dragondance,...), and `CmpLogRuntime` for cmplog instrumentation.
|
||||
All of these runtimes can be slotted into `FridaInstrumentationHelper` at build time.
|
||||
@ -53,12 +53,12 @@ Combined with any `Runtime` you'd like to use, you can initialize the `FridaInst
|
||||
|
||||
## Running the Fuzzer
|
||||
|
||||
After setting up the `FridaInstrumentationHelper`. You can obtain the pointer to the coverage map by calling `map_ptr_mut()`.
|
||||
After setting up the `FridaInstrumentationHelper` you can obtain the pointer to the coverage map by calling `map_mut_ptr()`.
|
||||
|
||||
```rust,ignore
|
||||
let edges_observer = HitcountsMapObserver::new(StdMapObserver::new_from_ptr(
|
||||
let edges_observer = HitcountsMapObserver::new(StdMapObserver::from_mut_ptr(
|
||||
"edges",
|
||||
frida_helper.map_ptr_mut().unwrap(),
|
||||
frida_helper.map_mut_ptr().unwrap(),
|
||||
MAP_SIZE,
|
||||
));
|
||||
```
|
||||
@ -83,5 +83,5 @@ You can then link this observer to `FridaInProcessExecutor` as follows:
|
||||
);
|
||||
```
|
||||
|
||||
And, finally you can run the fuzzer.
|
||||
See the `frida_` examples in [`./fuzzers`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/) for more information and, for linux or full-system, play around with `libafl_qemu`, another binary-only tracer.
|
||||
And finally you can run the fuzzer.
|
||||
See the `frida_` examples in [`./fuzzers`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/) for more information and, for linux or full-system, play around with `libafl_qemu`, another binary-only tracer.
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Using LibAFL in `no_std` environments
|
||||
|
||||
It is possible to use LibAFL in `no_std` environments e.g. custom platforms like microcontrollers, kernels, hypervisors, and more.
|
||||
It is possible to use LibAFL in `no_std` environments e.g. on custom platforms like microcontrollers, kernels, hypervisors, and more.
|
||||
|
||||
You can simply add LibAFL to your `Cargo.toml` file:
|
||||
|
||||
@ -16,7 +16,7 @@ cargo build --no-default-features --target aarch64-unknown-none
|
||||
|
||||
## Use custom timing
|
||||
|
||||
The minimum amount of input LibAFL needs for `no_std` is a monotonically increasing timestamp.
|
||||
The minimum amount of support LibAFL needs for a `no_std` environment is a monotonically increasing timestamp.
|
||||
For this, anywhere in your project you need to implement the `external_current_millis` function, which returns the current time in milliseconds.
|
||||
|
||||
```c
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
NYX supports both source-based and binary-only fuzzing.
|
||||
|
||||
Currently, `libafl_nyx` only supports [afl++](https://github.com/AFLplusplus/AFLplusplus)'s instruction. To install it, you can use `sudo apt install aflplusplus`. Or compile from the source:
|
||||
Currently, `libafl_nyx` only supports [afl++](https://github.com/AFLplusplus/AFLplusplus)'s instruction type. To install it, you can use `sudo apt install aflplusplus`. Or compile from the source:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/AFLplusplus/AFLplusplus
|
||||
cd AFLplusplus
|
||||
make all # this will not compile afl's additional extension
|
||||
make all # this will not compile afl's additional extensions
|
||||
```
|
||||
|
||||
Then you should compile the target with the afl++ compiler wrapper:
|
||||
@ -20,9 +20,9 @@ export CXX=afl-clang-fast++
|
||||
make
|
||||
```
|
||||
|
||||
For binary-only fuzzing, Nyx uses intel-PT(Intel® Processor Trace). You can find the supported CPU at <https://www.intel.com/content/www/us/en/support/articles/000056730/processors.html>.
|
||||
For binary-only fuzzing, Nyx uses intel-PT(Intel® Processor Trace). You can find the list of supported CPUs at <https://www.intel.com/content/www/us/en/support/articles/000056730/processors.html>.
|
||||
|
||||
## Preparing Nyx working directory
|
||||
## Preparing the Nyx working directory
|
||||
|
||||
This step is used to pack the target into Nyx's kernel. Don't worry, we have a template shell script in our [example](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_parallel/setup_libxml2.sh):
|
||||
|
||||
@ -49,7 +49,7 @@ python3 ./packer/packer/nyx_config_gen.py /tmp/nyx_libxml2/ Kernel || exit
|
||||
|
||||
## Standalone fuzzing
|
||||
|
||||
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_standalone/src/main.rs). First you need to run `./setup_libxml2.sh`, It will prepare your target and create your nyx work directory in `/tmp/libxml2`. After that, you can start write your code.
|
||||
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_standalone/src/main.rs) you first need to run `./setup_libxml2.sh`. It will prepare your target and create your nyx work directory in `/tmp/libxml2`. After that, you can start to write your code.
|
||||
|
||||
First, to create `Nyxhelper`:
|
||||
|
||||
@ -57,22 +57,21 @@ First, to create `Nyxhelper`:
|
||||
let share_dir = Path::new("/tmp/nyx_libxml2/");
|
||||
let cpu_id = 0; // use first cpu
|
||||
let parallel_mode = false; // close parallel_mode
|
||||
let mut helper = NyxHelper::new(share_dir, cpu_id, true, parallel_mode, None).unwrap(); // we don't the set the last parameter in standalone mode, we just use None, here
|
||||
let mut helper = NyxHelper::new(share_dir, cpu_id, true, parallel_mode, None).unwrap(); // we don't need to set the last parameter in standalone mode, we just use None, here
|
||||
```
|
||||
|
||||
Then, fetch `trace_bits`, create an observer and the `NyxExecutor`:
|
||||
|
||||
```rust,ignore
|
||||
let trace_bits = unsafe { std::slice::from_raw_parts_mut(helper.trace_bits, helper.map_size) };
|
||||
let observer = StdMapObserver::new("trace", trace_bits);
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("trace", helper.trace_bits, helper.map_size) };
|
||||
let mut executor = NyxExecutor::new(&mut helper, tuple_list!(observer)).unwrap();
|
||||
```
|
||||
|
||||
Finally, use them as normal and pass them into `fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)` to start fuzzing.
|
||||
Finally, use them normally and pass them into `fuzzer.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)` to start fuzzing.
|
||||
|
||||
## Parallel fuzzing
|
||||
|
||||
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_parallel/src/main.rs). First you need to run `./setup_libxml2.sh` as described before.
|
||||
In the [example fuzzer](https://github.com/AFLplusplus/LibAFL/blob/main/fuzzers/nyx_libxml2_parallel/src/main.rs) you first need to run `./setup_libxml2.sh` as described before.
|
||||
|
||||
Parallel fuzzing relies on [`Launcher`](../message_passing/spawn_instances.md), so spawn logic should be written in the scoop of anonymous function `run_client`:
|
||||
|
||||
@ -91,7 +90,7 @@ let mut helper = NyxHelper::new(
|
||||
cpu_id, // current cpu id
|
||||
true, // open snap_mode
|
||||
parallel_mode, // open parallel mode
|
||||
Some(parent_cpu_id.id as u32), // the cpu-id of master instance, there is only one master instance, other instances will be treated as slaved
|
||||
Some(parent_cpu_id.id as u32), // the cpu-id of main instance, there is only one main instance, other instances will be treated as secondaries
|
||||
)
|
||||
.unwrap();
|
||||
```
|
||||
@ -99,13 +98,11 @@ let mut helper = NyxHelper::new(
|
||||
Then you can fetch the trace_bits and create an observer and `NyxExecutor`
|
||||
|
||||
```rust,ignore
|
||||
let trace_bits =
|
||||
unsafe { std::slice::from_raw_parts_mut(helper.trace_bits, helper.map_size) };
|
||||
let observer = StdMapObserver::new("trace", trace_bits);
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("trace", helper.trace_bits, helper.map_size) }
|
||||
let mut executor = NyxExecutor::new(&mut helper, tuple_list!(observer)).unwrap();
|
||||
```
|
||||
|
||||
Finally, open a `Launcher` as normal to start fuzzing:
|
||||
Finally, open a `Launcher` as usual to start fuzzing:
|
||||
|
||||
```rust,ignore
|
||||
match Launcher::builder()
|
||||
@ -121,6 +118,6 @@ match Launcher::builder()
|
||||
{
|
||||
Ok(()) => (),
|
||||
Err(Error::ShuttingDown) => println!("Fuzzing stopped by user. Good bye."),
|
||||
Err(err) => panic!("Failed to run launcher: {:?}", err),
|
||||
Err(err) => panic!("Failed to run launcher: {err:?}"),
|
||||
}
|
||||
```
|
||||
|
@ -17,7 +17,7 @@ You can find a complete version of this tutorial as an example fuzzer in [`fuzze
|
||||
|
||||
We use cargo to create a new Rust project with LibAFL as a dependency.
|
||||
|
||||
```sh
|
||||
```console
|
||||
$ cargo new baby_fuzzer
|
||||
$ cd baby_fuzzer
|
||||
```
|
||||
@ -25,18 +25,11 @@ $ cd baby_fuzzer
|
||||
The generated `Cargo.toml` looks like the following:
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "baby_fuzzer"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
{{#include ../../listings/baby_fuzzer/listing-01/Cargo.toml}}
|
||||
```
|
||||
|
||||
In order to use LibAFl we must add it as dependency adding `libafl = { path = "path/to/libafl/" }` under `[dependencies]`.
|
||||
That path actually needs to point to the `libafl` directory within the cloned repo, not the root of the repo itself.
|
||||
You can use the LibAFL version from [crates.io](https://crates.io/crates/libafl) if you want, in this case, you have to use `libafl = "*"` to get the latest version (or set it to the current version).
|
||||
|
||||
As we are going to fuzz Rust code, we want that a panic does not simply cause the program to exit, but raise an `abort` that can then be caught by the fuzzer.
|
||||
@ -47,28 +40,10 @@ Alongside this setting, we add some optimization flags for the compilation, when
|
||||
The final `Cargo.toml` should look similar to the following:
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "baby_fuzzer"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "path/to/libafl/" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
{{#include ../../listings/baby_fuzzer/listing-02/Cargo.toml}}
|
||||
```
|
||||
|
||||
|
||||
## The function under test
|
||||
|
||||
Opening `src/main.rs`, we have an empty `main` function.
|
||||
@ -76,52 +51,32 @@ To start, we create the closure that we want to fuzz. It takes a buffer as input
|
||||
`ExitKind` is used to inform the fuzzer about the harness' exit status.
|
||||
|
||||
```rust
|
||||
extern crate libafl;
|
||||
use libafl::{
|
||||
bolts::AsSlice,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
executors::ExitKind,
|
||||
};
|
||||
|
||||
fn main(){
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
// To test the panic:
|
||||
let input = BytesInput::new(Vec::from("abc"));
|
||||
#[cfg(feature = "panic")]
|
||||
harness(&input);
|
||||
}
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-03/src/main.rs}}
|
||||
```
|
||||
|
||||
To test the crash manually, you can add a feature in `Cargo.toml` that enables the call that triggers the panic:
|
||||
|
||||
```toml
|
||||
{{#include ../../listings/baby_fuzzer/listing-03/Cargo.toml:22:24}}
|
||||
```
|
||||
|
||||
And then run the program with that feature activated:
|
||||
|
||||
```console
|
||||
$ cargo run -F panic
|
||||
```
|
||||
|
||||
And you should see the program crash as expected.
|
||||
|
||||
## Generating and running some tests
|
||||
|
||||
One of the main components that a LibAFL-based fuzzer uses is the State, a container of the data that is evolved during the fuzzing process.
|
||||
Includes all State, such as the Corpus of inputs, the current RNG state, and potential Metadata for the testcases and run.
|
||||
One of the main components that a LibAFL-based fuzzer uses is the State, a container of the data that will evolve during the fuzzing process.
|
||||
It includes all state, such as the Corpus of inputs, the current RNG state, and potential Metadata for the testcases and run.
|
||||
In our `main` we create a basic State instance like the following:
|
||||
|
||||
```rust,ignore
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
&mut (),
|
||||
&mut ()
|
||||
).unwrap();
|
||||
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:state}}
|
||||
```
|
||||
|
||||
- The first parameter is a random number generator, that is part of the fuzzer state, in this case, we use the default one `StdRand`, but you can choose a different one. We seed it with the current nanoseconds.
|
||||
@ -129,43 +84,26 @@ let mut state = StdState::new(
|
||||
|
||||
To avoid type annotation error, you can use `InMemoryCorpus::<BytesInput>::new()` to replace `InMemoryCorpus::new()`. If not, type annotation will be automatically inferred when adding `executor`.
|
||||
|
||||
- third parameter is another corpus that stores the "solution" testcases for the fuzzer. For our purpose, the solution is the input that triggers the panic. In this case, we want to store it to disk under the `crashes` directory, so we can inspect it.
|
||||
- last two parameters are feedback and objective, we will discuss them later.
|
||||
- The third parameter is another Corpus that stores the "solution" testcases for the fuzzer. For our purpose, the solution is the input that triggers the panic. In this case, we want to store it to disk under the `crashes` directory, so we can inspect it.
|
||||
- The last two parameters are feedback and objective, we will discuss them later.
|
||||
|
||||
Another required component is the **EventManager**. It handles some events such as the addition of a testcase to the corpus during the fuzzing process. For our purpose, we use the simplest one that just displays the information about these events to the user using a `Monitor` instance.
|
||||
|
||||
```rust,ignore
|
||||
// The Monitor trait defines how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:event_manager}}
|
||||
```
|
||||
|
||||
In addition, we have the **Fuzzer**, an entity that contains some actions that alter the State. One of these actions is the scheduling of the testcases to the fuzzer using a **Scheduler**.
|
||||
We create it as `QueueScheduler`, a scheduler that serves testcases to the fuzzer in a FIFO fashion.
|
||||
|
||||
```rust,ignore
|
||||
// A queue policy to get testcasess from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, (), ());
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:scheduler_fuzzer}}
|
||||
```
|
||||
|
||||
Last but not least, we need an **Executor** that is the entity responsible to run our program under test. In this example, we want to run the harness function in-process (without forking off a child, for example), and so we use the `InProcessExecutor`.
|
||||
|
||||
```rust,ignore
|
||||
// Create the executor for an in-process function
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
(),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor");
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:executor}}
|
||||
```
|
||||
|
||||
It takes a reference to the harness, the state, and the event manager. We will discuss the second parameter later.
|
||||
@ -175,41 +113,19 @@ Now we have the 4 major entities ready for running our tests, but we still canno
|
||||
|
||||
For this purpose, we use a **Generator**, `RandPrintablesGenerator` that generates a string of printable bytes.
|
||||
|
||||
```rust,ignore
|
||||
use libafl::generators::RandPrintablesGenerator;
|
||||
|
||||
// Generator of printable bytearrays of max size 32
|
||||
let mut generator = RandPrintablesGenerator::new(32);
|
||||
|
||||
// Generate 8 initial inputs
|
||||
state
|
||||
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
|
||||
.expect("Failed to generate the initial corpus".into());
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:generator}}
|
||||
```
|
||||
|
||||
Now you can prepend the necessary `use` directives to your main.rs and compile the fuzzer.
|
||||
|
||||
```rust
|
||||
extern crate libafl;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use libafl::{
|
||||
bolts::{AsSlice, current_nanos, rands::StdRand},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
fuzzer::StdFuzzer,
|
||||
generators::RandPrintablesGenerator,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
schedulers::QueueScheduler,
|
||||
state::StdState,
|
||||
};
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-04/src/main.rs:use}}
|
||||
```
|
||||
|
||||
When running, you should see something similar to:
|
||||
|
||||
```sh
|
||||
```console
|
||||
$ cargo run
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
|
||||
Running `target/debug/baby_fuzzer`
|
||||
@ -225,60 +141,22 @@ Now we want to turn our simple fuzzer into a feedback-based one and increase the
|
||||
**Observer** can record the information about properties of a fuzzing run and then feeds the fuzzer. We use the `StdMapObserver`, the default observer that uses a map to keep track of covered elements. In our fuzzer, each condition is mapped to an entry of such map.
|
||||
|
||||
We represent such map as a `static mut` variable.
|
||||
As we don't rely on any instrumentation engine, we have to manually track the satisfied conditions by `singals_set` in our harness:
|
||||
As we don't rely on any instrumentation engine, we have to manually track the satisfied conditions by `signals_set` in our harness:
|
||||
|
||||
```rust
|
||||
extern crate libafl;
|
||||
use libafl::{
|
||||
bolts::AsSlice,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
executors::ExitKind,
|
||||
};
|
||||
|
||||
// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
}
|
||||
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
signals_set(0); // set SIGNALS[0]
|
||||
if buf.len() > 0 && buf[0] == 'a' as u8 {
|
||||
signals_set(1); // set SIGNALS[1]
|
||||
if buf.len() > 1 && buf[1] == 'b' as u8 {
|
||||
signals_set(2); // set SIGNALS[2]
|
||||
if buf.len() > 2 && buf[2] == 'c' as u8 {
|
||||
panic!("=)");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:signals}}
|
||||
```
|
||||
|
||||
The observer can be created directly from the `SIGNALS` map, in the following way:
|
||||
|
||||
```rust,ignore
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:observer}}
|
||||
```
|
||||
|
||||
The observers are usually kept in the corresponding executor as they keep track of information that is valid for just one run. We have then to modify our InProcessExecutor creation to include the observer as follows:
|
||||
|
||||
```rust,ignore
|
||||
// Create the executor for an in-process function with just one observer
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
tuple_list!(observer),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor".into());
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:executor_with_observer}}
|
||||
```
|
||||
|
||||
Now that the fuzzer can observe which condition is satisfied, we need a way to rate an input as interesting (i.e. worth of addition to the corpus) based on this observation. Here comes the notion of Feedback.
|
||||
@ -287,49 +165,23 @@ Now that the fuzzer can observe which condition is satisfied, we need a way to r
|
||||
|
||||
We use `MaxMapFeedback`, a feedback that implements a novelty search over the map of the MapObserver. Basically, if there is a value in the observer's map that is greater than the maximum value registered so far for the same entry, it rates the input as interesting and updates its state.
|
||||
|
||||
**Objective Feedback** is another kind of Feedback which decide if an input is a "solution". It will save input to solutions(`./crashes` in our case) other than corpus when the input is rated interesting. We use `CrashFeedback` to tell the fuzzer that if an input causes the program to crash it is a solution for us.
|
||||
**Objective Feedback** is another kind of Feedback which decides if an input is a "solution". It will save input to solutions(`./crashes` in our case) rather than corpus when the input is rated interesting. We use `CrashFeedback` to tell the fuzzer that if an input causes the program to crash it is a solution for us.
|
||||
|
||||
We need to update our State creation including the feedback state and the Fuzzer including the feedback and the objective:
|
||||
|
||||
```rust,ignore
|
||||
extern crate libafl;
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
feedbacks::{MaxMapFeedback, CrashFeedback},
|
||||
fuzzer::StdFuzzer,
|
||||
state::StdState,
|
||||
observers::StdMapObserver,
|
||||
};
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:state_with_feedback_and_objective}}
|
||||
```
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
Once again, you need to add the necessary `use` directives for this to work properly:
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
&mut feedback,
|
||||
&mut objective
|
||||
).unwrap();
|
||||
|
||||
// ...
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
|
||||
```rust
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-05/src/main.rs:use}}
|
||||
```
|
||||
|
||||
## The actual fuzzing
|
||||
|
||||
Now, after including the correct `use`, we can run the program, but the outcome is not so different from the previous one as the random generator does not take into account what we save as interesting in the corpus. To do that, we need to plug a Mutator.
|
||||
Now, we can run the program, but the outcome is not so different from the previous one as the random generator does not take into account what we save as interesting in the corpus. To do that, we need to plug a Mutator.
|
||||
|
||||
**Stages** perform actions on individual inputs, taken from the corpus.
|
||||
For instance, the `MutationalStage` executes the harness several times in a row, every time with mutated inputs.
|
||||
@ -337,28 +189,20 @@ For instance, the `MutationalStage` executes the harness several times in a row,
|
||||
As the last step, we create a MutationalStage that uses a mutator inspired by the havoc mutator of AFL.
|
||||
|
||||
```rust,ignore
|
||||
use libafl::{
|
||||
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
|
||||
stages::mutational::StdMutationalStage,
|
||||
fuzzer::Fuzzer,
|
||||
};
|
||||
|
||||
// ...
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::new(havoc_mutations());
|
||||
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
|
||||
|
||||
fuzzer
|
||||
.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)
|
||||
.expect("Error in the fuzzing loop");
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-06/src/main.rs:mutational_stage}}
|
||||
```
|
||||
|
||||
`fuzz_loop` will request a testcase for each iteration to the fuzzer using the scheduler and then it will invoke the stage.
|
||||
|
||||
After adding this code, we have a proper fuzzer, that can run a find the input that panics the function in less than a second.
|
||||
Again, we need to add the new `use` directives:
|
||||
|
||||
```text
|
||||
```rust,ignore
|
||||
{{#rustdoc_include ../../listings/baby_fuzzer/listing-06/src/main.rs:use}}
|
||||
```
|
||||
|
||||
After adding this code, we have a proper fuzzer, that can run and find the input that panics the function in less than a second.
|
||||
|
||||
```console
|
||||
$ cargo run
|
||||
Compiling baby_fuzzer v0.1.0 (/home/andrea/Desktop/baby_fuzzer)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 1.56s
|
||||
|
@ -9,4 +9,4 @@ Examples can be found under `./fuzzer`.
|
||||
| baby_fuzzer_nautilus | [nautilus](https://www.ndss-symposium.org/wp-content/uploads/2019/02/ndss2019_04A-3_Aschermann_paper.pdf) is a **coverage guided, grammar based** fuzzer|
|
||||
|baby_fuzzer_tokens| basic **token level** fuzzer with token level mutations|
|
||||
|baby_fuzzer_with_forkexecutor| example for **InProcessForkExecutor**|
|
||||
|baby_no_std|a minimalistic example how to create a libafl based fuzzer that works on **`no_std`** environments like TEEs, Kernels or on barew metal|
|
||||
|baby_no_std|a minimalistic example how to create a libafl based fuzzer that works on **`no_std`** environments like TEEs, Kernels or on bare metal|
|
||||
|
@ -4,8 +4,8 @@ The Corpus is where testcases are stored. We define a Testcase as an Input and a
|
||||
|
||||
A Corpus can store testcases in different ways, for example on disk, or in memory, or implement a cache to speedup on disk storage.
|
||||
|
||||
Usually, a testcase is added to the Corpus when it is considered as interesting, but a Corpus is used also to store testcases that fulfill an objective (like crashing the tested program for instance).
|
||||
Usually, a testcase is added to the Corpus when it is considered as interesting, but a Corpus is used also to store testcases that fulfill an objective (like crashing the program under test for instance).
|
||||
|
||||
Related to the Corpus, there is the way in which the fuzzer should ask for the next testcase to fuzz picking it from the Corpus. The taxonomy for this in LibAFL is CorpusScheduler, the entity representing the policy to pop testcases from the Corpus, FIFO for instance.
|
||||
Related to the Corpus is the way in which the next testcase (the fuzzer would ask for) is retrieved from the Corpus. The taxonomy for this handling in LibAFL is CorpusScheduler, the entity representing the policy to pop testcases from the Corpus, in a FIFO fashion for instance.
|
||||
|
||||
Speaking about the code, [`Corpus`](https://docs.rs/libafl/0/libafl/corpus/trait.Corpus.html) and [`CorpusScheduler`](https://docs.rs/libafl/0/libafl/corpus/trait.CorpusScheduler.html) are traits.
|
||||
|
@ -13,7 +13,7 @@ In Rust, we bind this concept to the [`Executor`](https://docs.rs/libafl/0/libaf
|
||||
|
||||
By default, we implement some commonly used Executors such as [`InProcessExecutor`](https://docs.rs/libafl/0/libafl/executors/inprocess/struct.InProcessExecutor.html) in which the target is a harness function providing in-process crash detection. Another Executor is the [`ForkserverExecutor`](https://docs.rs/libafl/0/libafl/executors/forkserver/struct.ForkserverExecutor.html) that implements an AFL-like mechanism to spawn child processes to fuzz.
|
||||
|
||||
A common pattern when creating an Executor is wrapping an existing one, for instance [`TimeoutExecutor`](https://docs.rs/libafl/0.6.1/libafl/executors/timeout/struct.TimeoutExecutor.html) wraps an executor and install a timeout callback before calling the original run function of the wrapped executor.
|
||||
A common pattern when creating an Executor is wrapping an existing one, for instance [`TimeoutExecutor`](https://docs.rs/libafl/0.6.1/libafl/executors/timeout/struct.TimeoutExecutor.html) wraps an executor and installs a timeout callback before calling the original `run` function of the wrapped executor.
|
||||
|
||||
## InProcessExecutor
|
||||
Let's begin with the base case; `InProcessExecutor`.
|
||||
@ -24,7 +24,7 @@ When you want to execute the harness as fast as possible, you will most probably
|
||||
One thing to note here is, when your harness is likely to have heap corruption bugs, you want to use another allocator so that corrupted heap does not affect the fuzzer itself. (For example, we adopt MiMalloc in some of our fuzzers.). Alternatively you can compile your harness with address sanitizer to make sure you can catch these heap bugs.
|
||||
|
||||
## ForkserverExecutor
|
||||
Next, we'll take a look at the `ForkserverExecutor`. In this case, it is `afl-cc` (from AFLplusplus/AFLplusplus) that compiles the harness code, and therefore, we can't use `EDGES_MAP` anymore. Hopefully, we have [_a way_](https://github.com/AFLplusplus/AFLplusplus/blob/2e15661f184c77ac1fbb6f868c894e946cbb7f17/instrumentation/afl-compiler-rt.o.c#L270) to tell the forkserver which map to record the coverage.
|
||||
Next, we'll take a look at the `ForkserverExecutor`. In this case, it is `afl-cc` (from AFLplusplus/AFLplusplus) that compiles the harness code, and therefore, we can't use `EDGES_MAP` anymore. Fortunately we have [_a way_](https://github.com/AFLplusplus/AFLplusplus/blob/2e15661f184c77ac1fbb6f868c894e946cbb7f17/instrumentation/afl-compiler-rt.o.c#L270) to tell the forkserver which map to record the coverage in.
|
||||
|
||||
As you can see from the forkserver example,
|
||||
|
||||
@ -48,7 +48,7 @@ See AFL++'s [_documentation_](https://github.com/AFLplusplus/AFLplusplus/blob/st
|
||||
Finally, we'll talk about the `InProcessForkExecutor`.
|
||||
`InProcessForkExecutor` has only one difference from `InprocessExecutor`; It forks before running the harness and that's it.
|
||||
|
||||
But why do we want to do so? well, under some circumstances, you may find your harness pretty unstable or your harness wreaks havoc on the global states. In this case, you want to fork it before executing the harness runs in the child process so that it doesn't break things.
|
||||
But why do we want to do so? Well, under some circumstances, you may find your harness pretty unstable or your harness wreaks havoc on the global states. In this case, you want to fork it before executing the harness runs in the child process so that it doesn't break things.
|
||||
|
||||
However, we have to take care of the shared memory, it's the child process that runs the harness code and writes the coverage to the map.
|
||||
|
||||
|
@ -10,17 +10,25 @@ The concept of "interestingness" is abstract, but typically it is related to a n
|
||||
|
||||
As an example, given an Observer that reports all the sizes of memory allocations, a maximization Feedback can be used to maximize these sizes to sport pathological inputs in terms of memory consumption.
|
||||
|
||||
In terms of code, the library offers the [`Feedback`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html) and the [`FeedbackState`](https://docs.rs/libafl/0/libafl/feedbacks/trait.FeedbackState.html) traits.
|
||||
The first is used to implement functors that, given the state of the observers from the last execution, tells if the execution was interesting. The second is tied with `Feedback` and it is the state of the data that the feedback wants to persist in the fuzzers's state, for instance the cumulative map holding all the edges seen so far in the case of a feedback based on edge coverage.
|
||||
In terms of code, the library offers the [`Feedback`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html) trait.
|
||||
It is used to implement functors that, given the state of the observers from the last execution, tells if the execution was interesting.
|
||||
So to speak, it reduces the observations to a boolean result of [`is_interesting`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html#tymethod.is_interesting) - or not.
|
||||
For this, a `Feedback` can store anything it wants to persist in the fuzzers's state.
|
||||
This might be, for instance, the cumulative map of all edges seen so far, in the case of a feedback based on edge coverage.
|
||||
This can be achieved by adding `Metadata` in [`init_state`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html#method.init_state) and accessing it later in `is_interesting`.
|
||||
`Feedback` can also add custom metadata to a newly created [`Testcase`](https://docs.rs/libafl/0/libafl/corpus/testcase/struct.Testcase.html) using [`append_metadata`](https://docs.rs/libafl/0.10.1/libafl/feedbacks/trait.Feedback.html#method.append_metadata).
|
||||
|
||||
Multiple Feedbacks can be combined into boolean formula, considering for instance an execution as interesting if it triggers new code paths or execute in less time compared to the average execution time using [`feedback_or`](https://docs.rs/libafl/*/libafl/macro.feedback_or.html).
|
||||
Multiple Feedbacks can be combined into a boolean expression, considering for instance an execution as interesting if it triggers new code paths or execute in less time compared to the average execution time using [`feedback_or`](https://docs.rs/libafl/*/libafl/macro.feedback_or.html).
|
||||
|
||||
On top, logic operators like `feedback_or` and `feedback_and` have a `_fast` option (`feedback_or_fast` where the second feedback will not be evaluated, if the first part already answers the `interestingness` question, to save precious performance.
|
||||
On top, logic operators like `feedback_or` and `feedback_and` have a `_fast` variant (e.g. `feedback_or_fast`) where the second feedback will not be evaluated, if the value of the first feedback operand already answers the `interestingness` question so as to save precious performance.
|
||||
|
||||
Using `feedback_and_fast` in combination with [`ConstFeedback`](https://docs.rs/libafl/*/libafl/feedbacks/enum.ConstFeedback.html#method.new), certain feedbacks can be disabled dynamically.
|
||||
|
||||
## Objectives
|
||||
|
||||
While feedbacks are commonly used to decide if an [`Input`](https://docs.rs/libafl/*/libafl/inputs/trait.Input.html) should be kept for future mutations, they serve a double-purpose, as so-called `Objective Feedbacks`.
|
||||
In this case, the `interestingness` of a feedback indicates, if an `Objective` has been hit.
|
||||
Commonly, these would be a`crash or a timeout, but they can also be used to find specific parts of the program, for sanitization, or a differential fuzzing success.
|
||||
In this case, the `interestingness` of a feedback indicates if an `Objective` has been hit.
|
||||
Commonly, these objectives would be a crash or a timeout, but they can also be used to detect if specific parts of the program have been reached, for sanitization, or a differential fuzzing success.
|
||||
Objectives use the same trait as a normal [`Feedback`](https://docs.rs/libafl/0/libafl/feedbacks/trait.Feedback.html) and the implementations can be used interchangeably.
|
||||
|
||||
The only difference is that `interesting` Objectives won't be mutated further, and are counted as `Solutions`, a successful fuzzing campaign.
|
||||
|
@ -6,10 +6,10 @@ In our model of an abstract fuzzer, we define the Input as the internal represen
|
||||
|
||||
In the straightforward case, the input of the program is a byte array and in fuzzers such as AFL we store and manipulate exactly these byte arrays.
|
||||
|
||||
But it is not always the case. A program can expect inputs that are not byte arrays (e.g. a sequence of syscalls) and the fuzzer does not represent the Input in the same way that the program consumes it.
|
||||
But it is not always the case. A program can expect inputs that are not linear byte arrays (e.g. a sequence of syscalls forming a use case or protocol) and the fuzzer does not represent the Input in the same way that the program consumes it.
|
||||
|
||||
In case of a grammar fuzzer for instance, the Input is generally an Abstract Syntax Tree because it is a data structure that can be easily manipulated while maintaining the validity, but the program expects a byte array as input, so just before the execution, the tree is serialized to a sequence of bytes.
|
||||
|
||||
In the Rust code, an [`Input`](https://docs.rs/libafl/*/libafl/inputs/trait.Input.html) is a trait that can be implemented only by structures that are serializable and have only owned data as fields.
|
||||
|
||||
While most fuzzer use a normal `BytesInput`], more advanced inputs like inputs include special inputs for grammar fuzzing ([GramatronInput](https://docs.rs/libafl/*/libafl/inputs/gramatron/struct.GramatronInput.html) or `NautilusInput` on nightly), as well as the token-level [EncodedInput](https://docs.rs/libafl/*/libafl/inputs/encoded/struct.EncodedInput.html).
|
||||
While most fuzzers use a normal `BytesInput`, more advanced ones use inputs that include special inputs for grammar fuzzing ([GramatronInput](https://docs.rs/libafl/*/libafl/inputs/gramatron/struct.GramatronInput.html) or `NautilusInput` on Rust nightly), as well as the token-level [EncodedInput](https://docs.rs/libafl/*/libafl/inputs/encoded/struct.EncodedInput.html).
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Mutator
|
||||
|
||||
The Mutator is an entity that takes one or more Inputs and generates a new derived one.
|
||||
The Mutator is an entity that takes one or more Inputs and generates a new instance of Input derived by its inputs.
|
||||
|
||||
Mutators can be composed, and they are generally linked to a specific Input type.
|
||||
|
||||
There can be, for instance, a Mutator that applies more than a single type of mutation on the input. Consider a generic Mutator for a byte stream, bit flip is just one of the possible mutations but not the only one, there is also, for instance, the random replacement of a byte of the copy of a chunk.
|
||||
There can be, for instance, a Mutator that applies more than a single type of mutation to the input. Consider a generic Mutator for a byte stream, bit flip is just one of the possible mutations but not the only one, there is also, for instance, the random replacement of a byte of the copy of a chunk.
|
||||
|
||||
In LibAFL, [`Mutator`](https://docs.rs/libafl/*/libafl/mutators/trait.Mutator.html) is a trait.
|
||||
|
@ -4,8 +4,8 @@ An Observer is an entity that provides an information observed during the execut
|
||||
|
||||
The information contained in the Observer is not preserved across executions, but it may be serialized and passed on to other nodes if an `Input` is considered `interesting`, and added to the `Corpus`.
|
||||
|
||||
As an example, the coverage map, filled during the execution to report the executed edges used by fuzzers such as AFL and `HonggFuzz` can be considered an observation. Another `Observer` can be the time spent executing a run, the program output, or more advanced observation, like maximum stack depth at runtime.
|
||||
This information is not preserved across runs, and it is an observation of a dynamic property of the program.
|
||||
As an example, the coverage map, filled during the execution to report the executed edges used by fuzzers such as AFL and `HonggFuzz` can be considered an observation. Another `Observer` can collect the time spent executing a run, the program output, or a more advanced observation, like maximum stack depth at runtime.
|
||||
This information is an observation of a dynamic property of the program.
|
||||
|
||||
In terms of code, in the library this entity is described by the [`Observer`](https://docs.rs/libafl/0/libafl/observers/trait.Observer.html) trait.
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Stage
|
||||
|
||||
A Stage is an entity that operates on a single Input got from the Corpus.
|
||||
A Stage is an entity that operates on a single Input received from the Corpus.
|
||||
|
||||
For instance, a Mutational Stage, given an input of the corpus, applies a Mutator and executes the generated input one or more time. How many times this has to be done can be scheduled, AFL for instance uses a performance score of the input to choose how many times the havoc mutator should be invoked. This can depend also on other parameters, for instance, the length of the input if we want to just apply a sequential bitflip, or be a fixed value.
|
||||
For instance, a Mutational Stage, given an input of the corpus, applies a Mutator and executes the generated input one or more times. How many times this has to be done can be scheduled, AFL for instance uses a performance score of the input to choose how many times the havoc mutator should be invoked. This can depend also on other parameters, for instance, the length of the input if we want to just apply a sequential bitflip, or a fixed value.
|
||||
|
||||
A stage can also be an analysis stage, for instance, the Colorization stage of Redqueen that aims to introduce more entropy in a testcase or the Trimming stage of AFL that aims to reduce the size of a testcase.
|
||||
|
||||
|
@ -10,6 +10,6 @@ Thinking about similar fuzzers, you can observe that most of the time the data s
|
||||
|
||||
Beside the entities previously described, we introduce the [`Testcase`](https://docs.rs/libafl/0.6/libafl/corpus/testcase/struct.Testcase.html) and [`State`](https://docs.rs/libafl/0.6/libafl/state/struct.StdState.html) entities. The Testcase is a container for an Input stored in the Corpus and its metadata (so, in the implementation, the Corpus stores Testcases) and the State contains all the metadata that are evolved while running the fuzzer, Corpus included.
|
||||
|
||||
The State, in the implementation, contains only owned objects that are serializable, and it is serializable itself. Some fuzzers may want to serialize its state when pausing or just, when doing in-process fuzzing, serialize on crash and deserialize in the new process to continue to fuzz with all the metadata preserved.
|
||||
The State, in the implementation, contains only owned objects that are serializable, and it is serializable itself. Some fuzzers may want to serialize their state when pausing or just, when doing in-process fuzzing, serialize on crash and deserialize in the new process to continue to fuzz with all the metadata preserved.
|
||||
|
||||
Additionally, we group the entities that are "actions", like the `CorpusScheduler` and the `Feedbacks`, in a common place, the [`Fuzzer'](https://docs.rs/libafl/*/libafl/fuzzer/struct.StdFuzzer.html).
|
||||
|
@ -5,10 +5,10 @@ A metadata in LibAFL is a self-contained structure that holds associated data to
|
||||
In terms of code, a metadata can be defined as a Rust struct registered in the SerdeAny register.
|
||||
|
||||
```rust
|
||||
extern crate libafl;
|
||||
extern crate serde;
|
||||
# extern crate libafl_bolts;
|
||||
# extern crate serde;
|
||||
|
||||
use libafl::SerdeAny;
|
||||
use libafl_bolts::SerdeAny;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, SerdeAny)]
|
||||
@ -19,7 +19,7 @@ pub struct MyMetadata {
|
||||
|
||||
The struct must be static, so it cannot hold references to borrowed objects.
|
||||
|
||||
As an alternative to `derive(SerdeAny)` that is a proc-macro in `libafl_derive` the user can use `libafl::impl_serdeany!(MyMetadata);`.
|
||||
As an alternative to `derive(SerdeAny)` which is a proc-macro in `libafl_derive` the user can use `libafl_bolts::impl_serdeany!(MyMetadata);`.
|
||||
|
||||
## Usage
|
||||
|
||||
|
27
docs/src/design/migration-0.11.md
Normal file
27
docs/src/design/migration-0.11.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Migrating from LibAFL <0.11 to 0.11
|
||||
|
||||
We moved the old `libafl::bolts` module to its own crate called `libafl_bolts`.
|
||||
For this, imports for types in LibAFL bolts have changed in version 0.11, everything else should remain the same.
|
||||
|
||||
## Reasons for This Change
|
||||
|
||||
With the change we can now use a lot of low-level features of LibAFL for projects that are unrelated to fuzzing, or just completely different to LibAFL.
|
||||
Some cross-platform things in bolts include
|
||||
|
||||
* SerdeAnyMap: a map that stores and retrieves elements by type and is serializable and deserializable
|
||||
* ShMem: A cross-platform (Windows, Linux, Android, MacOS) shared memory implementation
|
||||
* LLMP: A fast, lock-free IPC mechanism via SharedMap
|
||||
* Core_affinity: A maintained version of `core_affinity` that can be used to get core information and bind processes to cores
|
||||
* Rands: Fast random number generators for fuzzing (like [RomuRand](http://www.romu-random.org/))
|
||||
* MiniBSOD: get and print information about the current process state including important registers.
|
||||
* Tuples: Haskel-like compile-time tuple lists
|
||||
* Os: OS specific stuff like signal handling, windows exception handling, pipes, and helpers for `fork`
|
||||
|
||||
## What changed
|
||||
|
||||
You will need to move all `libafl::bolts::` imports to `libafl_bolts:::` and add the crate dependency in your Cargo.toml (and specify feature flags there).
|
||||
As only exception, the `libafl::bolts::launcher::Launcher` has moved to `libafl::events::launcher::Launcher` since it has fuzzer and `EventManager` specific code.
|
||||
If you are using `prelude`, you may need to also ad `libafl_bolts::prelude`.
|
||||
|
||||
That's it.
|
||||
Enjoy using `libafl_bolts` in other projects.
|
@ -75,7 +75,7 @@ where
|
||||
```
|
||||
|
||||
The executor is constrained to `EM` and `Z`, with each of their respective states being constrained to `E`'s state. It
|
||||
is no longer necessary to explicitly defined a generic for the input type, the state type, or the generic type, as these
|
||||
is no longer necessary to explicitly define a generic for the input type, the state type, or the generic type, as these
|
||||
are all present as associated types for `E`. Additionally, we don't even need to specify any details about the observers
|
||||
(`OT` in the previous version) as the type does not need to be constrained and is not shared by other types.
|
||||
|
||||
@ -101,7 +101,7 @@ See `fuzzers/` for examples of these changes.
|
||||
If you implemented a Mutator, Executor, State, or another kind of component, you must update your implementation. The
|
||||
main changes to the API are in the use of "Uses*" for associated types.
|
||||
|
||||
In many scenarios, Input, Observers, and State generics have been moved into traits with associated types (namely,
|
||||
In many scenarios, Input, Observer, and State generics have been moved into traits with associated types (namely,
|
||||
"UsesInput", "UsesObservers", and "UsesState". These traits are required for many existing traits now and are very
|
||||
straightforward to implement. In a majority of cases, you will have generics on your custom implementation or a fixed
|
||||
type to implement this with. Thankfully, Rust will let you know when you need to implement this type.
|
||||
@ -127,7 +127,7 @@ where
|
||||
}
|
||||
```
|
||||
|
||||
After 0.9, all `Corpus` implementations are required to implement `UsesInput` and `Corpus` no longer has a generic for
|
||||
After 0.9, all `Corpus` implementations are required to implement `UsesInput`. Also `Corpus` no longer has a generic for
|
||||
the input type (as it is now provided by the UsesInput impl). The migrated implementation is shown below:
|
||||
|
||||
```rust,ignore
|
||||
@ -160,3 +160,26 @@ Now, `Corpus` cannot be accidentally implemented for another type other than tha
|
||||
is fixed to the associated type for `UsesInput`.
|
||||
|
||||
A more complex example of migration can be found in the "Reasons for this change" section of this document.
|
||||
|
||||
## Observer Changes
|
||||
|
||||
Additionally, we changed the Observer API, as the API in 0.8 led to undefined behavior.
|
||||
At the same time, we used the change to simplify the common case: creating an `StdMapObserver`
|
||||
from libafl_target's `EDGES_MAP`.
|
||||
In the future, instead of using:
|
||||
|
||||
```rust,ignore
|
||||
let edges = unsafe { &mut EDGES_MAP[0..MAX_EDGES_NUM] };
|
||||
let edges_observer = StdMapObserver::new("edges", edges);
|
||||
```
|
||||
|
||||
creating the edges observer is as simple as using the new `std_edges_map_observer` function.
|
||||
|
||||
```rust,ignore
|
||||
let edges_observer = unsafe { std_edges_map_observer("edges") };
|
||||
```
|
||||
|
||||
Alternatively, `StdMapObserver::new` will still work, but now the whole method is marked as `unsafe`.
|
||||
The reason is that the caller has to make sure `EDGES_MAP` (or other maps) are not moved or freed in memory,
|
||||
for the lifetime of the `MapObserver`.
|
||||
This means that the buffer should either be `static` or `Pin`.
|
||||
|
@ -6,7 +6,7 @@ LibAFL, as most of the Rust projects, can be built using `cargo` from the root d
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
Note that the `--release` flag is optional for development, but you needed to add it to fuzzing at a decent speed.
|
||||
Note that the `--release` flag is optional for development, but you need to add it to do fuzzing at a decent speed.
|
||||
Slowdowns of 10x or more are not uncommon for Debug builds.
|
||||
|
||||
The LibAFL repository is composed of multiple crates.
|
||||
|
@ -10,7 +10,7 @@ libafl = { version = "*" }
|
||||
|
||||
## Crate List
|
||||
|
||||
For LibAFL, each crate has its self-contained purpose, and the user may not need to use all of them in its project.
|
||||
For LibAFL, each crate has its self-contained purpose, and the user may not need to use all of them in their project.
|
||||
Following the naming convention of the folders in the project's root, they are:
|
||||
|
||||
### [`libafl`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl)
|
||||
@ -31,20 +31,35 @@ You can choose the features by using `features = ["feature1", "feature2", ...]`
|
||||
Out of this list, by default, `std`, `derive`, and `rand_trait` are already set.
|
||||
You can choose to disable them by setting `default-features = false` in your `Cargo.toml`.
|
||||
|
||||
### libafl_sugar
|
||||
### [`libafl_bolts`](https://github.com/AFLplusplus/LibAFL/tree/main/libafl)
|
||||
|
||||
The `libafl_bolts` crate is a minimal tool shed filled with useful low-level rust features, not necessarily related to fuzzers.
|
||||
In it, you'll find highlights like:
|
||||
|
||||
- `core_affinity` to bind the current process to cores
|
||||
- `SerdeAnyMap` a map that can store typed values in a serializable fashion
|
||||
- `minibsod` to dump the current process state
|
||||
- `LLMP`, "low level message passing", a lock-free IPC mechanism
|
||||
- `Rand`, different fast (non-cryptographically secure) RNG implementations like RomuRand
|
||||
- `ShMem`, a platform independent shard memory implementation
|
||||
- `Tuples`, a compiletime tuple implementation
|
||||
|
||||
... and much more.
|
||||
|
||||
### `libafl_sugar`
|
||||
|
||||
The sugar crate abstracts away most of the complexity of LibAFL's API.
|
||||
Instead of high flexibility, it aims to be high-level and easy-to-use.
|
||||
It is not as flexible as stitching your fuzzer together from each individual component, but allows you to build a fuzzer with minimal lines of code.
|
||||
To see it in action, take a look at the [`libfuzzer_stb_image_sugar` example fuzzer](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/libfuzzer_stb_image_sugar).
|
||||
|
||||
### libafl_derive
|
||||
### `libafl_derive`
|
||||
|
||||
This a proc-macro crate paired with the `libafl` crate.
|
||||
|
||||
At the moment, it just exposes the `derive(SerdeAny)` macro that can be used to define Metadata structs, see the section about [Metadata](../design/metadata.md) for details.
|
||||
|
||||
### libafl_targets
|
||||
### `libafl_targets`
|
||||
|
||||
This crate exposes code to interact with, and to instrument, targets.
|
||||
To enable and disable features at compile-time, the features are enabled and disabled using feature flags.
|
||||
@ -52,36 +67,36 @@ To enable and disable features at compile-time, the features are enabled and dis
|
||||
Currently, the supported flags are:
|
||||
|
||||
- `pcguard_edges` defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges in a map.
|
||||
- `pcguard_hitcounts defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges with the hitcounts (like AFL) in a map.
|
||||
- `pcguard_hitcounts` defines the SanitizerCoverage trace-pc-guard hooks to track the executed edges with the hitcounts (like AFL) in a map.
|
||||
- `libfuzzer` exposes a compatibility layer with libFuzzer style harnesses.
|
||||
- `value_profile` defines the SanitizerCoverage trace-cmp hooks to track the matching bits of each comparison in a map.
|
||||
|
||||
### libafl_cc
|
||||
### `libafl_cc`
|
||||
|
||||
This is a library that provides utils wrap compilers and create source-level fuzzers.
|
||||
This is a library that provides utils to wrap compilers and create source-level fuzzers.
|
||||
|
||||
At the moment, only the Clang compiler is supported.
|
||||
To understand it deeper, look through the tutorials and examples.
|
||||
|
||||
### libafl_frida
|
||||
### `libafl_frida`
|
||||
|
||||
This library bridges LibAFL with Frida as instrumentation backend.
|
||||
With this crate, you can instrument targets on Linux/macOS/Windows/Android for coverage collection.
|
||||
Additionally, it supports CmpLog, and AddressSanitizer instrumentation and runtimes for aarch64.
|
||||
See further information, as well as usage instructions, [later in the book](../advanced_features/frida.md).
|
||||
|
||||
### libafl_qemu
|
||||
### `libafl_qemu`
|
||||
|
||||
This library bridges LibAFL with QEMU user-mode to fuzz ELF cross-platform binaries.
|
||||
|
||||
It works on Linux and can collect edge coverage without collisions!
|
||||
It also supports a wide range of hooks and instrumentation options.
|
||||
|
||||
### libafl_nyx
|
||||
### `libafl_nyx`
|
||||
|
||||
[Nyx](https://nyx-fuzz.com/) is a KVM-based snapshot fuzzer. `libafl_nyx` adds these capabilities to LibAFL. There is a specific section explaining usage of libafl_nyx [later in the book](../advanced_features/nyx.md).
|
||||
|
||||
### libafl_concolic
|
||||
### `libafl_concolic`
|
||||
|
||||
Concolic fuzzing is the combination of fuzzing and a symbolic execution engine.
|
||||
This can reach greater depth than normal fuzzing, and is exposed in this crate.
|
||||
|
@ -11,15 +11,15 @@ The first step is to download LibAFL and all dependencies that are not automatic
|
||||
> previous command. Additionally, PowerShell-specific examples will use `>`
|
||||
> rather than `$`.
|
||||
|
||||
While you technically do not need to install LibAFL, but can use the version from crates.io directly, we do recommend to download or clone the GitHub version.
|
||||
While technically you do not need to install LibAFL, but can use the version from crates.io directly, we do recommend to download or clone the GitHub version.
|
||||
This gets you the example fuzzers, additional utilities, and latest patches.
|
||||
The easiest way to do this is to use `git`.
|
||||
|
||||
```sh
|
||||
$ git clone git@github.com:AFLplusplus/LibAFL.git
|
||||
$ git clone https://github.com/AFLplusplus/LibAFL.git
|
||||
```
|
||||
|
||||
You can alternatively, on a UNIX-like machine, download a compressed archive and extract it with:
|
||||
Alternatively, on a UNIX-like machine, you can download a compressed archive and extract it with:
|
||||
|
||||
```sh
|
||||
wget https://github.com/AFLplusplus/LibAFL/archive/main.tar.gz
|
||||
@ -31,7 +31,7 @@ $ ls LibAFL-main # this is the extracted folder
|
||||
## Clang installation
|
||||
|
||||
One of the external dependencies of LibAFL is the Clang C/C++ compiler.
|
||||
While most of the code is in pure Rust, we still need a C compiler because stable Rust still does not support features that some parts of LibAFL may need, such as weak linking, and LLVM builtins linking.
|
||||
While most of the code is written in pure Rust, we still need a C compiler because stable Rust still does not support features that some parts of LibAFL may need, such as weak linking, and LLVM builtins linking.
|
||||
For these parts, we use C to expose the missing functionalities to our Rust codebase.
|
||||
|
||||
In addition, if you want to perform source-level fuzz testing of C/C++ applications,
|
||||
|
@ -4,10 +4,10 @@ Fuzzers are important tools for security researchers and developers alike.
|
||||
A wide range of state-of-the-art tools like [AFL++](https://github.com/AFLplusplus/AFLplusplus), [libFuzzer](https://llvm.org/docs/LibFuzzer.html) or [honggfuzz](https://github.com/google/honggfuzz) are available to users. They do their job in a very effective way, finding thousands of bugs.
|
||||
|
||||
From the perspective of a power user, however, these tools are limited.
|
||||
Their design does not treat extensibility as a first-class citizen.
|
||||
Their designs do not treat extensibility as a first-class citizen.
|
||||
Usually, a fuzzer developer can choose to either fork one of these existing tools, or to create a new fuzzer from scratch.
|
||||
In any case, researchers end up with tons of fuzzers, all of which are incompatible with each other.
|
||||
Their outstanding features can not just be combined for new projects.
|
||||
Their outstanding features cannot just be combined for new projects.
|
||||
By reinventing the wheel over and over, we may completely miss out on features that are complex to reimplement.
|
||||
|
||||
To tackle this issue, we created LibAFL, a library that is _not just another fuzzer_, but a collection of reusable pieces for individual fuzzers.
|
||||
@ -24,11 +24,11 @@ Some highlight features currently include:
|
||||
This means it does not require a specific OS-dependent runtime to function.
|
||||
Define an allocator and a way to map pages, and you are good to inject LibAFL in obscure targets like embedded devices, hypervisors, or maybe even WebAssembly?
|
||||
- `adaptable`: Given years of experience fine-tuning *AFLplusplus* and our academic fuzzing background, we could incorporate recent fuzzing trends into LibAFL's design and make it future-proof.
|
||||
To give an example, as opposed to old-skool fuzzers, a `BytesInput` is just one of the potential forms of inputs:
|
||||
To give an example, as opposed to old-school fuzzers, a `BytesInput` is just one of the potential forms of inputs:
|
||||
feel free to use and mutate an Abstract Syntax Tree instead, for structured fuzzing.
|
||||
- `scalable`: As part of LibAFL, we developed `Low Level Message Passing`, `LLMP` for short, which allows LibAFL to scale almost linearly over cores. That is, if you chose to use this feature - it is your fuzzer, after all.
|
||||
Scaling to multiple machines over TCP is also possible, using LLMP's `broker2broker` feature.
|
||||
- `fast`: We do everything we can at compile time so that the runtime overhead is as minimal as it can get.
|
||||
- `bring your own target`: We support binary-only modes, like QEMU-Mode and Frida-Mode with ASAN and CmpLog, as well as multiple compilation passes for sourced-based instrumentation.
|
||||
- `bring your own target`: We support binary-only modes, like (full-system) QEMU-Mode and Frida-Mode with ASan and CmpLog, as well as multiple compilation passes for sourced-based instrumentation.
|
||||
Of course, we also support custom instrumentation, as you can see in the Python example based on Google's Atheris.
|
||||
- `usable`: This one is on you to decide. Dig right in!
|
||||
|
@ -1,11 +1,11 @@
|
||||
# The LibAFL Fuzzing Library
|
||||
|
||||
<img align="right" src="https://github.com/AFLplusplus/Website/raw/master/static/logo_256x256.png" alt="AFL++ Logo">
|
||||
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/main/static/libafl_logo.svg" alt="LibAFL Logo" style="width: 256px; height: auto">
|
||||
|
||||
*by Andrea Fioraldi and Dominik Maier*
|
||||
|
||||
Welcome to LibAFL, the Advanced Fuzzing Library.
|
||||
This book shall be a gentle introduction into the library.
|
||||
This book shall be a gentle introduction to the library.
|
||||
|
||||
This version of the LibAFL book is coupled with the release 1.0 beta of the library.
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Configurations for individual fuzzer nodes are relevant for multi node fuzzing.
|
||||
The chapter describes how to run nodes with different configurations
|
||||
in one fuzzing cluster.
|
||||
This allows, for example, a node compiled with ASAN, to know that it needs to rerun new testcases for a node without ASAN, while the same binary/configuration does not.
|
||||
This allows, for example, a node compiled with ASan, to know that it needs to rerun new testcases for a node without ASan, while the same binary/configuration does not.
|
||||
|
||||
Fuzzers with the same configuration can exchange Observers for new testcases and reuse them without rerunning the input.
|
||||
A different configuration indicates, that only the raw input can be exchanged, it must be rerun on the other node to capture relevant observations.
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Message Passing
|
||||
|
||||
LibAFL offers a standard mechanism for message passing over processes and machines with a low overhead.
|
||||
LibAFL offers a standard mechanism for message passing between processes and machines with a low overhead.
|
||||
We use message passing to inform the other connected clients/fuzzers/nodes about new testcases, metadata, and statistics about the current run.
|
||||
Depending on individual needs, LibAFL can also write testcase contents to disk, while still using events to notify other fuzzers, using an `OnDiskCorpus`.
|
||||
Depending on individual needs, LibAFL can also write testcase contents to disk, while still using events to notify other fuzzers, using the `CachedOnDiskCorpus` or similar.
|
||||
|
||||
In our tests, message passing scales very well to share new testcases and metadata between multiple running fuzzer instances for multi-core fuzzing.
|
||||
Specifically, it scales _a lot_ better than using memory locks on a shared corpus, and _a lot_ better than sharing the testcases via the filesystem, as AFL traditionally does.
|
||||
@ -12,7 +12,7 @@ The `EventManager` interface is used to send Events over the wire using `Low Lev
|
||||
|
||||
## Low Level Message Passing (LLMP)
|
||||
|
||||
LibAFL comes with a reasonably lock-free message passing mechanism that scales well across cores and, using its *broker2broker* mechanism, even to connected machines via TCP.
|
||||
LibAFL comes with a reasonably lock-free message passing mechanism that scales well across cores and, using its _broker2broker_ mechanism, even to connected machines via TCP.
|
||||
Most example fuzzers use this mechanism, and it is the best `EventManager` if you want to fuzz on more than a single core.
|
||||
In the following, we will describe the inner workings of `LLMP`.
|
||||
|
||||
@ -28,12 +28,12 @@ Shared maps, called shared memory for the sake of not colliding with Rust's `map
|
||||
Each client, usually a fuzzer trying to share stats and new testcases, maps an outgoing `ShMem` map.
|
||||
With very few exceptions, only this client writes to this map, therefore, we do not run in race conditions and can live without locks.
|
||||
The broker reads from all client's `ShMem` maps.
|
||||
It checks all incoming client maps periodically and then forwards new messages to its outgoing broadcast-`ShMem`, mapped by all connected clients.
|
||||
It periodically checks all incoming client maps and then forwards new messages to its outgoing broadcast-`ShMem`, mapped by all connected clients.
|
||||
|
||||
To send new messages, a client places a new message at the end of their shared memory and then updates a static field to notify the broker.
|
||||
Once the outgoing map is full, the sender allocates a new `ShMem` using the respective `ShMemProvider`.
|
||||
It then sends the information needed to map the newly-allocated page in connected processes to the old page, using an end of page (`EOP`) message.
|
||||
Once the receiver maps the new page, flags it as safe for unmapping from the sending process (to avoid race conditions if we have more than a single EOP in a short time), and then continues to read from the new `ShMem`.
|
||||
Once the receiver maps the new page, it flags it as safe for unmapping by the sending process (to avoid race conditions if we have more than a single EOP in a short time), and then continues to read from the new `ShMem`.
|
||||
|
||||
The schema for client's maps to the broker is as follows:
|
||||
|
||||
@ -54,10 +54,10 @@ After the broker received a new message from clientN, (`clientN_out->current_id
|
||||
|
||||
The clients periodically, for example after finishing `n` mutations, check for new incoming messages by checking if (`current_broadcast_map->current_id != last_message->message_id`).
|
||||
While the broker uses the same EOP mechanism to map new `ShMem`s for its outgoing map, it never unmaps old pages.
|
||||
This additional memory overhead serves a good purpose: by keeping all broadcast pages around, we make sure that new clients can join in on a fuzzing campaign at a later point in time
|
||||
This additional memory resources serve a good purpose: by keeping all broadcast pages around, we make sure that new clients can join in on a fuzzing campaign at a later point in time.
|
||||
They just need to re-read all broadcasted messages from start to finish.
|
||||
|
||||
So the outgoing messages flow like this over the outgoing broadcast `Shmem`:
|
||||
So the outgoing messages flow is like this over the outgoing broadcast `Shmem`:
|
||||
|
||||
```text
|
||||
[broker]
|
||||
|
@ -4,18 +4,18 @@ Multiple fuzzer instances can be spawned using different ways.
|
||||
|
||||
## Manually, via a TCP port
|
||||
|
||||
The straightforward way to do Multi-Threading is to use the `LlmpRestartingEventManager`, specifically to use `setup_restarting_mgr_std`.
|
||||
The straightforward way to do Multi-Threading is to use the [`LlmpRestartingEventManager`](https://docs.rs/libafl/latest/libafl/events/llmp/struct.LlmpRestartingEventManager.html), specifically to use [`setup_restarting_mgr_std`](https://docs.rs/libafl/latest/libafl/events/llmp/fn.setup_restarting_mgr_std.html).
|
||||
It abstracts away all the pesky details about restarts on crash handling (for in-memory fuzzers) and multi-threading.
|
||||
With it, every instance you launch manually tries to connect to a TCP port on the local machine.
|
||||
|
||||
If the port is not yet bound, this instance becomes the broker, itself binding to the port to await new clients.
|
||||
If the port is not yet bound, this instance becomes the broker, binding itself to the port to await new clients.
|
||||
|
||||
If the port is already bound, the EventManager will try to connect to it.
|
||||
The instance becomes a client and can now communicate with all other nodes.
|
||||
|
||||
Launching nodes manually has the benefit that you can have multiple nodes with different configurations, such as clients fuzzing with and without ASAN.
|
||||
Launching nodes manually has the benefit that you can have multiple nodes with different configurations, such as clients fuzzing with and without `ASan``.
|
||||
|
||||
While it's called "restarting" manager, it uses `fork` on Unix operating systems as optimization and only actually restarts from scratch on Windows.
|
||||
While it's called "restarting" manager, it uses `fork` on Unix-like operating systems as optimization and only actually restarts from scratch on Windows.
|
||||
|
||||
|
||||
## Automated, with Launcher
|
||||
@ -23,7 +23,7 @@ While it's called "restarting" manager, it uses `fork` on Unix operating systems
|
||||
The Launcher is the lazy way to do multiprocessing.
|
||||
You can use the Launcher builder to create a fuzzer that spawns multiple nodes with one click, all using restarting event managers and the same configuration.
|
||||
|
||||
To use launcher, first you need to write an anonymous function `let mut run_client = |state: Option<_>, mut mgr, _core_id|{}`, which uses three parameters to create individual fuzzer. Then you can specify the `shmem_provider`,`broker_port`,`monitor`,`cores` and other stuff through `Launcher::builder()`:
|
||||
To use launcher, first you need to write an anonymous function `let mut run_client = |state: Option<_>, mut mgr, _core_id|{}`, which uses three parameters to create an individual fuzzer. Then you can specify the `shmem_provider`,`broker_port`,`monitor`,`cores` and other stuff through `Launcher::builder()`:
|
||||
|
||||
```rust,ignore
|
||||
Launcher::builder()
|
||||
@ -42,13 +42,17 @@ To use launcher, first you need to write an anonymous function `let mut run_clie
|
||||
This first starts a broker, then spawns `n` clients, according to the value passed to `cores`.
|
||||
The value is a string indicating the cores to bind to, for example, `0,2,5` or `0-3`.
|
||||
For each client, `run_client` will be called.
|
||||
On Windows, the Launcher will restart each client, while on Unix, it will use `fork`.
|
||||
If the launcher uses `fork`, it will hide child output, unless the settings indicate otherwise, or the `LIBAFL_DEBUG_OUTPUT` env variable is set.
|
||||
On Windows, the Launcher will restart each client, while on Unix-alikes, it will use `fork`.
|
||||
|
||||
Advanced use-cases:
|
||||
|
||||
1. To connect multiple nodes together via TCP, you can use the `remote_broker_addr`. this requires the `llmp_bind_public` compile-time feature for `LibAFL`.
|
||||
2. To use multiple launchers for individual configurations, you can set `spawn_broker` to `false` on all but one.
|
||||
2. To use multiple launchers for individual configurations, you can set `spawn_broker` to `false` on all instances but one.
|
||||
3. Launcher will not select the cores automatically, so you need to specify the `cores` that you want.
|
||||
4. On `Unix`, you can chose between a forking and non-forking version of Launcher by setting the `fork` feature in LibAFL. Some targets may not like forking, but it is faster than restarting processes from scratch. Windows will never fork.
|
||||
5. For simple debugging, first set the `LIBAFL_DEBUG_OUTPUT` env variable to see if a child process printed anything.
|
||||
6. For further debugging of fuzzer failures, it may make sense to replace `Launcher` temporarily with a [`SimpleEventManager`](https://docs.rs/libafl/latest/libafl/events/simple/struct.SimpleEventManager.html#method.new) and call your harness fn (`run_client(None, mgr, 0);`) directly, so that fuzzing runs in the same thread and is easier to debug, before moving back to `Launcher` after the bugfix.
|
||||
|
||||
For more examples, you can check out `qemu_launcher` and `libfuzzer_libpng_launcher` in [`./fuzzers/`](https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers).
|
||||
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
In this chapter, we will build a custom fuzzer using the [Lain](https://github.com/microsoft/lain) mutator in Rust.
|
||||
|
||||
This tutorial will introduce you in writing extensions to LibAFL like Feedbacks and Testcase's metadata.
|
||||
This tutorial will introduce you to writing extensions to LibAFL like Feedbacks and Testcase's metadata.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer"
|
||||
version = "0.7.1"
|
||||
version = "0.10.0"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -21,3 +21,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
|
@ -5,4 +5,6 @@ This is a minimalistic example about how to create a libafl based fuzzer.
|
||||
It runs on a single core until a crash occurs and then exits.
|
||||
|
||||
The tested program is a simple Rust function without any instrumentation.
|
||||
For real fuzzing, you will want to add some sort to add coverage or other feedback.
|
||||
For real fuzzing, you will want to add some sort to add coverage or other feedback.
|
||||
|
||||
You can run this example using `cargo run`, and you can enable the TUI feature by running `cargo run --features tui`.
|
@ -4,67 +4,86 @@ from pylibafl import libafl
|
||||
|
||||
def map_observer_wrapper(map_observer):
|
||||
if type(map_observer).__name__ == "OwnedMapObserverI32":
|
||||
return libafl.MapObserverI32.new_from_owned(map_observer)
|
||||
return libafl.MapObserverI32.new_owned(map_observer)
|
||||
|
||||
def executor_wrapper(executor):
|
||||
if type(executor).__name__ == "OwnedInProcessExecutorI32":
|
||||
return libafl.ExecutorI32.new_from_inprocess(executor)
|
||||
if type(executor).__name__ == "InProcessExecutor":
|
||||
return libafl.Executor.new_inprocess(executor)
|
||||
|
||||
def generator_wrapper(generator):
|
||||
if type(generator).__name__ == "RandPrintablesGenerator":
|
||||
return libafl.Generator.new_rand_printables(generator)
|
||||
|
||||
def monitor_wrapper(monitor):
|
||||
if type(monitor).__name__ == "SimpleMonitor":
|
||||
return libafl.Monitor.new_from_simple(monitor)
|
||||
return monitor.as_monitor()
|
||||
|
||||
def event_manager_wrapper(event_manager):
|
||||
if type(event_manager).__name__ == "SimpleEventManager":
|
||||
return libafl.EventManagerI32.new_from_simple(event_manager)
|
||||
return event_manager.as_manager()
|
||||
|
||||
def corpus_wrapper(corpus):
|
||||
if type(corpus).__name__ == "InMemoryCorpus":
|
||||
return libafl.Corpus.new_from_in_memory(corpus)
|
||||
return libafl.Corpus.new_in_memory(corpus)
|
||||
if type(corpus).__name__ == "OnDiskCorpus":
|
||||
return libafl.Corpus.new_from_on_disk(corpus)
|
||||
return libafl.Corpus.new_on_disk(corpus)
|
||||
|
||||
def rand_wrapper(rand):
|
||||
if type(rand).__name__ == "StdRand":
|
||||
return libafl.Rand.new_from_std(rand)
|
||||
return libafl.Rand.new_std(rand)
|
||||
|
||||
def mutator_wrapper(mutator):
|
||||
if type(mutator).__name__ == "StdHavocMutator":
|
||||
return libafl.Mutator.new_std_havoc(mutator)
|
||||
|
||||
def stage_wrapper(stage):
|
||||
if type(stage).__name__ == "StdScheduledHavocMutationsStageI32":
|
||||
return libafl.StageI32.new_from_std_scheduled(stage)
|
||||
if type(stage).__name__ == "StdMutationalStage":
|
||||
return libafl.Stage.new_std_mutational(stage)
|
||||
|
||||
# CODE WRITTEN BY USER
|
||||
|
||||
def harness(inp):
|
||||
if len(inp.hex()) >= 2 and inp.hex()[:2] == '61':
|
||||
raise Exception("NOOOOOO =)")
|
||||
import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
map_observer = libafl.OwnedMapObserverI32("signals", [0] * 16)
|
||||
|
||||
feedback_state = libafl.MapFeedbackStateI32.with_observer(map_observer_wrapper(map_observer))
|
||||
def harness(inp):
|
||||
#print(inp)
|
||||
map_observer[0] = 1
|
||||
if len(inp) > 0 and inp[0] == ord('a'):
|
||||
map_observer[1] = 1
|
||||
if len(inp) > 1 and inp[1] == ord('b'):
|
||||
map_observer[2] = 1
|
||||
if len(inp) > 2 and inp[2] == ord('c'):
|
||||
map_observer[3] = 1
|
||||
raise Exception("NOOOOOO =)")
|
||||
|
||||
feedback = libafl.MaxMapFeedbackI32(feedback_state, map_observer_wrapper(map_observer))
|
||||
feedback = libafl.MaxMapFeedbackI32(map_observer_wrapper(map_observer))
|
||||
objective = libafl.CrashFeedback()
|
||||
|
||||
state = libafl.StdStateI32(
|
||||
state = libafl.StdState(
|
||||
rand_wrapper(libafl.StdRand.with_current_nanos()),
|
||||
corpus_wrapper(libafl.InMemoryCorpus()),
|
||||
corpus_wrapper(libafl.OnDiskCorpus("./crashes")),
|
||||
feedback_state
|
||||
feedback.as_feedback(),
|
||||
objective.as_feedback(),
|
||||
)
|
||||
|
||||
monitor = libafl.SimpleMonitor()
|
||||
monitor = libafl.SimpleMonitor(lambda x: print(x))
|
||||
|
||||
mgr = libafl.SimpleEventManager(monitor_wrapper(monitor))
|
||||
|
||||
fuzzer = libafl.StdFuzzerI32(feedback)
|
||||
fuzzer = libafl.StdFuzzer(feedback.as_feedback(), objective.as_feedback())
|
||||
|
||||
executor = libafl.OwnedInProcessExecutorI32(harness, map_observer_wrapper(map_observer), fuzzer, state, event_manager_wrapper(mgr))
|
||||
observers = libafl.ObserversTuple([libafl.Observer.new_map_i32(map_observer_wrapper(map_observer))])
|
||||
|
||||
generator = libafl.RandPrintablesGeneratorI32(32)
|
||||
executor = libafl.InProcessExecutor(harness, observers, fuzzer, state, event_manager_wrapper(mgr))
|
||||
|
||||
state.generate_initial_inputs(fuzzer, executor_wrapper(executor), generator, event_manager_wrapper(mgr), 8)
|
||||
generator = libafl.RandPrintablesGenerator(32)
|
||||
|
||||
stage = libafl.StdScheduledHavocMutationsStageI32.new_from_scheduled_havoc_mutations()
|
||||
state.generate_initial_inputs(fuzzer, executor_wrapper(executor), generator_wrapper(generator), event_manager_wrapper(mgr), 3)
|
||||
|
||||
stage_tuple_list = libafl.StagesOwnedListI32(stage_wrapper(stage))
|
||||
mutator = libafl.StdHavocMutator()
|
||||
|
||||
fuzzer.fuzz_loop(executor_wrapper(executor), state, event_manager_wrapper(mgr), stage_tuple_list)
|
||||
stage = libafl.StdMutationalStage(mutator_wrapper(mutator))
|
||||
|
||||
stages = libafl.StagesTuple([stage_wrapper(stage)])
|
||||
|
||||
fuzzer.fuzz_loop(executor_wrapper(executor), state, event_manager_wrapper(mgr), stages)
|
||||
|
@ -1,13 +1,12 @@
|
||||
use std::path::PathBuf;
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{path::PathBuf, ptr::write};
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
use libafl::monitors::tui::TuiMonitor;
|
||||
use libafl::monitors::tui::{ui::TuiUI, TuiMonitor};
|
||||
#[cfg(not(feature = "tui"))]
|
||||
use libafl::monitors::SimpleMonitor;
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
@ -21,16 +20,18 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
|
||||
#[allow(clippy::similar_names)]
|
||||
#[allow(clippy::similar_names, clippy::manual_assert)]
|
||||
pub fn main() {
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
@ -60,8 +61,7 @@ pub fn main() {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer =
|
||||
unsafe { StdMapObserver::new_from_ptr("signals", SIGNALS.as_mut_ptr(), SIGNALS.len()) };
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
@ -88,9 +88,11 @@ pub fn main() {
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
#[cfg(not(feature = "tui"))]
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::new(String::from("Baby Fuzzer"), false);
|
||||
let ui = TuiUI::with_version(String::from("Baby Fuzzer"), String::from("0.0.1"), false);
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::new(ui);
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_gramatron"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -20,4 +20,5 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
postcard = "0.7"
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
postcard = { version = "1.0", features = ["alloc"], default-features = false } # no_std compatible serde serialization format
|
@ -7,7 +7,6 @@ use std::{
|
||||
};
|
||||
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
@ -25,13 +24,15 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
/*
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { std::ptr::write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
*/
|
||||
|
||||
@ -57,7 +58,7 @@ pub fn main() {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
@ -83,7 +84,7 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let monitor = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
@ -122,7 +123,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
let mut set = HashSet::new();
|
||||
let st = libafl::bolts::current_milliseconds();
|
||||
let st = libafl_bolts::current_milliseconds();
|
||||
let mut b = vec![];
|
||||
let mut c = 0;
|
||||
for _ in 0..100000 {
|
||||
@ -131,7 +132,7 @@ pub fn main() {
|
||||
set.insert(calculate_hash(&b));
|
||||
c += b.len();
|
||||
}
|
||||
println!("{} / {}", c, libafl::bolts::current_milliseconds() - st);
|
||||
println!("{} / {}", c, libafl_bolts::current_milliseconds() - st);
|
||||
println!("{} / 100000", set.len());
|
||||
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_grimoire"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -20,3 +20,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
|
@ -1,15 +1,14 @@
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{fs, io::Read, path::PathBuf};
|
||||
use std::{fs, io::Read, path::PathBuf, ptr::write};
|
||||
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
feedbacks::{CrashFeedback, MaxMapFeedback},
|
||||
fuzzer::{Evaluator, Fuzzer, StdFuzzer},
|
||||
inputs::{GeneralizedInput, HasTargetBytes},
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
mutators::{
|
||||
havoc_mutations, scheduled::StdScheduledMutator, GrimoireExtensionMutator,
|
||||
@ -21,13 +20,14 @@ use libafl::{
|
||||
stages::{mutational::StdMutationalStage, GeneralizationStage},
|
||||
state::{HasMetadata, StdState},
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
|
||||
fn is_sub<T: PartialEq>(mut haystack: &[T], needle: &[T]) -> bool {
|
||||
@ -59,13 +59,13 @@ pub fn main() {
|
||||
let mut file = fs::File::open(path).expect("no file found");
|
||||
let mut buffer = vec![];
|
||||
file.read_to_end(&mut buffer).expect("buffer overflow");
|
||||
let input = GeneralizedInput::new(buffer);
|
||||
let input = BytesInput::new(buffer);
|
||||
initial_inputs.push(input);
|
||||
}
|
||||
}
|
||||
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &GeneralizedInput| {
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target_bytes = input.target_bytes();
|
||||
let bytes = target_bytes.as_slice();
|
||||
|
||||
@ -77,21 +77,14 @@ pub fn main() {
|
||||
signals_set(3);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
if input.grimoire_mutated {
|
||||
// println!(">>> {:?}", input.generalized());
|
||||
println!(">>> {:?}", std::str::from_utf8_unchecked(bytes));
|
||||
}
|
||||
}
|
||||
signals_set(1);
|
||||
ExitKind::Ok
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new_tracking(&observer, false, true);
|
||||
let mut feedback = MaxMapFeedback::tracking(&observer, false, true);
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
@ -113,12 +106,12 @@ pub fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
if state.metadata().get::<Tokens>().is_none() {
|
||||
if state.metadata_map().get::<Tokens>().is_none() {
|
||||
state.add_metadata(Tokens::from([b"FOO".to_vec(), b"BAR".to_vec()]));
|
||||
}
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let monitor = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
@ -158,7 +151,7 @@ pub fn main() {
|
||||
let mut stages = tuple_list!(
|
||||
generalization,
|
||||
StdMutationalStage::new(mutator),
|
||||
StdMutationalStage::new(grimoire_mutator)
|
||||
StdMutationalStage::transforming(grimoire_mutator)
|
||||
);
|
||||
|
||||
for input in initial_inputs {
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_minimizing"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>", "Addison Crump <research@addisoncrump.info>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -21,3 +21,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/", features = ["prelude"] }
|
||||
libafl_bolts = { path = "../../libafl_bolts/", features = ["prelude"] }
|
||||
|
@ -1,15 +1,17 @@
|
||||
use std::path::PathBuf;
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{path::PathBuf, ptr::write};
|
||||
|
||||
use libafl::prelude::*;
|
||||
use libafl_bolts::prelude::*;
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
|
||||
#[allow(clippy::similar_names)]
|
||||
@ -32,10 +34,9 @@ pub fn main() -> Result<(), Error> {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer =
|
||||
unsafe { StdMapObserver::new_from_ptr("signals", SIGNALS.as_mut_ptr(), SIGNALS.len()) };
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
let factory = MapEqualityFactory::new_from_observer(&observer);
|
||||
let factory = MapEqualityFactory::with_observer(&observer);
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
@ -44,7 +45,7 @@ pub fn main() -> Result<(), Error> {
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
|
||||
@ -56,7 +57,7 @@ pub fn main() -> Result<(), Error> {
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
OnDiskCorpus::new(&corpus_dir).unwrap(),
|
||||
InMemoryOnDiskCorpus::new(&corpus_dir).unwrap(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(&solution_dir).unwrap(),
|
||||
@ -108,7 +109,7 @@ pub fn main() -> Result<(), Error> {
|
||||
|
||||
let mut state = StdState::new(
|
||||
StdRand::with_seed(current_nanos()),
|
||||
OnDiskCorpus::new(&minimized_dir).unwrap(),
|
||||
InMemoryOnDiskCorpus::new(minimized_dir).unwrap(),
|
||||
InMemoryCorpus::new(),
|
||||
&mut (),
|
||||
&mut (),
|
||||
@ -116,7 +117,7 @@ pub fn main() -> Result<(), Error> {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
|
||||
@ -136,7 +137,13 @@ pub fn main() -> Result<(), Error> {
|
||||
let mut executor = InProcessExecutor::new(&mut harness, (), &mut fuzzer, &mut state, &mut mgr)?;
|
||||
|
||||
state.load_initial_inputs_forced(&mut fuzzer, &mut executor, &mut mgr, &[solution_dir])?;
|
||||
stages.perform_all(&mut fuzzer, &mut executor, &mut state, &mut mgr, 0)?;
|
||||
stages.perform_all(
|
||||
&mut fuzzer,
|
||||
&mut executor,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
CorpusId::from(0_usize),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_nautilus"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@ -20,3 +20,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/", features = ["default", "nautilus"] }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
|
@ -3,7 +3,6 @@ use std::path::PathBuf;
|
||||
use std::ptr::write_volatile;
|
||||
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
@ -21,13 +20,15 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::{HasMetadata, StdState},
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
/*
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { str::ptr::write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
*/
|
||||
|
||||
@ -46,7 +47,7 @@ pub fn main() {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = feedback_or!(
|
||||
@ -74,12 +75,16 @@ pub fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
if state.metadata().get::<NautilusChunksMetadata>().is_none() {
|
||||
if state
|
||||
.metadata_map()
|
||||
.get::<NautilusChunksMetadata>()
|
||||
.is_none()
|
||||
{
|
||||
state.add_metadata(NautilusChunksMetadata::new("/tmp/".into()));
|
||||
}
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let monitor = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
@ -117,7 +122,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
let mut set = HashSet::new();
|
||||
let st = libafl::bolts::current_milliseconds();
|
||||
let st = libafl_bolts::current_milliseconds();
|
||||
let mut b = vec![];
|
||||
let mut c = 0;
|
||||
for _ in 0..100000 {
|
||||
@ -126,7 +131,7 @@ pub fn main() {
|
||||
set.insert(calculate_hash(&b));
|
||||
c += b.len();
|
||||
}
|
||||
println!("{} / {}", c, libafl::bolts::current_milliseconds() - st);
|
||||
println!("{} / {}", c, libafl_bolts::current_milliseconds() - st);
|
||||
println!("{} / 100000", set.len());
|
||||
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_swap_differential"
|
||||
version = "0.7.1"
|
||||
version = "0.11.2"
|
||||
authors = ["Addison Crump <research@addisoncrump.info>"]
|
||||
edition = "2021"
|
||||
default-run = "fuzzer_sd"
|
||||
@ -21,11 +21,12 @@ debug = true
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1"
|
||||
bindgen = "0.61"
|
||||
bindgen = "0.63"
|
||||
cc = "1.0"
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl" }
|
||||
libafl_bolts = { path = "../../libafl_bolts" }
|
||||
libafl_targets = { path = "../../libafl_targets", features = ["sancov_pcguard_hitcounts", "libfuzzer", "sancov_cmplog", "pointer_maps"] }
|
||||
mimalloc = { version = "*", default-features = false }
|
||||
|
||||
|
@ -1,25 +1,27 @@
|
||||
# Variables
|
||||
[env]
|
||||
FUZZER_NAME='fuzzer_sd'
|
||||
CARGO_TARGET_DIR = { value = "target", condition = { env_not_set = ["CARGO_TARGET_DIR"] } }
|
||||
LIBAFL_CC = '${CARGO_TARGET_DIR}/release/libafl_cc'
|
||||
FUZZER = '${CARGO_TARGET_DIR}/release/${FUZZER_NAME}'
|
||||
PROJECT_DIR = { script = ["pwd"] }
|
||||
CARGO_TARGET_DIR = { value = "target", condition = { env_not_set = ["CARGO_TARGET_DIR"] } }
|
||||
PROFILE = { value = "release" }
|
||||
PROFILE_DIR = {value = "release" }
|
||||
LIBAFL_CC = '${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cc'
|
||||
FUZZER = '${CARGO_TARGET_DIR}/${PROFILE_DIR}/${FUZZER_NAME}'
|
||||
|
||||
# Compilers
|
||||
[tasks.cc]
|
||||
command = "cargo"
|
||||
args = ["build" , "--release", "--bin", "libafl_cc"]
|
||||
args = ["build" , "--profile", "${PROFILE}", "--bin", "libafl_cc"]
|
||||
|
||||
# Harness
|
||||
[tasks.fuzzer]
|
||||
command = "cargo"
|
||||
args = ["build" , "--release", "--bin", "${FUZZER_NAME}"]
|
||||
args = ["build" , "--profile", "${PROFILE}", "--bin", "${FUZZER_NAME}"]
|
||||
dependencies = [ "cc" ]
|
||||
|
||||
# Run the fuzzer
|
||||
[tasks.run]
|
||||
command = "${CARGO_TARGET_DIR}/release/${FUZZER_NAME}"
|
||||
command = "${CARGO_TARGET_DIR}/${PROFILE_DIR}/${FUZZER_NAME}"
|
||||
dependencies = [ "fuzzer" ]
|
||||
|
||||
# Test
|
||||
@ -31,7 +33,13 @@ windows_alias = "unsupported"
|
||||
[tasks.test_unix]
|
||||
script_runner = "@shell"
|
||||
script='''
|
||||
timeout 10s ${CARGO_TARGET_DIR}/release/${FUZZER_NAME}
|
||||
timeout 30s ${CARGO_TARGET_DIR}/${PROFILE_DIR}/${FUZZER_NAME} >fuzz_stdout.log || true
|
||||
if [ -z "$(grep "objectives: 1" fuzz_stdout.log)" ]; then
|
||||
echo "Fuzzer does not generate any testcases or any crashes"
|
||||
exit 1
|
||||
else
|
||||
echo "Fuzzer is working"
|
||||
fi
|
||||
'''
|
||||
dependencies = [ "fuzzer" ]
|
||||
|
||||
|
@ -27,9 +27,7 @@ fn main() -> anyhow::Result<()> {
|
||||
})
|
||||
.join("release/libafl_cc");
|
||||
println!("cargo:rerun-if-changed={}", compiler.to_str().unwrap());
|
||||
if !compiler.try_exists().unwrap_or(false) {
|
||||
println!("cargo:warning=Can't find libafl_cc; assuming that we're building it.");
|
||||
} else {
|
||||
if compiler.try_exists().unwrap_or(false) {
|
||||
cc::Build::new()
|
||||
.compiler(compiler)
|
||||
.file("first.c")
|
||||
@ -38,6 +36,8 @@ fn main() -> anyhow::Result<()> {
|
||||
.compile("diff-target");
|
||||
|
||||
println!("cargo:rustc-link-lib=diff-target");
|
||||
} else {
|
||||
println!("cargo:warning=Can't find libafl_cc; assuming that we're building it.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
bool both_require(const uint8_t *bytes, size_t len) {
|
||||
if (len >= 1 && bytes[0] == 'a') {
|
||||
if (len >= 2 && bytes[1] == 'b') {
|
||||
if (len >= 3 && bytes[2] == 'c') {
|
||||
return ACCEPT;
|
||||
}
|
||||
if (len >= 3 && bytes[2] == 'c') { return ACCEPT; }
|
||||
}
|
||||
}
|
||||
return REJECT;
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
bool inspect_first(const uint8_t *bytes, size_t len) {
|
||||
if (both_require(bytes, len)) {
|
||||
if (len >= 4 && bytes[3] == 'd') {
|
||||
return ACCEPT;
|
||||
}
|
||||
if (len >= 4 && bytes[3] == 'd') { return ACCEPT; }
|
||||
}
|
||||
return REJECT;
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
bool inspect_second(const uint8_t *bytes, size_t len) {
|
||||
if (both_require(bytes, len)) {
|
||||
if (len >= 5 && bytes[4] == 'e') {
|
||||
return ACCEPT;
|
||||
}
|
||||
if (len >= 5 && bytes[4] == 'e') { return ACCEPT; }
|
||||
}
|
||||
return REJECT;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use std::env;
|
||||
|
||||
use libafl_cc::{ClangWrapper, CompilerWrapper};
|
||||
use libafl_cc::{ClangWrapper, CompilerWrapper, ToolWrapper};
|
||||
|
||||
pub fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
@ -11,7 +11,7 @@ pub fn main() {
|
||||
let is_cpp = match wrapper_name[wrapper_name.len()-2..].to_lowercase().as_str() {
|
||||
"cc" => false,
|
||||
"++" | "pp" | "xx" => true,
|
||||
_ => panic!("Could not figure out if c or c++ wrapper was called. Expected {:?} to end with c or cxx", dir),
|
||||
_ => panic!("Could not figure out if c or c++ wrapper was called. Expected {dir:?} to end with c or cxx"),
|
||||
};
|
||||
|
||||
dir.pop();
|
||||
|
@ -6,12 +6,11 @@ use std::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
use libafl::monitors::tui::TuiMonitor;
|
||||
use libafl::monitors::tui::{ui::TuiUI, TuiMonitor};
|
||||
#[cfg(not(feature = "tui"))]
|
||||
use libafl::monitors::SimpleMonitor;
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
|
||||
corpus::{Corpus, InMemoryCorpus, OnDiskCorpus},
|
||||
corpus::{Corpus, InMemoryCorpus, InMemoryOnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, DiffExecutor, ExitKind},
|
||||
feedbacks::{CrashFeedback, MaxMapFeedback},
|
||||
@ -24,18 +23,22 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::{HasSolutions, StdState},
|
||||
};
|
||||
use libafl_targets::{DifferentialAFLMapSwapObserver, MAX_EDGES_NUM};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
use libafl_targets::{edges_max_num, DifferentialAFLMapSwapObserver};
|
||||
#[cfg(not(miri))]
|
||||
use mimalloc::MiMalloc;
|
||||
|
||||
#[global_allocator]
|
||||
#[cfg(not(miri))]
|
||||
static GLOBAL: MiMalloc = MiMalloc;
|
||||
|
||||
// bindings to the functions defined in the target
|
||||
mod bindings {
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(unused)]
|
||||
|
||||
#![allow(clippy::unreadable_literal)]
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
}
|
||||
|
||||
@ -44,24 +47,22 @@ use bindings::{inspect_first, inspect_second};
|
||||
#[cfg(feature = "multimap")]
|
||||
mod multimap {
|
||||
pub use libafl::observers::{HitcountsIterableMapObserver, MultiMapObserver};
|
||||
|
||||
pub static mut FIRST_EDGES: &'static mut [u8] = &mut [];
|
||||
pub static mut SECOND_EDGES: &'static mut [u8] = &mut [];
|
||||
pub static mut COMBINED_EDGES: [&'static mut [u8]; 2] = [&mut [], &mut []];
|
||||
pub use libafl_bolts::ownedref::OwnedMutSlice;
|
||||
}
|
||||
#[cfg(feature = "multimap")]
|
||||
use multimap::*;
|
||||
use multimap::{HitcountsIterableMapObserver, MultiMapObserver, OwnedMutSlice};
|
||||
|
||||
#[cfg(not(feature = "multimap"))]
|
||||
mod slicemap {
|
||||
pub use libafl::observers::HitcountsMapObserver;
|
||||
|
||||
pub static mut EDGES: &'static mut [u8] = &mut [];
|
||||
pub static mut EDGES: &mut [u8] = &mut [];
|
||||
}
|
||||
#[cfg(not(feature = "multimap"))]
|
||||
use slicemap::*;
|
||||
use slicemap::{HitcountsMapObserver, EDGES};
|
||||
|
||||
#[allow(clippy::similar_names)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn main() {
|
||||
// The closure that we want to fuzz
|
||||
let mut first_harness = |input: &BytesInput| {
|
||||
@ -83,19 +84,35 @@ pub fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let num_edges: usize = edges_max_num();
|
||||
|
||||
#[cfg(feature = "multimap")]
|
||||
let (first_map_observer, second_map_observer, map_swapper, map_observer) = {
|
||||
let (
|
||||
first_map_observer,
|
||||
second_map_observer,
|
||||
map_swapper,
|
||||
map_observer,
|
||||
layout,
|
||||
first_edges,
|
||||
second_edges,
|
||||
) = {
|
||||
// initialize the maps
|
||||
unsafe {
|
||||
let layout = Layout::from_size_align(MAX_EDGES_NUM, 64).unwrap();
|
||||
FIRST_EDGES = core::slice::from_raw_parts_mut(alloc_zeroed(layout), MAX_EDGES_NUM);
|
||||
SECOND_EDGES = core::slice::from_raw_parts_mut(alloc_zeroed(layout), MAX_EDGES_NUM);
|
||||
COMBINED_EDGES = [&mut FIRST_EDGES, &mut SECOND_EDGES];
|
||||
}
|
||||
let layout = Layout::from_size_align(num_edges, 64).unwrap();
|
||||
let first_edges = unsafe { (alloc_zeroed(layout), num_edges) };
|
||||
let second_edges = unsafe { (alloc_zeroed(layout), num_edges) };
|
||||
|
||||
let combined_edges = unsafe {
|
||||
vec![
|
||||
OwnedMutSlice::from_raw_parts_mut(first_edges.0, first_edges.1),
|
||||
OwnedMutSlice::from_raw_parts_mut(second_edges.0, second_edges.1),
|
||||
]
|
||||
};
|
||||
|
||||
// create the base maps used to observe the different executors from two independent maps
|
||||
let mut first_map_observer = StdMapObserver::new("first-edges", unsafe { FIRST_EDGES });
|
||||
let mut second_map_observer = StdMapObserver::new("second-edges", unsafe { SECOND_EDGES });
|
||||
let mut first_map_observer =
|
||||
unsafe { StdMapObserver::from_mut_ptr("first-edges", first_edges.0, first_edges.1) };
|
||||
let mut second_map_observer =
|
||||
unsafe { StdMapObserver::from_mut_ptr("second-edges", second_edges.0, second_edges.1) };
|
||||
|
||||
// create a map swapper so that we can replace the coverage map pointer (requires feature pointer_maps!)
|
||||
let map_swapper =
|
||||
@ -106,28 +123,35 @@ pub fn main() {
|
||||
// differential mode
|
||||
let map_observer = HitcountsIterableMapObserver::new(MultiMapObserver::differential(
|
||||
"combined-edges",
|
||||
unsafe { &mut COMBINED_EDGES },
|
||||
combined_edges,
|
||||
));
|
||||
|
||||
(
|
||||
first_map_observer,
|
||||
second_map_observer,
|
||||
map_swapper,
|
||||
map_observer,
|
||||
layout,
|
||||
first_edges,
|
||||
second_edges,
|
||||
)
|
||||
};
|
||||
#[cfg(not(feature = "multimap"))]
|
||||
let (first_map_observer, second_map_observer, map_swapper, map_observer) = {
|
||||
// initialize the map
|
||||
unsafe {
|
||||
let layout = Layout::from_size_align(MAX_EDGES_NUM * 2, 64).unwrap();
|
||||
EDGES = core::slice::from_raw_parts_mut(alloc_zeroed(layout), MAX_EDGES_NUM * 2);
|
||||
let layout = Layout::from_size_align(num_edges * 2, 64).unwrap();
|
||||
EDGES = core::slice::from_raw_parts_mut(alloc_zeroed(layout), num_edges * 2);
|
||||
}
|
||||
|
||||
let edges_ptr = unsafe { EDGES.as_mut_ptr() };
|
||||
|
||||
// create the base maps used to observe the different executors by splitting a slice
|
||||
let mut first_map_observer =
|
||||
StdMapObserver::new("first-edges", unsafe { &mut EDGES[..MAX_EDGES_NUM] });
|
||||
let mut second_map_observer =
|
||||
StdMapObserver::new("second-edges", unsafe { &mut EDGES[MAX_EDGES_NUM..] });
|
||||
unsafe { StdMapObserver::from_mut_ptr("first-edges", edges_ptr, num_edges) };
|
||||
let mut second_map_observer = unsafe {
|
||||
StdMapObserver::from_mut_ptr("second-edges", edges_ptr.add(num_edges), num_edges)
|
||||
};
|
||||
|
||||
// create a map swapper so that we can replace the coverage map pointer (requires feature pointer_maps!)
|
||||
let map_swapper =
|
||||
@ -136,10 +160,14 @@ pub fn main() {
|
||||
// create a combined map observer, e.g. for calibration
|
||||
// we use StdMapObserver::differential to indicate that we want to use the observer in
|
||||
// differential mode
|
||||
let map_observer =
|
||||
HitcountsMapObserver::new(StdMapObserver::differential("combined-edges", unsafe {
|
||||
EDGES
|
||||
}));
|
||||
let map_observer = unsafe {
|
||||
HitcountsMapObserver::new(StdMapObserver::differential_from_mut_ptr(
|
||||
"combined-edges",
|
||||
edges_ptr,
|
||||
num_edges * 2,
|
||||
))
|
||||
};
|
||||
|
||||
(
|
||||
first_map_observer,
|
||||
second_map_observer,
|
||||
@ -163,7 +191,7 @@ pub fn main() {
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
InMemoryOnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
// States of the feedbacks.
|
||||
// The feedbacks can report the data that should persist in the State.
|
||||
&mut feedback,
|
||||
@ -174,9 +202,11 @@ pub fn main() {
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
#[cfg(not(feature = "tui"))]
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::new(String::from("Baby Fuzzer"), false);
|
||||
let ui = TuiUI::new(String::from("Baby Fuzzer"), false);
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::new(ui);
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
@ -243,4 +273,10 @@ pub fn main() {
|
||||
)
|
||||
.expect("Error in the fuzzing loop");
|
||||
}
|
||||
|
||||
#[cfg(feature = "multimap")]
|
||||
unsafe {
|
||||
std::alloc::dealloc(first_edges.0, layout);
|
||||
std::alloc::dealloc(second_edges.0, layout);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_tokens"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -20,3 +20,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
|
@ -1,9 +1,8 @@
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{fs, io::Read, path::PathBuf};
|
||||
use std::{fs, io::Read, path::PathBuf, ptr::write};
|
||||
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
@ -17,13 +16,16 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
|
||||
/*
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
*/
|
||||
|
||||
@ -65,7 +67,7 @@ pub fn main() {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
@ -91,7 +93,7 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let monitor = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
|
1
fuzzers/baby_fuzzer_unicode/.gitignore
vendored
Normal file
1
fuzzers/baby_fuzzer_unicode/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
libpng-*
|
24
fuzzers/baby_fuzzer_unicode/Cargo.toml
Normal file
24
fuzzers/baby_fuzzer_unicode/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_unicode"
|
||||
version = "0.10.0"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
tui = []
|
||||
std = []
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/", features = ["unicode"] }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
15
fuzzers/baby_fuzzer_unicode/README.md
Normal file
15
fuzzers/baby_fuzzer_unicode/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Baby fuzzer: unicode
|
||||
|
||||
This is a minimalistic example about how to create a libafl based fuzzer.
|
||||
|
||||
It runs on a single core until a crash occurs and then exits.
|
||||
|
||||
The tested program is a simple Rust function without any instrumentation.
|
||||
For real fuzzing, you will want to add some sort to add coverage or other feedback.
|
||||
|
||||
You can run this example using `cargo run`, and you can enable the TUI feature by running `cargo run --features tui`.
|
||||
|
||||
## Unicode
|
||||
|
||||
This fuzzer uses mutators which preserve unicode properties. For programs which have string-heavy inputs, you may
|
||||
consider using the same strategy.
|
138
fuzzers/baby_fuzzer_unicode/src/main.rs
Normal file
138
fuzzers/baby_fuzzer_unicode/src/main.rs
Normal file
@ -0,0 +1,138 @@
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{path::PathBuf, ptr::write};
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
use libafl::monitors::tui::{ui::TuiUI, TuiMonitor};
|
||||
#[cfg(not(feature = "tui"))]
|
||||
use libafl::monitors::SimpleMonitor;
|
||||
use libafl::{
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
feedbacks::{CrashFeedback, MaxMapFeedback},
|
||||
fuzzer::{Fuzzer, StdFuzzer},
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
mutators::{StdScheduledMutator, StringCategoryRandMutator, StringSubcategoryRandMutator},
|
||||
observers::StdMapObserver,
|
||||
schedulers::QueueScheduler,
|
||||
stages::{mutational::StdMutationalStage, StringIdentificationStage},
|
||||
state::StdState,
|
||||
Evaluator,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 64] = [0; 64];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
|
||||
#[allow(clippy::similar_names, clippy::manual_assert)]
|
||||
pub fn main() {
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
let goal = b"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
|
||||
let mut i = 0;
|
||||
for _ in buf.iter().zip(goal).take_while(|(b, c)| b == c) {
|
||||
signals_set(i);
|
||||
i += 1;
|
||||
}
|
||||
if i == goal.len() {
|
||||
#[cfg(unix)]
|
||||
panic!("Artificial bug triggered =)");
|
||||
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
write_volatile(0 as *mut u32, 0);
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(PathBuf::from("./crashes")).unwrap(),
|
||||
// States of the feedbacks.
|
||||
// The feedbacks can report the data that should persist in the State.
|
||||
&mut feedback,
|
||||
// Same for objective feedbacks
|
||||
&mut objective,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
#[cfg(not(feature = "tui"))]
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
#[cfg(feature = "tui")]
|
||||
let ui = TuiUI::with_version(String::from("Baby Fuzzer"), String::from("0.0.1"), false);
|
||||
#[cfg(feature = "tui")]
|
||||
let mon = TuiMonitor::new(ui);
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(mon);
|
||||
|
||||
// A queue policy to get testcasess from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
|
||||
|
||||
// Create the executor for an in-process function with just one observer
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
tuple_list!(observer),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor");
|
||||
|
||||
// Generate 8 initial inputs
|
||||
fuzzer
|
||||
.evaluate_input(
|
||||
&mut state,
|
||||
&mut executor,
|
||||
&mut mgr,
|
||||
BytesInput::new(vec![b'a']),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::new(tuple_list!(
|
||||
StringCategoryRandMutator,
|
||||
StringSubcategoryRandMutator,
|
||||
StringSubcategoryRandMutator,
|
||||
StringSubcategoryRandMutator,
|
||||
StringSubcategoryRandMutator
|
||||
));
|
||||
let mut stages = tuple_list!(
|
||||
StringIdentificationStage::new(),
|
||||
StdMutationalStage::transforming(mutator)
|
||||
);
|
||||
|
||||
fuzzer
|
||||
.fuzz_loop(&mut stages, &mut executor, &mut state, &mut mgr)
|
||||
.expect("Error in the fuzzing loop");
|
||||
}
|
2
fuzzers/baby_fuzzer_wasm/.cargo/config.toml
Normal file
2
fuzzers/baby_fuzzer_wasm/.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[build]
|
||||
target = "wasm32-unknown-unknown"
|
6
fuzzers/baby_fuzzer_wasm/.gitignore
vendored
Normal file
6
fuzzers/baby_fuzzer_wasm/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
bin/
|
||||
wasm-pack.log
|
||||
.idea/
|
36
fuzzers/baby_fuzzer_wasm/Cargo.toml
Normal file
36
fuzzers/baby_fuzzer_wasm/Cargo.toml
Normal file
@ -0,0 +1,36 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Addison Crump <research@addisoncrump.info>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = ["console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
js-sys = "0.3"
|
||||
wasm-bindgen = "0.2.63"
|
||||
|
||||
libafl = { path = "../../libafl", default-features = false }
|
||||
libafl_bolts = { path = "../../libafl_bolts", default-features = false }
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||
# code size when deploying.
|
||||
console_error_panic_hook = { version = "0.1.6", optional = true }
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3"
|
||||
features = ['console', 'Window', 'Performance', 'PerformanceTiming']
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.3.13"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = true
|
||||
codegen-units = 1
|
29
fuzzers/baby_fuzzer_wasm/Makefile.toml
Normal file
29
fuzzers/baby_fuzzer_wasm/Makefile.toml
Normal file
@ -0,0 +1,29 @@
|
||||
[env]
|
||||
FUZZER_NAME="fuzzer"
|
||||
PROJECT_DIR = { script = ["pwd"] }
|
||||
|
||||
[tasks.unsupported]
|
||||
script_runner="@shell"
|
||||
script='''
|
||||
echo "Cargo-make not integrated yet on this"
|
||||
'''
|
||||
|
||||
# Fuzzer
|
||||
[tasks.build]
|
||||
command = "wasm-pack"
|
||||
args = ["build", "--target", "web"]
|
||||
|
||||
# Test
|
||||
[tasks.test]
|
||||
linux_alias = "test_unix"
|
||||
mac_alias = "test_unix"
|
||||
windows_alias = "unsupported"
|
||||
|
||||
[tasks.test_unix]
|
||||
command = "wasm-pack"
|
||||
args = ["test", "--chrome", "--headless"]
|
||||
|
||||
# Clean
|
||||
[tasks.clean]
|
||||
command = "cargo"
|
||||
args = ["clean"]
|
12
fuzzers/baby_fuzzer_wasm/README.md
Normal file
12
fuzzers/baby_fuzzer_wasm/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# libafl-wasm
|
||||
|
||||
A brief demo demonstrating libafl's compatibility with WASM, and how to do it.
|
||||
|
||||
In this example, the entire LibAFL harness and target are present in a WASM binary, which is then loaded by [the example
|
||||
webpage](pkg/index.html). To run this example, do `cargo make build`, then open [the example webpage](pkg/index.html) in
|
||||
your browser (via something like `python3 -m http.server`). The fuzzer will execute until finding a solution and will
|
||||
write the fuzzer log to your console.
|
||||
|
||||
In a real fuzzing campaign, you would likely need to also create a LibAFL Corpus implementation which was backed by
|
||||
JavaScript, and restart the fuzzing campaign by re-invoking the fuzzer and providing the associated corpora. This is
|
||||
not demonstrated in this barebones example.
|
1
fuzzers/baby_fuzzer_wasm/pkg/.gitignore
vendored
Normal file
1
fuzzers/baby_fuzzer_wasm/pkg/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*
|
14
fuzzers/baby_fuzzer_wasm/pkg/index.html
Normal file
14
fuzzers/baby_fuzzer_wasm/pkg/index.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>libafl_wasm test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
import libafl_wasm from './libafl_wasm.js'
|
||||
|
||||
libafl_wasm().then(wasm => wasm.fuzz())
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
17
fuzzers/baby_fuzzer_wasm/pkg/package.json
Normal file
17
fuzzers/baby_fuzzer_wasm/pkg/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "baby_fuzzer_wasm",
|
||||
"collaborators": [
|
||||
"Addison Crump <research@addisoncrump.info>"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"baby_fuzzer_wasm_bg.wasm",
|
||||
"baby_fuzzer_wasm.js",
|
||||
"baby_fuzzer_wasm.d.ts"
|
||||
],
|
||||
"module": "baby_fuzzer_wasm.js",
|
||||
"types": "baby_fuzzer_wasm.d.ts",
|
||||
"sideEffects": [
|
||||
"./snippets/*"
|
||||
]
|
||||
}
|
141
fuzzers/baby_fuzzer_wasm/src/lib.rs
Normal file
141
fuzzers/baby_fuzzer_wasm/src/lib.rs
Normal file
@ -0,0 +1,141 @@
|
||||
mod utils;
|
||||
|
||||
use libafl::{
|
||||
corpus::{Corpus, InMemoryCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{ExitKind, InProcessExecutor},
|
||||
feedbacks::{CrashFeedback, MapFeedbackMetadata, MaxMapFeedback},
|
||||
generators::RandPrintablesGenerator,
|
||||
inputs::{BytesInput, HasTargetBytes},
|
||||
monitors::SimpleMonitor,
|
||||
mutators::{havoc_mutations, StdScheduledMutator},
|
||||
observers::StdMapObserver,
|
||||
schedulers::QueueScheduler,
|
||||
stages::StdMutationalStage,
|
||||
state::{HasSolutions, StdState},
|
||||
Fuzzer, StdFuzzer,
|
||||
};
|
||||
use libafl_bolts::{
|
||||
current_nanos, rands::StdRand, serdeany::RegistryBuilder, tuples::tuple_list, AsSlice,
|
||||
};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::{Performance, Window};
|
||||
|
||||
use crate::utils::set_panic_hook;
|
||||
|
||||
// defined for internal use by libafl
|
||||
#[no_mangle]
|
||||
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||
pub extern "C" fn external_current_millis() -> u64 {
|
||||
let window: Window = web_sys::window().expect("should be in browser to run this demo");
|
||||
let performance: Performance = window
|
||||
.performance()
|
||||
.expect("should be in browser to run this demo");
|
||||
performance.now() as u64
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
#[wasm_bindgen]
|
||||
pub fn fuzz() {
|
||||
set_panic_hook();
|
||||
|
||||
unsafe {
|
||||
RegistryBuilder::register::<MapFeedbackMetadata<u8>>();
|
||||
}
|
||||
|
||||
let mut signals = [0u8; 64];
|
||||
let signals_ptr = signals.as_mut_ptr();
|
||||
let signals_set = |i: usize| unsafe {
|
||||
*signals_ptr.add(i) += 1;
|
||||
};
|
||||
|
||||
// The closure that we want to fuzz
|
||||
let mut harness = |input: &BytesInput| {
|
||||
let target = input.target_bytes();
|
||||
let buf = target.as_slice();
|
||||
signals_set(0);
|
||||
if !buf.is_empty() && buf[0] == b'a' {
|
||||
signals_set(1);
|
||||
if buf.len() > 1 && buf[1] == b'b' {
|
||||
signals_set(2);
|
||||
#[allow(clippy::manual_assert)]
|
||||
if buf.len() > 2 && buf[2] == b'c' {
|
||||
// WASM cannot handle traps: https://webassembly.github.io/spec/core/intro/overview.html
|
||||
// in a "real" fuzzing campaign, you should prefer to setup trap handling in JS,
|
||||
// but we do not do this for demonstration purposes
|
||||
return ExitKind::Crash;
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitKind::Ok
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer =
|
||||
unsafe { StdMapObserver::from_mut_ptr("signals", signals.as_mut_ptr(), signals.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
|
||||
// A feedback to choose if an input is a solution or not
|
||||
let mut objective = CrashFeedback::new();
|
||||
|
||||
// create a State from scratch
|
||||
let mut state = StdState::new(
|
||||
// RNG
|
||||
StdRand::with_seed(current_nanos()),
|
||||
// Corpus that will be evolved, we keep it in memory for performance
|
||||
InMemoryCorpus::new(),
|
||||
// In a "real" fuzzing campaign, you should stash solutions in a JS array instead
|
||||
InMemoryCorpus::new(),
|
||||
// States of the feedbacks.
|
||||
// The feedbacks can report the data that should persist in the State.
|
||||
&mut feedback,
|
||||
// Same for objective feedbacks
|
||||
&mut objective,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are reported to the user
|
||||
let monitor = SimpleMonitor::new(|s| {
|
||||
web_sys::console::log_1(&s.into());
|
||||
});
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
let mut mgr = SimpleEventManager::new(monitor);
|
||||
|
||||
// A queue policy to get testcasess from the corpus
|
||||
let scheduler = QueueScheduler::new();
|
||||
|
||||
// A fuzzer with feedbacks and a corpus scheduler
|
||||
let mut fuzzer = StdFuzzer::new(scheduler, feedback, objective);
|
||||
|
||||
// Create the executor for an in-process function with just one observer
|
||||
let mut executor = InProcessExecutor::new(
|
||||
&mut harness,
|
||||
tuple_list!(observer),
|
||||
&mut fuzzer,
|
||||
&mut state,
|
||||
&mut mgr,
|
||||
)
|
||||
.expect("Failed to create the Executor");
|
||||
|
||||
// Generator of printable bytearrays of max size 32
|
||||
let mut generator = RandPrintablesGenerator::new(32);
|
||||
|
||||
// Generate 8 initial inputs
|
||||
state
|
||||
.generate_initial_inputs(&mut fuzzer, &mut executor, &mut generator, &mut mgr, 8)
|
||||
.expect("Failed to generate the initial corpus");
|
||||
|
||||
// Setup a mutational stage with a basic bytes mutator
|
||||
let mutator = StdScheduledMutator::new(havoc_mutations());
|
||||
let mut stages = tuple_list!(StdMutationalStage::new(mutator));
|
||||
|
||||
while state.solutions().is_empty() {
|
||||
fuzzer
|
||||
.fuzz_one(&mut stages, &mut executor, &mut state, &mut mgr)
|
||||
.expect("Error in the fuzzing loop");
|
||||
}
|
||||
}
|
10
fuzzers/baby_fuzzer_wasm/src/utils.rs
Normal file
10
fuzzers/baby_fuzzer_wasm/src/utils.rs
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn set_panic_hook() {
|
||||
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||
// `set_panic_hook` function at least once during initialization, and then
|
||||
// we will get better error messages if our code ever panics.
|
||||
//
|
||||
// For more details see
|
||||
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||
#[cfg(feature = "console_error_panic_hook")]
|
||||
console_error_panic_hook::set_once();
|
||||
}
|
14
fuzzers/baby_fuzzer_wasm/tests/web.rs
Normal file
14
fuzzers/baby_fuzzer_wasm/tests/web.rs
Normal file
@ -0,0 +1,14 @@
|
||||
//! Test suite for the Web and headless browsers.
|
||||
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
use baby_fuzzer_wasm::fuzz;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_fuzz() {
|
||||
fuzz();
|
||||
}
|
15
fuzzers/baby_fuzzer_wasm/webdriver.json
Normal file
15
fuzzers/baby_fuzzer_wasm/webdriver.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"moz:firefoxOptions": {
|
||||
"prefs": {
|
||||
"media.navigator.streams.fake": true,
|
||||
"media.navigator.permission.disabled": true
|
||||
},
|
||||
"args": []
|
||||
},
|
||||
"goog:chromeOptions": {
|
||||
"args": [
|
||||
"--use-fake-device-for-media-stream",
|
||||
"--use-fake-ui-for-media-stream"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_fuzzer_with_forkexecutor"
|
||||
version = "0.6.1"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -20,3 +20,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
libafl_bolts = { path = "../../libafl_bolts/" }
|
||||
|
@ -1,15 +1,8 @@
|
||||
use std::path::PathBuf;
|
||||
#[cfg(windows)]
|
||||
use std::ptr::write_volatile;
|
||||
use std::{path::PathBuf, ptr::write};
|
||||
|
||||
use libafl::{
|
||||
bolts::{
|
||||
current_nanos,
|
||||
rands::StdRand,
|
||||
shmem::{unix_shmem, ShMemProvider},
|
||||
tuples::tuple_list,
|
||||
AsMutSlice, AsSlice,
|
||||
},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::{ExitKind, InProcessForkExecutor},
|
||||
@ -24,16 +17,23 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{
|
||||
current_nanos,
|
||||
rands::StdRand,
|
||||
shmem::{unix_shmem, ShMemProvider},
|
||||
tuples::tuple_list,
|
||||
AsMutSlice, AsSlice,
|
||||
};
|
||||
|
||||
#[allow(clippy::similar_names)]
|
||||
pub fn main() {
|
||||
let mut shmem_provider = unix_shmem::UnixShMemProvider::new().unwrap();
|
||||
let mut signals = shmem_provider.new_shmem(16).unwrap();
|
||||
let mut signals_clone = signals.clone();
|
||||
let signals_len = signals.as_slice().len();
|
||||
let signals_ptr = signals.as_mut_slice().as_mut_ptr();
|
||||
|
||||
let mut signals_set = |idx: usize| {
|
||||
let a = signals.as_mut_slice();
|
||||
a[idx] = 1;
|
||||
let signals_set = |idx: usize| {
|
||||
unsafe { write(signals_ptr.add(idx), 1) };
|
||||
};
|
||||
|
||||
// The closure that we want to fuzz
|
||||
@ -64,7 +64,7 @@ pub fn main() {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", signals_clone.as_mut_slice());
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", signals_ptr, signals_len) };
|
||||
// Create a stacktrace observer to add the observers tuple
|
||||
|
||||
// Feedback to rate the interestingness of an input, obtained by ANDing the interestingness of both feedbacks
|
||||
@ -91,7 +91,7 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "baby_no_std"
|
||||
version = "0.8.2"
|
||||
version = "0.11.2"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
@ -16,6 +16,7 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { default-features = false, path = "../../libafl/" }
|
||||
libafl_bolts = { default-features = false, path = "../../libafl_bolts/" }
|
||||
static-alloc = "0.2.3"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
@ -1,6 +1,8 @@
|
||||
[env]
|
||||
FUZZER_NAME="fuzzer"
|
||||
PROJECT_DIR = { script = ["pwd"] }
|
||||
PROFILE = { value = "release", condition = {env_not_set = ["PROFILE"]} }
|
||||
PROFILE_DIR = {value = "release", condition = {env_not_set = ["PROFILE_DIR"] }}
|
||||
|
||||
[tasks.unsupported]
|
||||
script_runner="@shell"
|
||||
@ -11,7 +13,7 @@ echo "Cargo-make not integrated yet on this"
|
||||
# Fuzzer
|
||||
[tasks.build]
|
||||
command = "cargo"
|
||||
args = ["build", "--release", "-Zbuild-std=core,alloc", "--target", "x86_64-unknown-linux-gnu"]
|
||||
args = ["build", "--profile", "${PROFILE}", "-Zbuild-std=core,alloc", "--target", "x86_64-unknown-linux-gnu"]
|
||||
|
||||
# Test
|
||||
[tasks.test]
|
||||
@ -26,7 +28,7 @@ cargo run -Zbuild-std=core,alloc --target x86_64-unknown-linux-gnu || true
|
||||
dependencies = ["build"]
|
||||
|
||||
[tasks.build_aarch]
|
||||
script = "cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release"
|
||||
script = "cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --profile ${PROFILE}"
|
||||
|
||||
# Clean
|
||||
[tasks.clean]
|
||||
|
@ -1,8 +1,6 @@
|
||||
#![no_std]
|
||||
// Embedded targets: build with no_main
|
||||
#![cfg_attr(not(any(windows)), no_main)]
|
||||
// Embedded needs alloc error handlers which only work on nightly right now...
|
||||
#![cfg_attr(not(any(windows)), feature(default_alloc_error_handler))]
|
||||
|
||||
#[cfg(any(windows, unix))]
|
||||
extern crate alloc;
|
||||
@ -10,9 +8,9 @@ extern crate alloc;
|
||||
use alloc::ffi::CString;
|
||||
#[cfg(not(any(windows)))]
|
||||
use core::panic::PanicInfo;
|
||||
use core::ptr::write;
|
||||
|
||||
use libafl::{
|
||||
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
|
||||
corpus::InMemoryCorpus,
|
||||
events::SimpleEventManager,
|
||||
executors::{inprocess::InProcessExecutor, ExitKind},
|
||||
@ -27,6 +25,7 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
|
||||
#[cfg(any(windows, unix))]
|
||||
use libc::{abort, printf};
|
||||
use static_alloc::Bump;
|
||||
@ -48,10 +47,11 @@ fn panic(_info: &PanicInfo) -> ! {
|
||||
|
||||
/// Coverage map with explicit assignments due to the lack of instrumentation
|
||||
static mut SIGNALS: [u8; 16] = [0; 16];
|
||||
static mut SIGNALS_PTR: *mut u8 = unsafe { SIGNALS.as_mut_ptr() };
|
||||
|
||||
/// Assign a signal to the signals map
|
||||
fn signals_set(idx: usize) {
|
||||
unsafe { SIGNALS[idx] = 1 };
|
||||
unsafe { write(SIGNALS_PTR.add(idx), 1) };
|
||||
}
|
||||
|
||||
/// Provide custom time in `no_std` environment
|
||||
@ -87,7 +87,7 @@ pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
};
|
||||
|
||||
// Create an observation channel using the signals map
|
||||
let observer = StdMapObserver::new("signals", unsafe { &mut SIGNALS });
|
||||
let observer = unsafe { StdMapObserver::from_mut_ptr("signals", SIGNALS_PTR, SIGNALS.len()) };
|
||||
|
||||
// Feedback to rate the interestingness of an input
|
||||
let mut feedback = MaxMapFeedback::new(&observer);
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Backtrace baby fuzzers
|
||||
|
||||
The projects contained in this directory are simple fuzzers derived from the original baby_fuzzer examples, whose purpose is to show how to use a `BacktraceObserver` or an `ASANObserver` to dedupe crashes and other necessary components for this feature.
|
||||
The projects contained in this directory are simple fuzzers derived from the original baby_fuzzer examples, whose purpose is to show how to use a `BacktraceObserver` or an `ASANObserver` to dedupe crashes and other necessary components for this feature. To use `casr` deduplication for `BacktraceObserver` or `ASANObserver` build LibAFL with `casr` feature.
|
||||
|
||||
The examples cover:
|
||||
|
||||
|
@ -16,6 +16,7 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../../libafl/" }
|
||||
libafl_bolts = { path = "../../../libafl_bolts/" }
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -1,13 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use libafl::{
|
||||
bolts::{
|
||||
current_nanos,
|
||||
rands::StdRand,
|
||||
shmem::{ShMem, ShMemProvider, StdShMemProvider},
|
||||
tuples::tuple_list,
|
||||
AsSlice,
|
||||
},
|
||||
corpus::{InMemoryCorpus, OnDiskCorpus},
|
||||
events::SimpleEventManager,
|
||||
executors::InProcessForkExecutor,
|
||||
@ -23,6 +16,13 @@ use libafl::{
|
||||
stages::mutational::StdMutationalStage,
|
||||
state::StdState,
|
||||
};
|
||||
use libafl_bolts::{
|
||||
current_nanos,
|
||||
rands::StdRand,
|
||||
shmem::{ShMem, ShMemProvider, StdShMemProvider},
|
||||
tuples::tuple_list,
|
||||
AsSlice,
|
||||
};
|
||||
use libc::{c_int, c_uchar};
|
||||
extern crate libc;
|
||||
|
||||
@ -45,7 +45,7 @@ pub fn main() {
|
||||
libafl::executors::ExitKind::Ok
|
||||
};
|
||||
// Create an observation channel using the signals map
|
||||
let observer = unsafe { ConstMapObserver::<u8, 3>::new_from_ptr("signals", map_ptr) };
|
||||
let observer = unsafe { ConstMapObserver::<u8, 3>::from_mut_ptr("signals", map_ptr) };
|
||||
// Create a stacktrace observer
|
||||
let mut bt = shmem_provider.new_shmem_object::<Option<u64>>().unwrap();
|
||||
let bt_observer = BacktraceObserver::new(
|
||||
@ -78,7 +78,7 @@ pub fn main() {
|
||||
.unwrap();
|
||||
|
||||
// The Monitor trait define how the fuzzer stats are displayed to the user
|
||||
let mon = SimpleMonitor::new(|s| println!("{}", s));
|
||||
let mon = SimpleMonitor::new(|s| println!("{s}"));
|
||||
|
||||
// The event manager handle the various events generated during the fuzzing loop
|
||||
// such as the notification of the addition of a new item to the corpus
|
||||
|
@ -16,6 +16,7 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../../libafl/" }
|
||||
libafl_bolts = { path = "../../../libafl_bolts/" }
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user