This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from netzob.all import * | |
# a list of raw bytes | |
data = [ "hello\x00\x11", "hello\x00\x12" ] | |
# convert data to a list of RawMessages | |
messages = [ RawMessage(d) for d in data ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: x = "010203040506" | |
In [2]: import binascii | |
In [3]: binascii.unhexlify(x) | |
Out[3]: '\x01\x02\x03\x04\x05\x06' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from netzob.all import * | |
# | |
# current knownledge of the fields definition | |
# | |
f_type = Field(domain=Raw(nbBytes=1), name="Type") | |
f_dev_id = Field(domain=Raw(nbBytes=1), name="Dev_id") | |
f_cmd = Field(domain=Raw(nbBytes=2), name="Command") | |
f_payload = Field(domain=Raw(nbBytes=(0, 10)), name="Payload") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from netzob.all import * | |
m1 = RawMessage("field0field1") | |
m2 = RawMessage("field0field1") | |
f0 = Field(Raw(nbBytes=6)) | |
f1 = Field(Raw(nbBytes=6)) | |
s = Symbol(fields=[f0, f1]) | |
s.messages = [m1, m2] | |
print s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from netzob.all import * | |
>>> f = Field(Raw(nbBytes=(1,10000))) | |
... | |
ValueError: Maximum size supported for a variable is 79999. | |
>>> AbstractType.MAXIMUM_GENERATED_DATA_SIZE = 10000 * 8 | |
>>> f = Field(Raw(nbBytes=(1,10000))) | |
>>> f.specialize() | |
slkdj qslddqsjqdlkjsqjdskljsd qkjkqldsj.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def make_pi(): | |
q, r, t, k, m, x = 1, 0, 1, 1, 3, 3 | |
for j in range(1000): | |
if 4 * q + r - t < m * t: | |
yield m | |
q, r, t, k, m, x = 10*q, 10*(r-m*t), t, k, (10*(3*q+r))//t - 10*m, x | |
else: | |
q, r, t, k, m, x = q*k, (2*q+r)*x, t*x, k+1, (q*(7*k+2)+r*x)//(t*x), x+2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from netzob.all import * | |
file_to_parse = "/tmp/test.txt" | |
messages = [] | |
with open(file_to_parse, 'r') as fd: | |
for data in fd: | |
messages.append(RawMessage(data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
from netzob.all import * | |
data = ["hello bernard !", "hello albert !", "hello netzob !"] | |
messages = [RawMessage(d) for d in data] | |
f0 = Field(ASCII("hello ")) | |
f1 = Field(ASCII(nbChars=(1,20))) | |
f2 = Field(ASCII(" !")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# | |
# third parties | |
from libcloud.storage.types import Provider | |
from libcloud.storage.providers import get_driver | |
my_username = "HORIZON-USERNAME" | |
my_password = "HORIZON-PASSWORD-FOR-MY-USERNAME" | |
my_tenant_name = "TENANT_NAME_I_CAN_FIND_IN_OVH_GENERATED_OPENRC_FILE" |