Skip to content

Instantly share code, notes, and snippets.

def handle(self):
nonce = os.urandom(8)
self.wfile.write(nonce)
import socket
import itertools
import struct
import string
import sys
def send_data( rsocket, data ):
length = struct.pack('I',len(data))
rsocket.send(length)
def encrypt(data, ctr):
aes = AES.new(ENCRYPT_KEY, AES.MODE_CTR, counter=ctr)
return aes.encrypt(zlib.compress(data))
@rikaardhosein
rikaardhosein / compression.py
Created April 22, 2013 01:49
PlaidCTF - compression
#!/usr/bin/python
import os
import struct
import SocketServer
import zlib
from Crypto.Cipher import AES
from Crypto.Util import Counter
# Not the real keys!
ENCRYPT_KEY = '0000000000000000000000000000000000000000000000000000000000000000'.decode('hex')
@rikaardhosein
rikaardhosein / sale.cpp
Last active October 11, 2015 18:37
Sale Problem
//Rikaard Hosein
//811004653
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <memory.h>
using namespace std;
#define _DEBUG_
if ((unsigned long)(nb) <= (unsigned long)(get_max_fast ()))
{
idx = fastbin_index(nb);
mfastbinptr* fb = &fastbin (av, idx);
mchunkptr pp = *fb;
do
{
victim = pp;
if (victim == NULL)
break;
<?php
if( isset($_COOKIE['username']) )
{
if( strcmp($_COOKIE['username'],"Jane") == 0)
{
echo "You have successfully logged in as Jane!";
}
}
?>
@rikaardhosein
rikaardhosein / gist:2466997
Created April 22, 2012 21:20
av_malloc_p2
#if CONFIG_MEMALIGN_HACK
ptr = malloc(size+ALIGN);
if(!ptr)
return ptr;
diff= ((-(long)ptr - 1)&(ALIGN-1)) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
@rikaardhosein
rikaardhosein / gist:2466932
Created April 22, 2012 21:05
av_malloc_p1
/* let's disallow possible ambiguous cases */
if (size > (max_alloc_size-32))
return NULL;
@rikaardhosein
rikaardhosein / gist:2466747
Created April 22, 2012 20:40
libavutil's av_malloc
void *av_malloc(size_t size)
{
void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
/* let's disallow possible ambiguous cases */
if (size > (max_alloc_size-32))
return NULL;