Git Product home page Git Product logo

py-segfault's Introduction

Segfault module for python

This is mostly a demo of mixing C into python, just a little more fun than the typicall "hello world" and "spam" example modules. There is actual documentation for this, and don't worry, I won't make you read the whole thing, just sections 1.1, 1.3 only if you're confused, 1.4, then click the first link in 1.5 but only read up through the second code block unless you're a total nerd.

C can do lots of stuff that python can't, mainly it's pretty fast, which is nice if you have some bottleneck in your python scripts.

Of course speed isn't all that C offers, you can do other amazing things, like access whatever memory you want. Damn the torpedoes!

So next time some snobby systems developer points to a segfault and asks "Can your python do this?!" show them what's up.

Installation

python setup.py install; \
echo lol, always forget; \
sudo python setup.py install

The segfault module

The segfault module provides only one method:

segfault.segfault(startString)

This method reads the string passed to it, but doesn't heed to silly things like null terminators that deter inferior string-reading methods. This one stops for nothing! It will print the byte index and the character there with verbose expansions for special and non-printable characters.

Passing an empty string supresses this output and memory bytes will only be copied into a buffer with no output.

Examples

Generate a segfault quietly:

python -c "import segfault; segfault.segfault('')"

Scroll through over 400KB at one line per byte, there's a surprise at the end:

python -c "import segfault; segfault.segfault('lol')"

Just a taste of the fun:

head <(python -c "import segfault; segfault.segfault('lol')"); \
echo "..."; \
tail <(python -c "import segfault; segfault.segfault('lol')"; exit="$?"; echo; man 7 signal | grep $(($exit-128)))

py-segfault's People

Contributors

vsharapov avatar

Watchers

 avatar  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.