Skip to content

Instantly share code, notes, and snippets.

View disconnect3d's full-sized avatar
🎯
deadlocking the reality

Disconnect3d disconnect3d

🎯
deadlocking the reality
View GitHub Profile
#include <iostream>
#include <fstream>

#define LOG(x) std::cout << #x << " = " << x << std::endl

int main() {
    {
        std::cout << "ofstream(\"/tmp\")" << std::endl;
        std::ofstream f("/tmp");
### GDB DEV
function gdb-conf {
if [ "$#" -lt 1 ]; then
echo "Usage: gdb-conf configure-path [additional args...]"
return
fi
conf=$1
shift 1
### GDB DEV
function gdb-conf {
if [ "$#" -lt 1 ]; then
echo "Usage: gdb-conf configure-path [additional args...]"
return
fi
conf=$1
shift 1
22:56:51 in ~/evelek
➜ cat main.c
#include <iostream>
int main() {
// below is a result of `pwn cyclic -n 8 1000` string added to `'a`' character
std::string s = "aaaaaaaabaaaaaaacaaaaaaadaaaaaaaeaaaaaaafaaaaaaagaaaaaaahaaaaaaaiaaaaaaajaaaaaaakaaaaaaalaaaaaaamaaaaaaanaaaaaaaoaaaaaaapaaaaaaaqaaaaaaaraaaaaaasaaaaaaataaaaaaauaaaaaaavaaaaaaawaaaaaaaxaaaaaaayaaaaaaazaaaaaabbaaaaaabcaaaaaabdaaaaaabeaaaaaabfaaaaaabgaaaaaabhaaaaaabiaaaaaabjaaaaaabkaaaaaablaaaaaabmaaaaaabnaaaaaaboaaaaaabpaaaaaabqaaaaaabraaaaaabsaaaaaabtaaaaaabuaaaaaabvaaaaaabwaaaaaabxaaaaaabyaaaaaabzaaaaaacbaaaaaaccaaaaaacdaaaaaaceaaaaaacfaaaaaacgaaaaaachaaaaaaciaaaaaacjaaaaaackaaaaaaclaaaaaacmaaaaaacnaaaaaacoaaaaaacpaaaaaacqaaaaaacraaaaaacsaaaaaactaaaaaacuaaaaaacvaaaaaacwaaaaaacxaaaaaacyaaaaaaczaaaaaadbaaaaaadcaaaaaaddaaaaaadeaaaaaadfaaaaaadgaaaaaadhaaaaaadiaaaaaadjaaaaaadkaaaaaadlaaaaaadmaaaaaadnaaaaaadoaaaaaadpaaaaaadqaaaaaadraaaaaadsaaaaaadtaaaaaaduaaaaaadvaaaaaadwaaaaaadxaaaaaadyaaaaaadzaaaaaaebaaaaaaecaaaaaaed

Based on https://stackoverflow.com/a/27522149

11:00:31 in ~/playground 
➜ cat check_dynlibs.cpp     
#include <iostream>
#include <dlfcn.h>
#include <link.h>

using UnknownStruct = struct unknown_struct {
   void*  pointers[3];
import marshal
import mod
print("Test code:")
print(mod.foo())
print(mod.__doc__)
PYCFILE = '__pycache__/mod.cpython-36.pyc'
with open(PYCFILE, 'rb') as f:
@disconnect3d
disconnect3d / wiechu_sqlalchemy.py
Last active July 3, 2018 20:35
Wiechu from freenode irc asked to show how to do some things in sqlalchemy, so here it is.
# requires `pip install sqlalchemy`
import datetime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine, Column, String, Integer, ForeignKey, DateTime, join, func
from sqlalchemy.orm import Session
import sqlalchemy as sa
import logging
logging.basicConfig()

// copied from http://edoceo.com/notabene/ova-to-vmdk-to-qcow2

Converting OVA for use with KVM / QCOW2

The OVA file is nothing more than a TAR archive, containing the .OVF and .VMDK files. Easy!

Using Evergreen ILS for example:

~ $ file Evergreen_trunk_Squeeze.ova
Evergreen_trunk_Squeeze.ova:                POSIX tar archive (GNU)
@disconnect3d
disconnect3d / setu.py
Created May 29, 2018 20:53
py3 c module distutils builder
from distutils.core import setup, Extension
mod = Extension('my_types', sources=['my_types.c'])
setup(
name='PackageName',
version='1.0',
description='This is a demo package',
ext_modules=[mod]
)
@disconnect3d
disconnect3d / breakprefix.py
Last active May 22, 2018 09:07
GDB command that adds a break with prefix functionality; load in GDB with `source breakprefix.py`
"""
Adds a command to GDB that let you specify prefix for a breakpoint.
E.g. you want to invoke `z foo` and make it so that it creates a breakpoint on `packageX.foo`.
With this command you just do `z prefix packageX.` and then `z SOMETHING` will
set a breakpoint at `packageX.SOMETHING`.
For more info on GDB API refer to its docs:
https://sourceware.org/gdb/onlinedocs/gdb/Commands-In-Python.html#Commands-In-Python
"""
import gdb