Skip to content

Instantly share code, notes, and snippets.

View HugoGuiroux's full-sized avatar

Hugo Guiroux HugoGuiroux

View GitHub Profile
@HugoGuiroux
HugoGuiroux / FilterStream.hpp
Last active June 29, 2020 16:32
Boost stream parser
/*
* An example of stream wrapper around an ssl stream supporting both HTTP and WebSocket requests.
*
* The current version is mainly a copy/paste of the existing boost::asio::ssl stream.
* The filtering logic is inside the mutate method, which takes an iterator on the MutableBufferSequence (it can be greatly improved obviously).
* Currently, only asynchronous reads are mutated, but using mutable for synchronous reads should be easy to do.
*
* Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
* Copyright (c) 2005-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
* Copyright (c) 2018 Hugo Guiroux
@HugoGuiroux
HugoGuiroux / build-kernel.sh
Last active October 26, 2016 11:05
Building kernel
#!/bin/bash
# Script to build a kernel
# Author: Hugo Guiroux <hugo.guiroux@gmail.com>
# Version from command line. Ex: 4.4
VERSION="$1"
echo "Installing dependencies"
apt-get install -y git-core kernel-package fakeroot build-essential libncurses5-dev python-pip wget xz-utils
@HugoGuiroux
HugoGuiroux / Makefile
Created January 12, 2016 09:43
Kernel module tracepoint hook
obj-m := my_module.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
unload:
sudo rmmod ./my_module.ko
load:
sudo insmod ./my_module.ko
@HugoGuiroux
HugoGuiroux / clang_bug.cpp
Created November 8, 2015 09:03
Code generating an optimization bug with clang
#include <iostream>
#include <cstring>
#define LOOP_COUNT 1000000000
unsigned long long rdtscl(void)
{
unsigned int lo, hi;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
@HugoGuiroux
HugoGuiroux / Dockerfile
Last active March 24, 2017 13:23
Dockerfile for Phoenix-2.0. Last version at https://github.com/GHugo/docker-phoenix-2.0/
FROM debian:stable
MAINTAINER Hugo Guiroux <gx.hugo+githubdocker@gmail.com> version: 0.1
# Install tools to build
RUN apt-get update && apt-get install -y \
build-essential \
git \
wget && \
rm -rf /var/lib/apt/lists/*
@HugoGuiroux
HugoGuiroux / rc4.py
Last active August 29, 2015 14:16
RC4 as iterator in Python
#!/usr/bin/env python2
# This is a simple RC4 python2 implementation as an iterator.
#
# Copyright (c) 2015 Hugo Guiroux: http://hugoguiroux.blogspot.fr/
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
@HugoGuiroux
HugoGuiroux / automaton_rule_30.py
Created August 30, 2014 12:29
Successive generations of a celular automaton using rule 30.
#!/usr/bin/python2
# Author: Hugo Guiroux: http://hugoguiroux.blogspot.fr/
import sys
from PIL import Image
import random
# The output image (bmp)
img_name = "wolf.bmp"
@HugoGuiroux
HugoGuiroux / socket_nonblocking.c
Last active August 29, 2015 14:01
Socket non blocking and socket size
/* Author: Hugo Guiroux: http://hugoguiroux.blogspot.fr/ */
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main()
@HugoGuiroux
HugoGuiroux / tor_poc.go
Last active June 14, 2022 14:50
Carry http request through tor in go
// Author: Hugo Guiroux: http://hugoguiroux.blogspot.fr/
package main
import (
"code.google.com/p/go.net/proxy"
"flag"
"fmt"
"io/ioutil"
"log"
"net"