Skip to content

Instantly share code, notes, and snippets.

View DavidBuchanan314's full-sized avatar
🌍
Hack the planet!

David Buchanan DavidBuchanan314

🌍
Hack the planet!
View GitHub Profile
# This code is very slow, and only cracks one key byte at a time. Choose which byte by changing keyi:
keyi = 0
import matplotlib.pyplot as plt
import numpy as np
ins = []
outs = []
samples = []
"""/*
5616f5962674d26741d2810600a6c5647620c4e3d2870177f09716b2379012c342d3b584c5672195d653722443f1c39254360007010381b721c741a532b03504d2849382d375c0d6806251a2946335a67365020100f160f17640c6a05583f49645d3b557856221b2
*/
function my_encrypt($flag, $key) {
$key = md5($key);
$message = $flag . "|" . $key;
$encrypted = chr(rand(0, 126));
for($i=0;$i<strlen($message);$i++) {
$encrypted .= chr((ord($message[$i]) + ord($key[$i % strlen($key)]) + ord($encrypted[$i])) % 126);
"""
This script "pastes" data into an arbitrary X11 window - useful for transfering files onto a VM where real pasting isn't set up.
Currently, it is configured to base64 encode a file, and type it out such that it is decoded into a file on the remote system.
"""
import Xlib
from Xlib.display import Display
import Xlib.XK
import time
import sys
# Solution to SquareCTF "Seventeen"
# echo -ne "sandflea\n\x00" | python 17.py
import re
import sys
def parse(data):
labels = {}
instructions = []
"""
Making UML Diagrams sucks. This script converts a .java file to "umlet" syntax, which can be used to generate a full UML diagram:
http://www.umlet.com/umletino/umletino.html
The only thing left to do is add the arrows to the diagram.
"""
import sys
import javalang
@DavidBuchanan314
DavidBuchanan314 / spectre.c
Last active January 4, 2018 01:13 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
#include <libtransistor/nx.h>
#include <stdio.h>
#include <stdint.h>
#define ASSERT_OK(label, expr) if((r = expr) != RESULT_OK) { \
printf("assertion failed at %s:%d: result 0x%x is not OK\n", __FILE__, __LINE__, r); \
goto label; \
}

Using the fs-net libtransistor fork

This guide assumes you are already familliar with setting up RetroArch with libtransistor.

Clone the fs-net branch from https://github.com/davidbuchanan314/libtransistor:

git clone https://github.com/davidbuchanan314/libtransistor --recursive -b fs-net

Build libtransistor as usual.

import struct
def unpack_struct(struct_spec, data, offset):
names, fmt = zip(*struct_spec)
result = {k:v for k, v in zip(names, struct.unpack_from("<"+"".join(fmt), data, offset))}
result.pop("unk", None)
return result
def print_dict(name, data):
print("\n{} = {{".format(name))
from capstone import *
from unicorn import *
from unicorn.x86_const import *
from syscall_dat import *
import struct
LOAD_ADDR = 0x08048000
STACK_PTR = 0xffff0000
SYS_ARGS = [UC_X86_REG_EBX, UC_X86_REG_ECX, UC_X86_REG_EDX, UC_X86_REG_ESI, UC_X86_REG_EDI]