Skip to content

Instantly share code, notes, and snippets.

View Justasic's full-sized avatar
🏍️
Making computers do things they don't want to

NightShadow Justasic

🏍️
Making computers do things they don't want to
View GitHub Profile
@Justasic
Justasic / EventDispatcher.h
Last active August 29, 2015 13:56
This is an (experimental) event dispatcher which binds functions to specific events. When an event call happens, all functions are called with the same arguments.
#pragma once
#include <functional>
#include <vector>
template<class... arguments__>
class Event
{
protected:
std::vector<std::function<bool(arguments__...)>> callables;
@Justasic
Justasic / BasicKeygenExample.cpp
Created March 19, 2014 01:05
This was just a template keygen I use for solving crackmes on http://crackmes.de/
#include <Windows.h>
#include <malloc.h>
#include <tchar.h>
#include <string>
#include <cstring>
#include <memory.h>
#include <cstdlib>
inline LPWSTR char2wchar(const char *str)
{
@Justasic
Justasic / corruptstack.c
Last active August 29, 2015 14:00
A dumb program that corrupts the stack and displays examples of different crashes. Useful to force an application crash without throwing compiler warnings.
#include <stdio.h>
#include <stdlib.h>
#if 0
void __attribute__((naked)) stackcorrupt(void)
{
// Push EAX to the stack (some random value in eax)
__asm__ __volatile__("pushl %eax");
// return, corrupted stack returns to garbage and program crashes.
__asm__ __volatile__("ret");
@Justasic
Justasic / test.asm
Last active August 29, 2015 14:00
Example of executing bytes from an array
; Compile with nasm -f elf64 test.asm
BITS 64
SECTION .text
global _start
_start:
sub rsp, 8 ; Align the stack pointer for a function call
mov rax, 0x14 ; Move syscall number 14 to rax (sys_getpid)
int 0x80 ; Call system call
push rax ; push rax to the stack
mov rbx, rax ; move rax to rbx
@Justasic
Justasic / freestanding.c
Last active August 29, 2015 14:01
This is a hello world example on linux without using the C standard library or any dynamic libs.
unsigned long int LinuxWrite(unsigned fd, const char *str, unsigned long len)
{
unsigned long ret = -1;
__asm__ __volatile__("int $0x80" : "=a" (ret) : "a" (4), "b" (fd), "c" (str), "d" (len));
return ret;
}
void LinuxExit(int code)
{
__asm__ __volatile__ ("int $0x80" :: "a" (1), "b" (code));
@Justasic
Justasic / Makefile
Created May 27, 2014 08:20
Basic (probably not working) calculator using flex/bison
CC=clang
CFLAGS=-Wall
LDFLAGS=-lfl
all:
bison -d calculator.y
flex calculator.l
$(CC) $(CFLAGS) -c scanner.c -o scanner.o
from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor, protocol
from twisted.protocols.basic import LineReceiver
from twisted.python import log
import sys, time
class Channel():
def __init__(self, name, ctime, modes):
self.name = name
@Justasic
Justasic / dlloader.cpp
Created July 8, 2014 17:50
An example class which shows how you can associate a shared object with a class in linux.
/* This file is public domain although credit would be nice :) */
#include <unistd.h>
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <dlfcn.h>
#include <cassert>
@Justasic
Justasic / cringe.cpp
Created July 26, 2014 00:44
Who needs C++ standards! Undefined behavior is way more fun!
void HandleEvents(HWND hwnd, UINT message, WPARAM wParam, LPARAM lparam)
{
switch (LOWORD(wParam))
{
case 1: // "Scan" button
{
//MessageBox(NULL, L"Scan button", L"You clicked scan", MB_OK);
// Disable the window, get the text from it, then start the scan threads.
HWND txtbox = GetDlgItem(hwnd, 8);
Edit_Enable(txtbox, FALSE);
@Justasic
Justasic / timingsafestringcompare.cpp
Created July 28, 2014 01:27
Some code on doing timing safe string comparison functions made by Aquanight and Attilamolnar from ChatSpike
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <unistd.h>
#include <cstdlib>
#include <vector>
#include <chrono>
bool AquaConstTimeCMP(const std::string &str1, const std::string &str2)