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 / macinfo.py
Created February 24, 2014 19:13
Retrieve interface manufacturer from MAC address
#!/usr/bin/python
#-*- coding: iso-8859-15 -*-
###################################################################
# macinfo by unixtrem #
# #
# this script shows the vendor of a mac address #
# you can use different syntaxes to get the result and the script #
# automatically parses your entered MAC for more speed. #
# #
@RobinDavid
RobinDavid / is_vm.c
Created February 24, 2014 20:39
Know if we are on a virtual machine thank's to the processor cache trick
#include <stdio.h>
int main () {
unsigned char m[2+4], rpill[] = "\x0f\x01\x0d\x00\x00\x00\x00\xc3";
*((unsigned*) & rpill[3]) = (unsigned)m;
((void(*)()) & rpill)();
printf ("idt base: %#x\n", *((unsigned*) & m[2]));
if (m[5]>0xd0) {
printf ("Inside Matrix!\n", m[5]);
@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 / html_parser.py
Created February 24, 2014 20:48
html parser in python to extract h1 text
from html.parser import HTMLParser #Import the parser
class HeadingParser(HTMLParser): #create a subclass of HTMLParser which will overload handle..
inHeading = False
def handle_starttag(self, tag, attrs): #Triggered when an opening tag is encountered
if tag == "h1": #if the tag is &lt;h1&gt;
self.inHeading = True #Change a variable which says we are in an header
print("Found a Heading 1")
def handle_data(self, data): #Triggered when data found (the content of the tag)
if self.inHeading: #Useless, used just to filter content of h1's
@RobinDavid
RobinDavid / rc4.py
Created February 24, 2014 21:16
RC4 algorithm implementation
def RC4(data, key):
x = 0
s = range(256)
for i in range(256):
x = (x + s[i] + ord(key[i % len(key)])) % 256
s[i], s[x] = s[x], s[i]
x = y = 0
out = ""
for c in data:
x = (x + 1) % 256
@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 / pydbg_hook_printf.py
Created February 25, 2014 17:29
Pydbg: sample hook printf function of a process
from pydbg import *
from defines import *
import struct
import random
def printf_randomizer(dbg):
# Read in the value of the counter at ESP + 0x8 as a DWORD
parameter_addr = dbg.context.Esp + 0x8
counter = dbg.read_process_memory(parameter_addr,4) #will be trigger when counter=4
@RobinDavid
RobinDavid / pydbg_access_violation.py
Last active April 25, 2017 10:03
Pydbg: sample hook exception (access violation)
'''
#This commented program is vulnerable to a buffer overflow (copy it in a separate file)
from ctypes import *
msvcrt = cdll.msvcrt
raw_input("Once the debbuger is attached press any key") # Give the debugger time to attach, then hit a button
buffer = c_char_p("AAAAA") # Create the 5-byte destination buffer