what = 'large metadata with {size} extra chars'
def write_metadata(self, f):
- p1 = '''/* CTF 1.8 */
-
-typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
-typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
-
-trace {
- major = 0;
- minor = 0;
- uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
- byte_order = le;
- packet.header := struct {
- uint32_t magic;
- uint8_t uuid[16];
- };
-};
-
-event {
+ p1 = \
+'''event {
name = myevent;
fields := struct {
uint8_t f;
'''
p2 = '\n};\n'
+ f.write(self.BASIC_PROLOGUE)
f.write(p1)
for i in range(self.size):
def write_metadata(self, f):
p1 = \
-'''/* CTF 1.8 */
-
-typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
-typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
-
-trace {
- major = 0;
- minor = 0;
- uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
- byte_order = le;
- packet.header := struct {
- uint32_t magic;
- uint8_t uuid[16];
- };
-};
-
-event {
+'''event {
name = myevent;
fields := struct {
uint8_t '''
};
'''
+ f.write(self.BASIC_PROLOGUE)
f.write(p1)
for i in range(self.size):
def write_metadata(self, f):
p1 = \
-'''/* CTF 1.8 */
-
-typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
-typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
-
-trace {
- major = 0;
- minor = 0;
- uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
- byte_order = le;
- packet.header := struct {
- uint32_t magic;
- uint8_t uuid[16];
- };
-};
-
-event {
+'''event {
name = myevent;
};
'''
+ f.write(self.BASIC_PROLOGUE)
f.write(p1)
for i in range(self.size):
what = '{size} typealiases'
def write_metadata(self, f):
- p1 = \
-'''/* CTF 1.8 */
-
-typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
-typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
-
-trace {
- major = 0;
- minor = 0;
- uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
- byte_order = le;
- packet.header := struct {
- uint32_t magic;
- uint8_t uuid[16];
- };
-};
-
-'''
-
typealias_fmt = \
'''typealias integer {{ size = 8; align = 8; signed = false; base = 10; }} := t{name};
'''
- f.write(p1)
+ f.write(self.BASIC_PROLOGUE)
for i in range(self.size):
typealias = typealias_fmt.format(name=i)
what = '{size} typedefs'
def write_metadata(self, f):
- p1 = \
-'''/* CTF 1.8 */
-
-typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
-typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
-
-trace {
- major = 0;
- minor = 0;
- uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
- byte_order = le;
- packet.header := struct {
- uint32_t magic;
- uint8_t uuid[16];
- };
-};
-
-'''
-
typedef_fmt = \
'''typedef integer {{ size = 8; align = 8; signed = false; base = 10; }} t{name};
'''
- f.write(p1)
+ f.write(self.BASIC_PROLOGUE)
for i in range(self.size):
typedef = typedef_fmt.format(name=i)
class MetadataTest:
+ BASIC_PROLOGUE = \
+'''/* CTF 1.8 */
+
+typealias integer { size = 8; align = 8; signed = false; base = 10; } := uint8_t;
+typealias integer { size = 32; align = 8; signed = false; base = hex; } := uint32_t;
+
+trace {
+ major = 0;
+ minor = 0;
+ uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
+ byte_order = le;
+ packet.header := struct {
+ uint32_t magic;
+ uint8_t uuid[16];
+ };
+};
+
+'''
+
def __init__(self):
self._actions = {
'prepare': self._prepare,