Skip to content

Instantly share code, notes, and snippets.

@rikaardhosein
rikaardhosein / isPalindrome.c
Created April 17, 2012 22:36
Recursive isPlaindrome
bool isPalindrome( char *string, unsigned int l, unsigned int r )
{
if( l >= r )return true;
if( string[l] != string[r] ) return false;
return isPalindrome( string, l+1, r-1 );
}
@rikaardhosein
rikaardhosein / Fib.c
Created April 17, 2012 23:52
Recursive Fibonacci
unsigned int Fib( unsigned int n )
{
if( n == 0 ) return 0;
if( (n==1) || (n==2) ) return 1;
else return Fib(n-1)+Fib(n-2);
}
@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;
@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: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;
<?php
if( isset($_COOKIE['username']) )
{
if( strcmp($_COOKIE['username'],"Jane") == 0)
{
echo "You have successfully logged in as Jane!";
}
}
?>
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;
@rikaardhosein
rikaardhosein / sale.cpp
Last active October 11, 2015 18:37
Sale Problem
//Rikaard Hosein
//811004653
#include &lt;cstdlib&gt;
#include &lt;cstdio&gt;
#include &lt;climits&gt;
#include &lt;memory.h&gt;
using namespace std;
#define _DEBUG_
@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')
def encrypt(data, ctr):
aes = AES.new(ENCRYPT_KEY, AES.MODE_CTR, counter=ctr)
return aes.encrypt(zlib.compress(data))