Skip to content

Commit

Permalink
fix bytes data type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
KissPeter committed Sep 10, 2019
1 parent 4c5403f commit e3fcfbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions apifuzzer/custom_fuzzers.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from kitty.model import RandomBits, String


# https://lcamtuf.blogspot.hu/2014/08/binary-fuzzing-strategies-what-works.html


def transform_data_to_bytes(data_in):
if isinstance(data_in, float):
return bytes(int(data_in))
elif isinstance(data_in, str):
return bytes(data_in, 'utf-16')
else:
return bytes(data_in)


class RandomBitsField(RandomBits):
"""Creates a fields which compatible field with String and Delimiter"""

def not_implemented(self, func_name):
pass

def __init__(self, value, name, fuzzable=True):
super(RandomBitsField, self).__init__(name=name, value=value, min_length=20, max_length=100, fuzzable=fuzzable, num_mutations=80)
super(RandomBitsField, self).__init__(name=name, value=transform_data_to_bytes(value), min_length=20, max_length=100, fuzzable=fuzzable, num_mutations=80)


class UnicodeStrings(String):
Expand All @@ -19,7 +28,7 @@ def __init__(self, value, name, min_length=20, max_length=100, num_mutations=80,
self.min_length = min_length
self.max_length = max_length
self.num_mutations = num_mutations
super(UnicodeStrings, self).__init__(name=name, value=value, fuzzable=fuzzable)
super(UnicodeStrings, self).__init__(name=name, value=transform_data_to_bytes(value), fuzzable=fuzzable)

def not_implemented(self, func_name):
pass
Expand Down
2 changes: 1 addition & 1 deletion apifuzzer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_sample_data_by_type(param_type):
u'name': '012',
u'string': 'asd',
u'integer': 1,
u'number': 667,
u'number': 667.5,
u'boolean': False,
u'array': ['a', 'b', 'c'],
# TODO sample object
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kittyfuzzer==0.7.1
kittyfuzzer==0.7.4

0 comments on commit e3fcfbc

Please sign in to comment.