Skip to content

Instantly share code, notes, and snippets.

View RobinDavid's full-sized avatar

Robin David RobinDavid

View GitHub Profile
@RobinDavid
RobinDavid / create_pdf.py
Created April 6, 2017 15:21
Create a pdf from a set of jpg images
from fpdf import FPDF
from path import Path
import sys
imagelist = [x for x in sorted(Path(sys.argv[1]).listdir()) if x.ext == ".jpg"]
pdf = FPDF()
for im in imagelist:
pdf.add_page(orientation="P", format=(410,550)) #Size of images is known
@RobinDavid
RobinDavid / self_checksumming.c
Created February 18, 2017 23:25
PoC to checksum a given portion of the code
#define _GNU_SOURCE
#include <unistd.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <link.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
void *begin;
@RobinDavid
RobinDavid / chg_mprotect.c
Created February 18, 2017 23:22
Changing the right on the text section to make it writeable
#define _GNU_SOURCE
#include <unistd.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <link.h>
#include <errno.h>
/*
- info: pointer to a dl_phdr_info {
ElfW(Addr) dlpi_addr; // Base address of object
@RobinDavid
RobinDavid / debootstrap.sh
Created November 30, 2015 20:02
Bootstrap command for debootstrap
#!/bin/bash
#Do all the partition stuff
#Let's consider we install to sda1
mkdir /media/debian
mount /dev/sda1 /media/debian
@RobinDavid
RobinDavid / wol.sh
Created November 29, 2015 20:04
Enabling WoL Linux
#!/bin/bash
sed -i 's,^\(NETDOWN=\).*,\1'no',' /etc/init.d/halt
aptitude install ethtool -y
echo 'pre-down /usr/sbin/ethool -s eth0 wol g' >> /etc/network/interface
@RobinDavid
RobinDavid / cpuid.cpp
Created January 18, 2015 20:15
Retrieve MMX and SSE support using the CPUID assembly command.
#include <iostream>
using namespace std;
int main(int argc,char* argv[])
{
unsigned int cpeinfo;
unsigned int cpsse3;
__asm__(
"mov $01,%%eax;"
@RobinDavid
RobinDavid / rflags.cpp
Created January 15, 2015 09:22
Get RFLAGS using inline assembly
#include <iostream>
int main(void)
{
unsigned long long var_RFLAGS = 0;
__asm__ (
"pushfq;" // Put RFLAGS into stack
"pop %%rax;" // Pop them in rax
"mov %%rax, %0" : :"m" (var_RFLAGS) // Retrieve them in a variable
@RobinDavid
RobinDavid / tiny32.asm
Last active April 25, 2017 10:03
Tiny ELF 32 (put code into _start)
; From: http://blog.stalkr.net/2014/10/tiny-elf-3264-with-nasm.html
; nasm -f bin -o tiny32 tiny32.asm
BITS 32
org 0x08048000
ehdr: ; Elf32_Ehdr
db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident
times 8 db 0
dw 2 ; e_type
dw 3 ; e_machine
@RobinDavid
RobinDavid / tiny64.asm
Last active April 25, 2017 10:03
Tiny ELF 64 (put code into _start)
; Credits from : http://blog.stalkr.net/2014/10/tiny-elf-3264-with-nasm.html
; nasm -f bin -o tiny64 tiny64.asm
BITS 64
org 0x400000
ehdr: ; Elf64_Ehdr
db 0x7f, "ELF", 2, 1, 1, 0 ; e_ident
times 8 db 0
dw 2 ; e_type
dw 0x3e ; e_machine
@RobinDavid
RobinDavid / chroot.sh
Created February 25, 2014 17:51
script to create an nice chroot to a given folder
#!/bin/bash
ROOT=$1
mount procfs -t proc $ROOT/proc/
mount sysfs -t sysfs
mount -o bin /dev $ROOT/dev/
mount -o bin /dev/pts $ROOT/dev/pts
mount --bind /etc/resolv.conf $ROOT/etc/resolv.conf
chroot $ROOT