Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit b0cd504

Browse files
committed
Add support for escaped strings to the dictionary.
The dictionary reader can now handle escaped strings in its vales, as given in the AFL examples.
1 parent 3a6fac5 commit b0cd504

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎pythonfuzz/dictionary.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
Basic reader for libfuzzer/AFL style dictionaries.
3+
4+
See documentation at:
5+
https://llvm.org/docs/LibFuzzer.html#dictionaries
6+
https://github.com/google/AFL/blob/master/dictionaries/README.dictionaries
7+
8+
For our use, we only support reading the content of the dictionary values.
9+
"""
10+
11+
import codecs
112
import random
213
import re
314
import os
@@ -18,7 +29,10 @@ def __init__(self, dict_path=None):
1829
continue
1930
word = self.line_re.search(line)
2031
if word:
21-
_dict.add(word.group(1))
32+
# Decode any escaped characters, giving us a bytes object
33+
value = word.group(1)
34+
(value, _) = codecs.escape_decode(value)
35+
_dict.add(value)
2236
self._dict = list(_dict)
2337

2438
def get_word(self):

0 commit comments

Comments
 (0)