Skip to content

Instantly share code, notes, and snippets.

@aaronyoo
aaronyoo / vigenere.py
Created September 5, 2018 00:30
Breaking the Vigenere Cipher
import base64
from collections import Counter
# English language letter frequencies from:
# https://gist.githueb.com/pozhidaevak/0dca594d6f0de367f232909fe21cdb2f
letterFrequency = {'E' : 12.0, 'T' : 9.10, 'A' : 8.12, 'O' : 7.68,
'I' : 7.31, 'N' : 6.95, 'S' : 6.28, 'R' : 6.02,
'H' : 5.92, 'D' : 4.32, 'L' : 3.98, 'U' : 2.88,
'C' : 2.71, 'M' : 2.61, 'F' : 2.30, 'Y' : 2.11,
@aaronyoo
aaronyoo / ptrace_trick_1.c
Created September 5, 2018 00:50
A simple ptrace-trick example
#include <stdio.h>
#include <sys/ptrace.h>
int main() {
if (ptrace(PTRACE_TRACEME, 0, 1, 0) == -1) {
printf("Debugger\n");
} else {
printf("Normal\n");
}
return 0;
@aaronyoo
aaronyoo / ptrace_inject.c
Last active September 5, 2018 03:55
A ptrace injection.
// This is a redefinition of ptrace to get around the
// ptrace anti-debug trick.
long ptrace(int a, int b, void *c, void *d) {
return 0;
}
@aaronyoo
aaronyoo / cictro-hash.py
Created November 21, 2018 07:33
An implementation of CictroHash
def pad(txt):
while (len(txt) % 4 != 0):
txt += '\0'
return txt
def create_w(s):
w = [[s[0], s[1], s[2], s[3]],
[s[4], s[5], s[6], s[7]]]
return w
@aaronyoo
aaronyoo / cictro-hash-birthday.py
Created November 21, 2018 07:39
The birthday attack portion of the CictroHash
birthday_dict = {}
while (True):
pre = "".join(random.choices(string.ascii_letters + string.digits, k = random.randint(1, 5)))
hash_val = hash(pre)
if (hash_val in birthday_dict and birthday_dict[hash_val] != pre):
print(pre, birthday_dict[hash_val])
else:
birthday_dict[hash_val] = pre
@aaronyoo
aaronyoo / flipping-bits.py
Created November 22, 2018 02:10
Solution script to SquareCTF flipping-bits challenge
import binascii
import gmpy2
e1 = 13
e2 = 15
ct1 = 13981765388145083997703333682243956434148306954774120760845671024723583618341148528952063316653588928138430524040717841543528568326674293677228449651281422762216853098529425814740156575513620513245005576508982103360592761380293006244528169193632346512170599896471850340765607466109228426538780591853882736654
ct2 = 79459949016924442856959059325390894723232586275925931898929445938338123216278271333902062872565058205136627757713051954083968874644581902371182266588247653857616029881453100387797111559677392017415298580136496204898016797180386402171968931958365160589774450964944023720256848731202333789801071962338635072065
n = 103109065902334620226101162008793963504256027939117020091876799039690801944735604259018655534860183205031069083254290258577291605287053538752280231959857465853228851714786887294961873006234153079187216285516823832102424110934062954272346111907571393964363630079343598511602013316604641904852018969178919051627
def xgcd(a,b):
"""Extended GCD
@aaronyoo
aaronyoo / angerme.py
Created December 17, 2018 01:57
Solution to angerme
import angr
# Load the binary
import angr
proj = angr.Project('angrme')
# Create a simulation manager
simgr = proj.factory.simgr()
# Use the simulation manager to explore until win condition --> :)
@aaronyoo
aaronyoo / example.c
Created December 28, 2018 20:13
Example C program from Learning Linux Binary Analysis
#include <stdio.h>
int func1(int a, int b, int c) {
printf("%d %d %d\n", a, b, c);
}
int main(void) {
func1(1, 2, 3);
}
@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) {
#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);
}