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 / 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 / circle.c
Last active December 24, 2021 11:21
Having a bit of fun with GLFW and circles! Compile with: clang -Wall -Wextra -std=c11 -g circle.c -o circle -lm -lGL -lglfw
#define _BSD_SOURCE 2387423
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <stddef.h>
#include <GLFW/glfw3.h>
@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)
@Justasic
Justasic / sizereduce.c
Created August 15, 2014 03:41
A little function which reduces the size (give in bytes) and returns a string with the correct size in a human-readable form. Goes up to Yittabytes so when early quantom computers come around, this function will work in an amd64 emulator :D
// Pointers returns by SizeReduce should be free()'d
char *SizeReduce(size_t size)
{
static const char *sizes[] = {
"B",
"KB",
"MB",
"GB",
"TB",
"PB",
# bigdecoder.py, by aderyn@gmail.com, 2009-03-01
#
# decoder for .BIG-format files utilized by Red Alert 3 and C&C: Zero Hours
# among others. .big is a trivial archival format. quite frankly, this is
# probably the simplest compound file format imaginable.
#
# this script is written for microsoft windows. it can probably be easily
# adapted for other platforms, but i haven't tried.
#
# file structure: