Skip to content

Instantly share code, notes, and snippets.

@GabrielL
GabrielL / gist:51240
Created January 23, 2009 22:38
Preuve de code simple
length :: [a] -> Int
length [] = 0
length (h:t) = 1 + length t
Prouver que la propriété P :
length [ l1 ++ l2 ] = length l1 + length l2
----------------
Montrons P([], [])
/**
* Determine le type de base d'un pointeur
* @{
*/
template <typename T>
struct BaseType
{
typedef T base_type;
};
@GabrielL
GabrielL / Makefile
Created November 25, 2010 10:35
llvm IR generation in C
CC = gcc
CXX = g++
CFLAGS = `llvm-config --cflags`
LDFLAGS = `llvm-config --libs --cflags --ldflags core analysis executionengine jit interpreter native`
# c++ compiler needed here for -lstdc++
fac:fac.o
$(CXX) $^ -o $@ $(LDFLAGS)
@GabrielL
GabrielL / call_me_later.c
Created August 2, 2011 15:19
Call me Later !
#include <err.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#define OFFSET_PARAM 0x2
#define OFFSET_ADDR (OFFSET_PARAM + 8 + 2)
@GabrielL
GabrielL / tokenize.c
Created August 17, 2011 13:28
Simple use case for strsep
#include <stdio.h>
#include <string.h>
/*
* Split the argument by ','
*/
int main(int argc, char **argv)
{
char *token;
char *string = argv[1];
@GabrielL
GabrielL / syslog.c
Created August 17, 2011 15:14
syslog example
#include <stdarg.h>
#include <stdlib.h>
#include <syslog.h>
void log_err(const char *format, ...)
{
va_list ap;
va_start(ap, format);
syslog(LOG_ERR, format, ap);
va_end(ap);
@GabrielL
GabrielL / output
Created February 17, 2012 10:32
Errors in number of function not implemented in dmd
$ dmd -c toot.d
toot.d(6): Error: class toot.B interface function A.foo isn't implemented
toot.d(10): Error: class toot.C interface function A.foo isn't implemented
toot.d(10): Error: class toot.C interface function A.foo isn't implemented
toot.d(14): Error: class toot.D interface function A.foo isn't implemented
toot.d(10): Error: class toot.C interface function A.foo isn't implemented
toot.d(14): Error: class toot.D interface function A.foo isn't implemented
@GabrielL
GabrielL / alias_method.rb
Created May 24, 2012 22:56
Simulating a Loaded Dice in a Constant Time
#
# Implemented from http://web.eecs.utk.edu/~vose/Publications/random.pdf
# and http://scriptogr.am/jj/post/simulating-a-loaded-dice-in-a-constant-time
#
class AliasMethod
def initialize(probs)
@probability = probs
@alias_numbers = [ -1 ] * @probability.size
@GabrielL
GabrielL / setup.sh
Last active November 11, 2023 16:04
build cross-compiling gcc
#!/bin/sh
binutils_version=2.23
gcc_version=4.7.2
gdb_version=7.5.1
newlib_version=2.0.0
export TARGET=i386-none-elf
export PREFIX=/opt/cross

Writeup net300 (ebCTF teaser 2013)

by tsuro and comawill (Stratum 0 https://stratum0.org)

Step 1: Reverse engineering

Here is what the program does:

  • It opens an socket(AF_INET, SOCK_RAW, 0xfe)
  • and waits with an resvmsg for incoming packets
  • each packet will be 'parsed' (extracts source_addr of the packet and skips the remaining part)
  • expexts the first four bytes of the payload as length of payload - 4