code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
if not self.authenticators:
return
request.user = None
request.auth = None
for authenticator in self.authenticators:
auth_tuple = authenticator.authenticate()
if auth_tuple:
request.user = auth_tuple[0]
requ... | def perform_authentication(self) | Perform authentication on the incoming request. | 2.825923 | 2.603197 | 1.085559 |
for permission in self.permissions:
if not permission.has_permission():
if request.user:
raise errors.PermissionDenied()
else:
raise errors.NotAuthenticated() | def perform_authorization(self) | Check if the request should be permitted.
Raises an appropriate exception if the request is not permitted. | 5.739592 | 4.503858 | 1.274372 |
config = ET.Element("config")
clock_sa = ET.SubElement(config, "clock-sa", xmlns="urn:brocade.com:mgmt:brocade-clock")
clock = ET.SubElement(clock_sa, "clock")
timezone = ET.SubElement(clock, "timezone")
timezone.text = kwargs.pop('timezone')
callback = kwargs.p... | def clock_sa_clock_timezone(self, **kwargs) | Auto Generated Code | 1.469292 | 1.343831 | 1.093361 |
config = ET.Element("config")
show_clock = ET.Element("show_clock")
config = show_clock
input = ET.SubElement(show_clock, "input")
rbridge_id = ET.SubElement(input, "rbridge-id")
rbridge_id.text = kwargs.pop('rbridge_id')
callback = kwargs.pop('callback'... | def show_clock_input_rbridge_id(self, **kwargs) | Auto Generated Code | 1.456619 | 1.309646 | 1.112223 |
config = ET.Element("config")
show_clock = ET.Element("show_clock")
config = show_clock
output = ET.SubElement(show_clock, "output")
clock_time = ET.SubElement(output, "clock-time")
rbridge_id_out = ET.SubElement(clock_time, "rbridge-id-out")
rbridge_id_o... | def show_clock_output_clock_time_rbridge_id_out(self, **kwargs) | Auto Generated Code | 1.39962 | 1.292673 | 1.082733 |
config = ET.Element("config")
show_clock = ET.Element("show_clock")
config = show_clock
output = ET.SubElement(show_clock, "output")
clock_time = ET.SubElement(output, "clock-time")
current_time = ET.SubElement(clock_time, "current-time")
current_time.tex... | def show_clock_output_clock_time_current_time(self, **kwargs) | Auto Generated Code | 1.43646 | 1.268757 | 1.132179 |
'''
update db entry
:param field_dict: dictionary of fields and values
:param where_clause: where clause for the update
'''
query = '''
UPDATE %s SET %s
''' % (
self._name,
','.join('%s=:%s' % (k, k) for k in field_dict)
)
... | def update(self, field_dict, where_clause=None) | update db entry
:param field_dict: dictionary of fields and values
:param where_clause: where clause for the update | 2.589044 | 2.193501 | 1.180325 |
'''
insert new db entry
:param fields: list of fields to insert
:param values: list of values to insert
:return: row id of the new row
'''
if fields:
_fields = ' (%s) ' % ','.join(fields)
else:
_fields = ''
_values = ','.jo... | def insert(self, fields, values) | insert new db entry
:param fields: list of fields to insert
:param values: list of values to insert
:return: row id of the new row | 2.54466 | 2.179698 | 1.167437 |
'''
:param report: the report to store
:param test_id: the id of the test reported
:return: report id
'''
report_d = report.to_dict()
content = self._serialize_dict(report_d)
report_id = self.insert(
['test_id', 'content', 'status', 'reason'],
... | def store(self, report, test_id) | :param report: the report to store
:param test_id: the id of the test reported
:return: report id | 3.620275 | 2.974426 | 1.217134 |
'''
get report by the test id
:param test_id: test id
:return: Report object
'''
self.select('*', 'test_id=?', [test_id])
row = self._cursor.fetchone()
if not row:
raise KeyError('No report with test id %s in the DB' % test_id)
values... | def get(self, test_id) | get report by the test id
:param test_id: test id
:return: Report object | 4.364411 | 3.808621 | 1.145929 |
'''
:return: ids of test reports
'''
self.select('test_id, status, reason')
res = []
for row in self._cursor.fetchall():
res.append((row[0], row[1], row[2]))
return res | def get_report_list(self) | :return: ids of test reports | 5.701763 | 4.08429 | 1.396023 |
'''
serializes a dictionary
:param data: data to serialize
'''
return b64encode(zlib.compress(cPickle.dumps(data, protocol=2))).decode() | def _serialize_dict(cls, data) | serializes a dictionary
:param data: data to serialize | 6.488531 | 4.076182 | 1.591816 |
'''
deserializes a dictionary
:param data: data to deserialize
'''
return cPickle.loads(zlib.decompress(b64decode(data.encode()))) | def _deserialize_dict(cls, data) | deserializes a dictionary
:param data: data to deserialize | 6.888851 | 4.063637 | 1.695243 |
'''
:rtype: :class:`~kitty.data.data_manager.SessionInfo`
:return: current session info
'''
self.select('*')
row = self._cursor.fetchone()
if not row:
return None
info_d = self.row_to_dict(row)
return SessionInfo.from_dict(info_d) | def read_info(self) | :rtype: :class:`~kitty.data.data_manager.SessionInfo`
:return: current session info | 5.302239 | 2.824316 | 1.877353 |
'''
:type info: :class:`~kitty.data.data_manager.SessionInfo`
:param info: info to set
'''
if not self.info:
self.info = SessionInfo()
info_d = self.info.as_dict()
ks = []
vs = []
for k, v in info_d.items():
... | def set_session_info(self, info) | :type info: :class:`~kitty.data.data_manager.SessionInfo`
:param info: info to set | 3.486882 | 2.552556 | 1.366035 |
'''
:param orig: SessionInfo object to copy
:return: True if changed, false otherwise
'''
changed = False
for attr in SessionInfo.fields:
oattr = getattr(orig, attr)
if getattr(self, attr) != oattr:
setattr(self, attr, oattr)
... | def copy(self, orig) | :param orig: SessionInfo object to copy
:return: True if changed, false otherwise | 3.335289 | 2.174459 | 1.533848 |
'''
:param info_d: the info dictionary
:rtype: :class:`~kitty.data.data_manager.SessionInfo`
:return: object that corresponds to the info dictionary
'''
info = SessionInfo()
for k, v in info_d.items():
setattr(info, k, v)
return info | def from_dict(cls, info_d) | :param info_d: the info dictionary
:rtype: :class:`~kitty.data.data_manager.SessionInfo`
:return: object that corresponds to the info dictionary | 4.655876 | 1.76836 | 2.632877 |
'''
:return: dictionary of information about this model
'''
info = {}
info['model_name'] = self.name
info['stages'] = '->'.join([repr(s) for s in self._stages])
info['sequence'] = {
'index': self._current_index
}
return info | def get_model_info(self) | :return: dictionary of information about this model | 5.02682 | 4.312123 | 1.165741 |
'''
Run a single sequence
'''
self._check_pause()
self._pre_test()
session_data = self.target.get_session_data()
self._test_info()
resp = None
for edge in sequence:
if edge.callback:
edge.callback(self, edge, resp)
... | def _run_sequence(self, sequence) | Run a single sequence | 5.58127 | 5.198718 | 1.073586 |
'''
Transmit node data to target.
:type node: Template
:param node: node to transmit
:return: response if there is any
'''
payload = node.render().tobytes()
self._last_payload = payload
try:
return self.target.transmit(payload)
... | def _transmit(self, node) | Transmit node data to target.
:type node: Template
:param node: node to transmit
:return: response if there is any | 5.774399 | 3.085805 | 1.871278 |
'''
Encode string
:param data: string to encode
:param encoding: encoding to use (default: 'hex')
:return: encoded string
'''
if six.PY2:
return data.encode(encoding)
else:
if isinstance(data, str):
data = bytes(data, 'utf-8')
return codecs.encode(dat... | def encode_string(data, encoding='hex') | Encode string
:param data: string to encode
:param encoding: encoding to use (default: 'hex')
:return: encoded string | 2.622011 | 2.342814 | 1.119172 |
'''
Decode string
:param data: string to decode
:param encoding: encoding to use (default: 'hex')
:return: decoded string
'''
if six.PY2:
return data.decode(encoding)
else:
return codecs.decode(data.encode('ascii'), encoding) | def decode_string(data, encoding='hex') | Decode string
:param data: string to decode
:param encoding: encoding to use (default: 'hex')
:return: decoded string | 2.977737 | 2.426687 | 1.22708 |
'''
Encode data - list, dict, string, bool or int (and nested)
:param data: data to encode
:return: encoded object of the same type
'''
if isinstance(data, (six.string_types, bytes)):
return encode_string(data)
elif isinstance(data, (six.integer_types, bool, float)):
return ... | def encode_data(data) | Encode data - list, dict, string, bool or int (and nested)
:param data: data to encode
:return: encoded object of the same type | 2.508169 | 1.722605 | 1.456032 |
'''
Generate a function that performs rpc call
:param method: method name
:return: rpc function
'''
def _(**kwargs):
'''
always use named arguments
'''
msg_id = self.get_unique_msg_id()
params = encode_data(kwar... | def _generate_rpc_method(self, method) | Generate a function that performs rpc call
:param method: method name
:return: rpc function | 3.50886 | 3.053147 | 1.14926 |
'''
Parse the request
'''
self.req_method = 'unknown'
self.req_params = {}
self.req_rpc_version = '2.0'
self.req_id = 0
self.data = self.rfile.read(int(self.headers.get('content-length')))
data_dict = json.loads(self.data)
self.req_method =... | def _parse_request(self) | Parse the request | 2.641758 | 2.421207 | 1.091091 |
'''
Handle POST requests
'''
try:
self._parse_request()
except Exception as ex1:
print(traceback.format_exc())
self.error_response(JSONRPC_PARSE_ERROR, 'exception when parsing jsonrpc request [%s]' % (ex1))
return
try:
... | def do_POST(self) | Handle POST requests | 2.766098 | 2.68417 | 1.030523 |
'''
Send a result to the RPC client
:param additional_dict: the dictionary with the response
'''
self.send_response(200)
self.send_header("Content-type", "application/json")
response = {
'jsonrpc': self.req_rpc_version,
'id': self.req_id,
... | def send_result(self, additional_dict) | Send a result to the RPC client
:param additional_dict: the dictionary with the response | 2.553978 | 2.040068 | 1.251908 |
'''
Serving loop
'''
print('Waiting for a client to connect to url http://%s:%d/' % (self.host, self.port))
self.state = RpcServer._STATE_RUN
while self.state == RpcServer._STATE_RUN:
self.server.handle_request()
self.server.server_close()
self... | def start(self) | Serving loop | 5.038802 | 3.982815 | 1.265136 |
'''
:param fuzzer: the fuzzer object
:param edge: the edge in the graph we currently at.
edge.src is the get_session template
edge.dst is the send_data template
:param resp: the response from the target
'''
fuzzer.logger.info('session is: %s' % hexlify(resp[1:3]... | def new_session_callback(fuzzer, edge, resp) | :param fuzzer: the fuzzer object
:param edge: the edge in the graph we currently at.
edge.src is the get_session template
edge.dst is the send_data template
:param resp: the response from the target | 5.666923 | 2.567193 | 2.207439 |
'''
Returns an instance of some BitField class
.. note::
Since BitField is frequently used in binary format, multiple aliases were created for it. See aliases.py for more details.
'''
if not full_range:
return _LibraryBitField(value, length, signed, min_value, max_value, encoder, fu... | def BitField(value, length, signed=False, min_value=None, max_value=None, encoder=ENC_INT_DEFAULT, fuzzable=True, name=None, full_range=False) | Returns an instance of some BitField class
.. note::
Since BitField is frequently used in binary format, multiple aliases were created for it. See aliases.py for more details. | 4.923527 | 2.064023 | 2.385403 |
'''
Sets the current value of the field
:param value: value to set
:return: rendered value
'''
self._current_value = value
self._current_rendered = self._encode_value(self._current_value)
return self._current_rendered | def set_current_value(self, value) | Sets the current value of the field
:param value: value to set
:return: rendered value | 4.355192 | 2.764481 | 1.57541 |
'''
Skip up to [count] cases, default behavior is to just mutate [count] times
:count: number of cases to skip
:rtype: int
:return: number of cases skipped
'''
skipped = 0
for _ in range(count):
if self.mutate():
skipped += 1
... | def skip(self, count) | Skip up to [count] cases, default behavior is to just mutate [count] times
:count: number of cases to skip
:rtype: int
:return: number of cases skipped | 5.799083 | 2.281088 | 2.542244 |
'''
Mutate the field
:rtype: boolean
:return: True if field the mutated
'''
self._initialize()
if self._exhausted():
return False
self._current_index += 1
self._mutate()
return True | def mutate(self) | Mutate the field
:rtype: boolean
:return: True if field the mutated | 8.177934 | 4.376662 | 1.868532 |
'''
Render the current value of the field
:rtype: Bits
:return: rendered value
'''
self._initialize()
if not self.is_default():
self._current_rendered = self._encode_value(self._current_value)
return self._current_rendered | def render(self, ctx=None) | Render the current value of the field
:rtype: Bits
:return: rendered value | 7.126956 | 4.004021 | 1.77995 |
'''
Reset the field to its default state
'''
self._current_index = -1
self._current_value = self._default_value
self._current_rendered = self._default_rendered
self.offset = None | def reset(self) | Reset the field to its default state | 6.444983 | 4.718167 | 1.365993 |
'''
:rtype: dictionary
:return: field information
'''
info = {
'name': self.name if self.name else '<no name>',
'path': self.name if self.name else '<no name>',
'field_type': type(self).__name__,
'value': {
'raw': re... | def get_info(self) | :rtype: dictionary
:return: field information | 3.649079 | 3.342021 | 1.091878 |
'''
Resolve a field from name
:param field: name of the field to resolve
:rtype: BaseField
:return: the resolved field
:raises: KittyException if field could not be resolved
'''
if isinstance(field, BaseField):
return field
name = fiel... | def resolve_field(self, field) | Resolve a field from name
:param field: name of the field to resolve
:rtype: BaseField
:return: the resolved field
:raises: KittyException if field could not be resolved | 3.657862 | 2.468448 | 1.481847 |
'''
Resolve a field from an absolute name.
An absolute name is just like unix absolute path,
starts with '/' and each name component is separated by '/'.
:param name: absolute name, e.g. "/container/subcontainer/field"
:return: field with this absolute name
:rais... | def resolve_absolute_name(self, name) | Resolve a field from an absolute name.
An absolute name is just like unix absolute path,
starts with '/' and each name component is separated by '/'.
:param name: absolute name, e.g. "/container/subcontainer/field"
:return: field with this absolute name
:raises: KittyException i... | 5.76692 | 1.95081 | 2.956167 |
'''
:rtype: int
:return: hash of the field
'''
if self._hash is None:
self._initialize()
self._hash = khash(type(self).__name__, self._default_value, self._fuzzable)
return self._hash | def hash(self) | :rtype: int
:return: hash of the field | 6.284928 | 5.078731 | 1.2375 |
'''
skip up to [count] cases
:param count: number of cases to skip
:rtype: int
:return: number of cases skipped
'''
self._initialize()
skipped = 0
if not self._exhausted():
skipped = min(count, self._last_index() - self._current_index)... | def skip(self, count) | skip up to [count] cases
:param count: number of cases to skip
:rtype: int
:return: number of cases skipped | 4.493166 | 3.290697 | 1.365415 |
'''
.. note::
The following mutations will probably not be detected
unless there's a monitor that checks if the file /tmp/KITTY
was created in the post test
'''
lib.append(('|touch /tmp/KITTY', 'command injection - pipe'))
lib.append((';touch ... | def _add_command_injection_strings_unix(self, lib) | .. note::
The following mutations will probably not be detected
unless there's a monitor that checks if the file /tmp/KITTY
was created in the post test | 6.30475 | 3.385329 | 1.862375 |
'''
.. note::
The following mutations will probably not be detected
unless some entity will check the response from the target
on the validity of the DB.
'''
entries = [
("' or 1=1 --", 'mssql - bypass check'),
("\'; desc users... | def _add_sql_injection_strings(self, lib) | .. note::
The following mutations will probably not be detected
unless some entity will check the response from the target
on the validity of the DB. | 8.644525 | 5.18011 | 1.668792 |
'''
.. note::
The following mutations will probably not be detected
unless there's a monitor that checks if the file /tmp/KITTY
was created in the post test
'''
entries = [
(('/etc/passwd', 'absolute - /etc/passwd')),
(('./../.... | def _add_path_traversal_strings(self, lib) | .. note::
The following mutations will probably not be detected
unless there's a monitor that checks if the file /tmp/KITTY
was created in the post test | 5.202196 | 3.104485 | 1.675703 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(String, self).hash()
return khash(hashed, self._max_size) | def hash(self) | :rtype: int
:return: hash of the field | 8.602818 | 6.619409 | 1.299635 |
'''
If the range is from a to b, we try a few numbers around the arrows
a b
+-------------------------------------------+
^ ^ ^ ^ ^
'''
lib = []
num_sections = 4
for i in... | def _get_class_lib(self) | If the range is from a to b, we try a few numbers around the arrows
a b
+-------------------------------------------+
^ ^ ^ ^ ^ | 3.593043 | 2.52826 | 1.421152 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(_LibraryBitField, self).hash()
return khash(hashed, self._length, self._signed, self._min_value, self._max_value) | def hash(self) | :rtype: int
:return: hash of the field | 8.096026 | 6.732209 | 1.202581 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(Group, self).hash()
return khash(hashed, frozenset(self._values)) | def hash(self) | :rtype: int
:return: hash of the field | 10.474924 | 8.135913 | 1.287492 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(Dynamic, self).hash()
return khash(hashed, self._key, self._length) | def hash(self) | :rtype: int
:return: hash of the field | 9.666933 | 7.41966 | 1.302881 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(RandomBits, self).hash()
return khash(hashed, self._min_length, self._max_length, self._num_mutations, self._step, self._seed) | def hash(self) | :rtype: int
:return: hash of the field | 7.994597 | 6.651997 | 1.201834 |
'''
stop the thread, return after thread stopped
'''
self._stop_event.set()
if self._func_stop_event is not None:
self._func_stop_event.set()
self.join(timeout=1)
if self.isAlive():
print('Failed to stop thread') | def stop(self) | stop the thread, return after thread stopped | 4.415068 | 3.291513 | 1.341349 |
'''
We override _initialize, as we want to resolve the field each time
'''
if self._field_name:
self._field = self.resolve_field(self._field_name)
if not self._field:
raise KittyException('Could not resolve field name %s' % self._field_name) | def _initialize(self) | We override _initialize, as we want to resolve the field each time | 6.227411 | 3.113969 | 1.999831 |
'''
Render the current value into a :class:`bitstring.Bits` object
:rtype: :class:`bitstring.Bits`
:return: the rendered field
'''
self._initialize()
if ctx is None:
ctx = RenderContext()
#
# if we are called from within render, return... | def render(self, ctx=None) | Render the current value into a :class:`bitstring.Bits` object
:rtype: :class:`bitstring.Bits`
:return: the rendered field | 6.809024 | 4.984428 | 1.366059 |
'''
:rtype: int
:return: hash of the field
'''
hashed = super(Calculated, self).hash()
return khash(hashed, self._field_name) | def hash(self) | :rtype: int
:return: hash of the field | 9.951962 | 7.500807 | 1.326786 |
'''
We want to avoid trouble, so if the field is not enclosed by any other field,
we just return 0.
'''
encloser = field.enclosing
if encloser:
rendered = encloser.get_rendered_fields(RenderContext(self))
if field not in rendered:
v... | def _calculate(self, field) | We want to avoid trouble, so if the field is not enclosed by any other field,
we just return 0. | 5.902758 | 2.936213 | 2.01033 |
'''
If the offset is unknown, return 0
'''
base_offset = 0
if self.base_field is not None:
base_offset = self.base_field.offset
target_offset = self._field.offset
if (target_offset is None) or (base_offset is None):
return 0
return ... | def _calculate(self, field) | If the offset is unknown, return 0 | 3.675339 | 2.70298 | 1.359736 |
'''
Transmit single payload, and receive response, if expected.
The actual implementation of the send/receive should be in
``_send_to_target`` and ``_receive_from_target``.
:type payload: str
:param payload: payload to send
:rtype: str
:return: the respon... | def transmit(self, payload) | Transmit single payload, and receive response, if expected.
The actual implementation of the send/receive should be in
``_send_to_target`` and ``_receive_from_target``.
:type payload: str
:param payload: payload to send
:rtype: str
:return: the response (if received) | 2.317426 | 1.95123 | 1.187675 |
'''
Trigger the target (e.g. the victim application) to start communication with the fuzzer.
'''
assert(self.controller)
self._trigger()
self.logger.debug('Waiting for mutation response. (timeout = %d)'
% self.mutation_server_timeout)
res... | def trigger(self) | Trigger the target (e.g. the victim application) to start communication with the fuzzer. | 6.179013 | 4.852833 | 1.273279 |
'''
:type value: ``str``
:param value: value to encode
'''
kassert.is_of_types(value, (bytes, bytearray, six.string_types))
if isinstance(value, six.string_types):
return bytes(bytearray([ord(x) for x in value]))
elif isinstance(value, bytearray):
return bytes(value)
retu... | def strToBytes(value) | :type value: ``str``
:param value: value to encode | 3.604152 | 3.148736 | 1.144635 |
'''
:type value: ``str``
:param value: value to encode
'''
kassert.is_of_types(value, str)
if sys.version_info < (3,):
return ''.join([unichr(ord(x)) for x in value])
return value | def strToUtf8(value) | :type value: ``str``
:param value: value to encode | 4.882765 | 4.062801 | 1.201822 |
'''
:param value: value to encode
'''
encoded = strToBytes(value) + b'\x00'
return Bits(bytes=encoded) | def encode(self, value) | :param value: value to encode | 9.033972 | 7.978094 | 1.132347 |
'''
:param value: value to encode
:param length: length of value in bits
:param signed: is value signed
'''
if (length % 8 != 0) and self._mode:
raise Exception('cannot use endianess for non bytes aligned int')
pre = '' if signed else 'u'
fmt =... | def encode(self, value, length, signed) | :param value: value to encode
:param length: length of value in bits
:param signed: is value signed | 6.471653 | 5.510271 | 1.174471 |
'''
:param value: value to encode
:param length: length of value in bits
:param signed: is value signed
'''
if signed:
raise KittyException('Signed MultiBytes not supported yet, sorry')
# split to septets
if value:
bytes_arr = []
... | def encode(self, value, length, signed) | :param value: value to encode
:param length: length of value in bits
:param signed: is value signed | 4.204717 | 3.921156 | 1.072316 |
'''
:param value: value to encode
'''
kassert.is_of_types(value, Bits)
remainder = len(value) % 8
if remainder:
value += Bits(bin='0' * (8 - remainder))
return value | def encode(self, value) | :param value: value to encode | 6.591799 | 5.989703 | 1.100522 |
'''
:param value: value to encode
'''
kassert.is_of_types(value, Bits)
result = BitArray(value)
result.reverse()
return result | def encode(self, value) | :param value: value to encode | 10.458275 | 9.136943 | 1.144614 |
'''
:param value: value to encode
'''
kassert.is_of_types(value, Bits)
if len(value) % 8 != 0:
raise KittyException('this encoder cannot encode bits that are not byte aligned')
return self._encoder.encode(value.bytes) | def encode(self, value) | :param value: value to encode | 8.430383 | 7.689474 | 1.096354 |
'''
:param value: value to encode
'''
packed = pack(self.fmt, value)
return Bits(bytes=packed) | def encode(self, value) | :param value: value to encode | 8.367382 | 7.371367 | 1.135119 |
'''
hash arguments. khash handles None in the same way accross runs (which is good :))
'''
ksum = sum([hash(arg if arg is not None else -13371337) for arg in args])
return hash(str(ksum)) | def khash(*args) | hash arguments. khash handles None in the same way accross runs (which is good :)) | 12.430099 | 4.046999 | 3.071436 |
'''
need to wrap get_report, since we need to parse the report
'''
report_dict = self._meta_get_report()
report = Report.from_dict(report_dict)
return report | def get_report(self) | need to wrap get_report, since we need to parse the report | 8.299109 | 3.888276 | 2.134393 |
'''
Make sure the target is ready for fuzzing, including monitors and
controllers
'''
if self.controller:
self.controller.setup()
for monitor in self.monitors:
monitor.setup() | def setup(self) | Make sure the target is ready for fuzzing, including monitors and
controllers | 9.036825 | 2.438053 | 3.706575 |
'''
Clean up the target once all tests are completed
'''
if self.controller:
self.controller.teardown()
for monitor in self.monitors:
monitor.teardown() | def teardown(self) | Clean up the target once all tests are completed | 8.763525 | 4.143209 | 2.115154 |
'''
Stop the fuzzing session
'''
self.logger.info('Stopping client fuzzer')
self._target_control_thread.stop()
self.target.signal_mutated()
super(ClientFuzzer, self).stop() | def stop(self) | Stop the fuzzing session | 8.582911 | 6.407273 | 1.339558 |
'''
The matching stage is either the name of the last node, or ClientFuzzer.STAGE_ANY.
:return: True if we are in the correct model node
'''
if stage == ClientFuzzer.STAGE_ANY:
return True
if fuzz_node.name.lower() == stage.lower():
if self._index... | def _should_fuzz_node(self, fuzz_node, stage) | The matching stage is either the name of the last node, or ClientFuzzer.STAGE_ANY.
:return: True if we are in the correct model node | 6.572344 | 2.519231 | 2.608869 |
'''
Get the next mutation, if in the correct stage
:param stage: current stage of the stack
:param data: a dictionary of items to pass to the model
:return: mutated payload if in apropriate stage, None otherwise
'''
payload = None
# Commented out for now:... | def get_mutation(self, stage, data) | Get the next mutation, if in the correct stage
:param stage: current stage of the stack
:param data: a dictionary of items to pass to the model
:return: mutated payload if in apropriate stage, None otherwise | 7.56212 | 4.821033 | 1.568569 |
'''Signed 64-bit field'''
return BitField(value, 64, signed=True, min_value=min_value, max_value=max_value, encoder=encoder, fuzzable=fuzzable, name=name, full_range=full_range) | def SInt64(value, min_value=None, max_value=None, encoder=ENC_INT_DEFAULT, fuzzable=True, name=None, full_range=False) | Signed 64-bit field | 2.66009 | 2.23851 | 1.18833 |
'''8-bit field, Big endian encoded'''
return UInt8(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_BE, fuzzable=fuzzable, name=name, full_range=full_range) | def BE8(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 8-bit field, Big endian encoded | 4.599738 | 3.527772 | 1.303865 |
'''16-bit field, Big endian encoded'''
return UInt16(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_BE, fuzzable=fuzzable, name=name, full_range=full_range) | def BE16(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 16-bit field, Big endian encoded | 4.456928 | 3.376463 | 1.319999 |
'''32-bit field, Big endian encoded'''
return UInt32(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_BE, fuzzable=fuzzable, name=name, full_range=full_range) | def BE32(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 32-bit field, Big endian encoded | 4.517912 | 3.507804 | 1.28796 |
'''64-bit field, Big endian encoded'''
return UInt64(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_BE, fuzzable=fuzzable, name=name, full_range=full_range) | def BE64(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 64-bit field, Big endian encoded | 4.513993 | 3.542911 | 1.274091 |
'''8-bit field, Little endian encoded'''
return UInt8(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_LE, fuzzable=fuzzable, name=name, full_range=full_range) | def LE8(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 8-bit field, Little endian encoded | 4.373899 | 3.472185 | 1.259696 |
'''16-bit field, Little endian encoded'''
return UInt16(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_LE, fuzzable=fuzzable, name=name, full_range=full_range) | def LE16(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 16-bit field, Little endian encoded | 4.13119 | 3.254986 | 1.269188 |
'''32-bit field, Little endian encoded'''
return UInt32(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_LE, fuzzable=fuzzable, name=name, full_range=full_range) | def LE32(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 32-bit field, Little endian encoded | 4.168803 | 3.402779 | 1.225117 |
'''64-bit field, Little endian encoded'''
return UInt64(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_LE, fuzzable=fuzzable, name=name, full_range=full_range) | def LE64(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False) | 64-bit field, Little endian encoded | 4.215115 | 3.421554 | 1.23193 |
'''
:rtype: :class:`~kitty.model.low_level.calculated.Size`
:return: Size field, which holds the size in bytes of the sized field
'''
return Size(sized_field=sized_field, length=length, calc_func=lambda x: len(x) // 8, encoder=encoder, fuzzable=fuzzable, name=name) | def SizeInBytes(sized_field, length, encoder=ENC_INT_DEFAULT, fuzzable=False, name=None) | :rtype: :class:`~kitty.model.low_level.calculated.Size`
:return: Size field, which holds the size in bytes of the sized field | 6.337332 | 2.354096 | 2.692045 |
'''
:rtype: :class:`~kitty.model.low_level.calculated.Hash`
:return: MD5 hash field
'''
return Hash(depends_on=depends_on, algorithm='md5', encoder=encoder, fuzzable=fuzzable, name=name) | def Md5(depends_on, encoder=ENC_STR_DEFAULT, fuzzable=False, name=None) | :rtype: :class:`~kitty.model.low_level.calculated.Hash`
:return: MD5 hash field | 6.64001 | 2.344596 | 2.832049 |
while True:
try:
return func(*args)
except (OSError, select.error) as e:
if e.args[0] != errno.EINTR:
raise | def _eintr_retry(func, *args) | restart a system call interrupted by EINTR | 2.016876 | 1.976726 | 1.020311 |
self.__is_shut_down.clear()
try:
while not self.__shutdown_request:
r, w, e = _eintr_retry(select.select, [self], [], [], poll_interval)
if self in r:
self._handle_request_noblock()
finally:
self.__shutdown_req... | def serve_forever(self, poll_interval=0.5) | Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores
self.timeout. If you need to do periodic tasks, do them in
another thread. | 3.238373 | 3.226577 | 1.003656 |
try:
request, client_address = self.get_request()
except socket.error:
return
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
except:
self.handle_error(r... | def _handle_request_noblock(self) | Handle one request, without blocking. | 2.39949 | 2.158114 | 1.111846 |
self.finish_request(request, client_address)
self.shutdown_request(request) | def process_request(self, request, client_address) | Call finish_request. | 5.025308 | 3.662105 | 1.372246 |
if self.allow_reuse_address:
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind(self.server_address) | def server_bind(self) | Called by constructor to bind the socket. | 2.034471 | 1.855336 | 1.096551 |
try:
request.shutdown(socket.SHUT_WR)
except socket.error:
pass
self.close_request(request) | def shutdown_request(self, request) | Called to shutdown and close an individual request. | 4.077953 | 3.441233 | 1.185027 |
try:
self.finish_request(request, client_address)
self.shutdown_request(request)
except Exception as e:
self.logger.error(e)
self.handle_error(request, client_address)
self.shutdown_request(request) | def process_request_thread(self, request, client_address) | Process the request. | 2.299526 | 2.335363 | 0.984655 |
self.logger.error('-' * 40)
self.logger.error('Exception happened during processing of request from %s:%s' % (client_address[0], client_address[1]))
self.logger.error(traceback.format_exc())
self.logger.error('-' * 40)
self.stop() | def handle_error(self, request, client_address) | Add self.stop to make server stop | 2.410892 | 2.214442 | 1.088713 |
'''
:param obj: object to assert
:param the_types: iterable of types, or a signle type
:raise: an exception if obj is not an instance of types
'''
if not isinstance(obj, the_types):
raise KittyException('object type (%s) is not one of (%s)' % (type(obj), the_types)) | def is_of_types(obj, the_types) | :param obj: object to assert
:param the_types: iterable of types, or a signle type
:raise: an exception if obj is not an instance of types | 4.812973 | 2.381034 | 2.021379 |
if self._server:
if self._server.returncode is None:
self._server.kill()
time.sleep(0.2)
self._server = subprocess.Popen("python session_server.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
time.sleep(0.2) | def _restart_target(self) | Restart our Target. | 3.107859 | 2.901045 | 1.07129 |
'''
:return: description string (with listening host:port)
'''
return '%(description)s listening on %(host)s:%(port)s' % {
'description': super(WebInterface, self).get_description(),
'host': self._host,
'port': self._port
} | def get_description(self) | :return: description string (with listening host:port) | 5.209607 | 2.850927 | 1.827338 |
'''
:param src: source node, if dst is None it will be destination node and the root (dummy) node will be source
:param dst: destination node (default: None)
:type callback: func(fuzzer, edge, response) -> None
:param callback: a function to be called after the response for src r... | def connect(self, src, dst=None, callback=None) | :param src: source node, if dst is None it will be destination node and the root (dummy) node will be source
:param dst: destination node (default: None)
:type callback: func(fuzzer, edge, response) -> None
:param callback: a function to be called after the response for src received and before d... | 5.004253 | 2.291275 | 2.184048 |
'''
:param current: current node to check if visited
:param visited: list of visited fields
:raise: KittyException if loop found
'''
if current in visited:
path = ' -> '.join(v.get_name() for v in (visited + [current]))
raise KittyException('loop d... | def check_loops_in_grpah(self, current=None, visited=[]) | :param current: current node to check if visited
:param visited: list of visited fields
:raise: KittyException if loop found | 4.812007 | 3.079734 | 1.562475 |
'''
:return: dictionary of information regarding the stages in the fuzzing session
.. note::
structure: { current: ['stage1', 'stage2', 'stage3'], 'stages': {'source1': ['dest1', 'dest2'], 'source2': ['dest1', 'dest3']}}
'''
sequence = self.get_sequence()
st... | def get_stages(self) | :return: dictionary of information regarding the stages in the fuzzing session
.. note::
structure: { current: ['stage1', 'stage2', 'stage3'], 'stages': {'source1': ['dest1', 'dest2'], 'source2': ['dest1', 'dest3']}} | 3.185642 | 1.762442 | 1.807515 |
'''
Set the report to its defaults.
This will clear the report, keeping only the name and setting the
failure status to the default.
'''
self._data_fields = {}
self._sub_reports = {}
self.set_status(Report.FAILED if self._default_failed else Report.PASSED)... | def clear(self) | Set the report to its defaults.
This will clear the report, keeping only the name and setting the
failure status to the default. | 7.63627 | 3.40087 | 2.245387 |
'''
Set the report status to PASSED
'''
self.set_status(Report.PASSED)
if 'reason' in self._data_fields:
del self._data_fields['reason'] | def passed(self) | Set the report status to PASSED | 6.744664 | 4.876887 | 1.382985 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.