Skip to content

Instantly share code, notes, and snippets.

View RobinDavid's full-sized avatar

Robin David RobinDavid

View GitHub Profile
@RobinDavid
RobinDavid / blow.sh
Last active August 29, 2015 13:56
Bash script to download all zip or rar files from a website
#!/bin/bash
lien="$1"
dossier=""
exclure="$2"
wget -nv -nc -nd -X $exclure -r -linf -A zip,rar $lien
for file in `ls` do
if ( expr "$file" : .*rar$ ) > /dev/null
then
@RobinDavid
RobinDavid / jython_test.py
Created February 24, 2014 20:45
Just a sample of Jython script to use swing
#!/usr/bin/env jython
#-*- encoding:utf-8 -*-
from java.lang import System
from javax.swing import JFrame, JButton, JLabel
from java.awt import BorderLayout
# Exit application
def exitApp(event):
System.exit(0)
@RobinDavid
RobinDavid / pyunit_struct.py
Created February 25, 2014 17:19
Sample of a Pyunit test
import unittest
class Test1 (unittest.TestCase): #Define a class which extend unittest
def runTest(self):
self.failIf (1+1 != 2, '1+1 failed !')
def suite():
suite = unittest.TestSuite() #create an object testsuite
suite.addTest(Test1())
return suite
@RobinDavid
RobinDavid / server_adv.py
Created February 25, 2014 17:24
Another sample of python server
#!/usr/bin/env python
#-*- encoding: utf-8 -*-
import SocketServer
class EchoRequestHandler(SocketServer.BaseRequestHandler):
def setup(self):
print self.client_address, 'connected!'
self.request.send('hi ' + str(self.client_address) + '\n')
@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
@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 / 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 / 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 / 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 / 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