Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
90 lines (71 loc) · 2.67 KB

File metadata and controls

90 lines (71 loc) · 2.67 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Module generating ICMP payloads (with no header)"""
class PayloadProvider:
def __init__(self):
raise NotImplementedError('Cannot create instances of PayloadProvider')
def __iter__(self):
raise NotImplementedError()
def __next__(self):
raise NotImplementedError()
class List(PayloadProvider):
def __init__(self, payload_list):
"""Creates a provider of payloads from an existing list of payloads
:param payload_list: An existing list of payloads
:type payload_list: list"""
self._payloads = payload_list
self._counter = 0
def __iter__(self):
self._counter = 0
return self
def __next__(self):
if self._counter < len(self._payloads):
ret = self._payloads[self._counter]
self._counter += 1
return ret
raise StopIteration
class Repeat(PayloadProvider):
def __init__(self, pattern, count):
"""Creates a provider of many identical payloads
:param pattern: The existing payload
:type pattern: bytes
:param count: How many payloads to generate
:type count: int"""
self.pattern = pattern
self.count = count
self._counter = 0
def __iter__(self):
self._counter = 0
return self
def __next__(self):
if self._counter < self.count:
self._counter += 1
return self.pattern
raise StopIteration
class Sweep(PayloadProvider):
def __init__(self, pattern, start_size, end_size):
"""Creates a provider of payloads of increasing size
:param pattern: The existing payload, may be cut or replicated to fit the size
:type pattern: bytes
:param start_size: The first payload size to start with, included
:type start_size: int
:param end_size: The payload size to end with, included
:type end_size: int"""
if start_size > end_size:
raise ValueError('end_size must be greater or equal than start_size')
if len(pattern) == 0:
raise ValueError('pattern cannot be empty')
self.pattern = pattern
self.start_size = start_size
self.end_size = end_size
# Extend the length of the pattern if needed
while not len(self.pattern) >= end_size:
self.pattern += pattern
self._current_size = self.start_size
def __iter__(self):
self._current_size = self.start_size
return self
def __next__(self):
if self._current_size <= self.end_size:
ret = self.pattern[0:self._current_size]
self._current_size += 1
return ret
raise StopIteration
Morty Proxy This is a proxified and sanitized view of the page, visit original site.