import ptypes from . import ber, tlsext from ptypes import * ptypes.setbyteorder(ptypes.config.byteorder.bigendian) class sint8(pint.sint8_t): pass class sint16(pint.sint16_t): pass class sint24(pint.sint_t): length = 3 class sint32(pint.sint32_t): pass class sint64(pint.sint64_t): pass class uint8(pint.uint8_t): pass class uint16(pint.uint16_t): pass class uint24(pint.uint_t): length = 3 class uint32(pint.uint32_t): pass class uint64(pint.uint64_t): pass class ProtocolVersion(pstruct.type): _fields_ = [ (uint8, 'major'), (uint8, 'minor'), ] def summary(self): return "major={:d} minor={:d}".format(self['major'].int(), self['minor'].int()) class ContentType(pint.enum, uint8): _values_ = [ ('change_cipher_spec', 20), ('alert', 21), ('handshake', 22),
import ptypes from ptypes import * from . import * import art,graph from array import array ptypes.setbyteorder(ptypes.config.byteorder.littleendian) ## Ripped from PowerPoint97-2007BinaryFileFormat(ppt)Specification.pdf recordType = [ ('RT_Unknown', 0x0000), ('RT_SubContainerCompleted', 0x0001), ('RT_IRRAtom', 0x0002), # indexed record reference ('RT_PSS', 0x0003), # start of stream ('RT_SubContainerException', 0x0004), ('RT_ClientSignal1', 0x0006), ('RT_ClientSignal2', 0x0007), ('RT_PowerPointStateInfoAtom', 0x000a), ('RT_Scheme', 0x03f4), ('RT_SchemeAtom', 0x03f5), ('RT_DocViewInfo', 0x03f6), ('RT_SslideLayoutAtom', 0x03f7), ('RT_ViewInfo', 0x03fc), ('RT_Texture', 0x0403), ('RT_VBASlideInfo', 0x0404), ('RT_VBASlideInfoAtom', 0x0405), ('RT_OEShape', 0x0bc0), ('RT_GrColor', 0x0bcc), ('RT_GrectAtom', 0x0bd1), ('RT_GratioAtom', 0x0bd7), ('RT_Gscaling', 0x0bd8),
import ptypes from ptypes import ptype, parray, pstruct, pint, pstr, dyn, pbinary ptypes.setbyteorder(ptypes.config.byteorder.littleendian) ### header markers class ElfXX_File(ptype.boundary): pass class ElfXX_Header(ptype.boundary): pass class ElfXX_Ehdr(ElfXX_Header): pass ### base class uchar(pint.uint8_t): pass class ElfXX_BaseOff(ptype.rpointer_t): '''Always an offset relative to base of file.''' _object_ = ptype.undefined def _baseobject_(self): return self.getparent(ElfXX_File)
import ptypes from ptypes import * import ptypes.bitmap as bitmap from .__base__ import layer,datalink,stackable ptypes.setbyteorder(ptypes.config.byteorder.bigendian) class u_char(pint.uint8_t): pass class u_short(pint.uint16_t): pass class u_long(pint.uint32_t): pass class in_addr(u_long): def summary(self): num = bitmap.new(super(in_addr,self).int(), 32) octets = bitmap.split(num, 8)[::-1] return '0x{:x} {:d}.{:d}.{:d}.{:d}'.format(*map(bitmap.number,[num]+octets)) @layer.define class ip4_hdr(pstruct.type, stackable): type = 4 class __ip_h(pbinary.struct): _fields_ = [(4,'ver'),(4,'hlen')] _fields_ = [ # (u_char, 'ip_h'), (__ip_h, 'ip_h'), (u_char, 'ip_tos'), (u_short, 'ip_len'), (u_short, 'ip_id'),
import math, fractions, itertools, operator, functools, logging import ptypes from ptypes import * ptypes.setbyteorder(pint.bigendian) ### types class Type(ptype.definition): cache = {} @Type.define class BYTE(pint.uint8_t): type = 1 @Type.define class ASCII(pstr.char_t): type = 2 @Type.define class SHORT(pint.uint16_t): type = 3 @Type.define class LONG(pint.uint32_t): type = 4
import ptypes from ptypes import * ptypes.setbyteorder( pint.bigendian ) class Record(object): cache = {} @classmethod def Add(cls, object): t = object.type cls.cache[t] = object @classmethod def Lookup(cls, type): return cls.cache[type] @classmethod def Define(cls, pt): cls.Add(pt) return pt class Directory(pstruct.type): class Entry(pstruct.type): def _offset(self): id = int(self['id'].li) t = self['type'].l type = t.lookup[int(t)] c = int(self['count'].li) try: