Skip to content

Instantly share code, notes, and snippets.

View mfukar's full-sized avatar

Michael Foukarakis mfukar

View GitHub Profile
@mfukar
mfukar / patchone.asm
Created May 13, 2012 10:05
pctf '12 - supercomputer patches
; 0x400cb0:
mov rax,qword [rbp-0x20]
add qword [rbp+0x10],rax
add qword [rbp+0x18],rax
add qword [rbp+0x20],rax
add qword [rbp+0x28],rax
add qword [rbp-0x8],rax
jmp 0x3f
@mfukar
mfukar / patchtwo.asm
Created May 13, 2012 10:12
pctf '12 - supercomputer patches
; 0x400ef8:
mov rax,qword [rbp+0x20]
mov edx,eax
sar edx,0x1f
xor eax,edx
sub eax,edx
cdqe
mov qword [rbp-0x8],rax
imul rax,qword [rbp+0x18]
add qword [rbp+0x10],rax
@mfukar
mfukar / patchthree.asm
Created May 13, 2012 10:30
pctf '12 - supercomputer patches
; 0x4010e9:
mov rax,qword [0x601d38]
imul rax,rax,0xf7733c1
add qword [rbp-0x8],rax
add qword [rbp-0xc],0xf7733c1
mov rax,qword [rbp-0x8]
xor rdx,rdx
mov rcx,0x10bebc1fb ; the # in 2's complement from the original
div rcx
mov qword [rbp-0x8],rdx
@mfukar
mfukar / patchfour.asm
Created May 13, 2012 10:45
pctf '12 - supercomputer patches
; 0x401348:
jmp 0x145 ; these clothes are a little tight, but the price was right
@mfukar
mfukar / inspector_malloc.gdb
Last active May 9, 2023 11:04
gdb functions to dump glibc malloc arenas + chunks
define -mem-heap-dump-chunk
printf "%#016x: ", $mem_addr
printf "%016lu %016lu %#02x ", ((long *)$mem_addr)[0], ((long *)$mem_addr)[1] & ~3, ((long*)$mem_addr)[1] & 3
printf "%016x %016x\n", ((long *)$mem_addr)[2], ((long *)$mem_addr)[3]
set $mem_addr = $mem_addr + ((long *)$mem_addr)[1] & ~3
end
document -mem-heap-dump-chunk
!!! FOR INTERNAL USE ONLY - DO NOT CALL !!!
end
@mfukar
mfukar / sort1mb.cpp
Created November 5, 2012 04:41 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@mfukar
mfukar / epic_fail_1.c
Last active December 16, 2015 10:28
Epic Fail UCS-2 to UTF-8 conversion.
/* This is how a PhD holder thinks UCS-2 is converted to UTF-8 */
size_t gsm_convert_ucs2(const uint8_t *buf, size_t length, unsigned char *dest)
{
size_t i;
size_t j;
for (i=0,j=0;i<length;i+=2) {
if (buf[i] == 0)
dest[j++] = buf[i+1];
else {
snprintf((char *)&dest[j], 256-j, "\\%02x%02x", buf[i], buf[i+1]);
/*
* Partial applied functions in C
* Leandro Pereira <leandro@tia.mat.br>
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
@mfukar
mfukar / ants.clj
Created February 13, 2014 12:22 — forked from michiakig/ants.clj
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@mfukar
mfukar / dotd.py
Last active December 30, 2016 08:22
Log analyser for Dawn of the Dragons raids. Overengineered as fuck.
#!/usr/bin/env python
# @file dotd.py
# @author Michael Foukarakis
# @version 0.6
# @date Created: Sun Aug 25, 2013 09:57 BST
# Last Update: Fri Dec 30, 2016 10:21 EET
#------------------------------------------------------------------------
# Description: Log analyser for Dawn of the Dragons raids.
#------------------------------------------------------------------------
# History: None yet