Giter Site home page Giter Site logo

vstruct's Introduction

vstruct ( Mark II )

Vivisect Structure Definition/Parsing Library Build Status

Installing

python3.4 -m pip install vstruct

vstruct (version 2) can now be installed via pip!

Additionally, a repository of existing structure definitions is available as a seperate package named fracture.

Examples

Basic Parsing

Simple vstruct byte parsing:

from vstruct.types import *

class Foo(VStruct):

    def __init__(self):
        VStruct.__init__(self)
        self.bar    = uint32()
        self.baz    = vbytes(20)


foo = Foo()

# read in byts from somewhere...
foo.vsParse(byts)

# access struct fields by name
if foo.bar == 30:
    print('bar == 30!')

# assign fields by name
foo.bar = 90

# emit modified bytes back out
byts = bytes(foo) # same as foo.vsEmit()

Parser Callbacks

WriteBack Bytes/Files

vstruct supports "writeback" functionality for both files and mutable bytearray types, allowing field assignments to change the underlying file or bytearray immediately.

class Foo(VStruct):

    def __init__(self):
        VStruct.__init__(self)
        self.bar    = uint32()
        self.baz    = uint32()


foo = Foo()

# ba is a bytearray
foo.vsParse(ba, writeback=True)

# if bar is 30, set baz to 99
if foo.bar == 30:
    foo.baz = 99

# ba bytearray has now been modified

Enum Types

Builds

Travis-Ci ( Linux: py-2.7 / py-3.4 )

Build Status

AppVeyor ( Windows: py-2.7 / py-3.4 )

Build Status

vstruct's People

Contributors

invisig0th avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.