Skip to content

Instantly share code, notes, and snippets.

@aaronyoo
aaronyoo / lru.cpp
Created October 14, 2021 23:33
lru.cpp
LRU Cache
insert -- touch the value, update the value
init -- initialize w/ capacity
get -- get the value associated w/ key. touch the value
keep track of the LRU
Assumptions
1. key is an int, value is an int
(setq inhibit-startup-message t)
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
exception ImplementMe
type t = True | False | If of t * t * t | Int of int | Plus of t * t | Greater of t * t
let isval t =
match t with
True|False -> true
| Int _ -> true
| _ -> false
; Function Attrs: noinline nounwind ssp
define void @"dummy_function(Dummy&, long, long, long)"({ i64, i64, i64 }* %dummy, i64 %i, i64 %j, i64 %k) local_unnamed_addr #0 {
%1 = tail call i8* @llvm.returnaddress(i32 0)
%2 = ptrtoint i8* %1 to i64
%3 = ptrtoint { i64, i64, i64 }* %dummy to i64
%4 = getelementptr inbounds { i64, i64, i64 }, { i64, i64, i64 }* %dummy, i64 0, i32 0
store i64 %i, i64* %4, align 8
%5 = add i64 %3, 8
%6 = inttoptr i64 %5 to i64*
store i64 %j, i64* %6, align 8
; Function Attrs: noinline nounwind ssp
define void @"dummy_function(Dummy&, long, long, long)"({ i64, i64, i64 }* %dummy, i64 %i, i64 %j, i64 %k) local_unnamed_addr #0 {
%1 = tail call i8* @llvm.returnaddress(i32 0)
%2 = ptrtoint i8* %1 to i64
%3 = tail call %struct.Memory* @__remill_write_memory_64(%struct.Memory* null, i64 14096, i64 %2)
%4 = tail call %struct.Memory* @__remill_write_memory_64(%struct.Memory* %3, i64 14088, i64 0) #4
%5 = ptrtoint { i64, i64, i64 }* %dummy to i64
%6 = tail call %struct.Memory* @__remill_write_memory_64(%struct.Memory* %4, i64 %5, i64 %i) #4
%7 = add i64 %5, 8
%8 = tail call %struct.Memory* @__remill_write_memory_64(%struct.Memory* %6, i64 %7, i64 %j) #4
@aaronyoo
aaronyoo / setup_ctfd.py
Created April 7, 2019 01:27
Python script to do some setup operations on CTFd
import requests
import re
def main():
print("starting")
# Set the admin cookie before doing anything else
my_cookie = {
"name":"admin",
"value":"true"
#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#define PARASITE_SIZE 8824
int main(int argc, char **argv) {
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
int main(int argc, char **argv) {
if (argc != 3) {
printf("Usage: ./infect [host] [parasite]\n");
exit(0);
}
@aaronyoo
aaronyoo / elfparse.c
Created December 31, 2018 04:27
Simple elf parser.
#include <stdint.h>
#include <stdlib.h>
#include <elf.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
void readElfHeader(Elf64_Ehdr *ehdr);
int main(int argc, char **argv) {