Skip to content

Instantly share code, notes, and snippets.

View karanlyons's full-sized avatar

Karan Lyons karanlyons

View GitHub Profile
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
from copy import deepcopy
from django.db import models
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
from contextlib import contextmanager
from os import getpid
from random import getrandbits
@karanlyons
karanlyons / sha512.cpp
Created July 4, 2017 08:35
SHA-512 in C“++”
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstring>
using namespace std;
const uint64_t k[] = {
UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd), UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc),
@karanlyons
karanlyons / parse.html
Created July 9, 2017 10:34
Javascript QTFF/MP4 Parser
<html>
<body>
<script>
'use strict';
ArrayBuffer.prototype.toSource = function(hex) {
var buf = this,
bytes = Array.prototype.slice.call(new Uint8Array(buf)),
i = buf.byteLength,
blank = true;
@karanlyons
karanlyons / method_missing.py
Last active August 7, 2017 17:47
method_missing for Python: All the headaches of Ruby, now with added whitespace!
import dis
import inspect
class MethodMissingMixin:
def __getattr__(self, attr):
if hasattr(getattr(self, '__methodmissing__', None), '__call__'):
parent_frame = inspect.currentframe().f_back
instructions = dis.get_instructions(parent_frame.f_code)
@karanlyons
karanlyons / solver.py
Last active January 2, 2023 06:41
Why PRNGs are not the same as CSPRNGs
import z3
def sym_xoroshiro128plus(solver, sym_s0, sym_s1, mask, result):
s0 = sym_s0
s1 = sym_s1
sym_r = (sym_s0 + sym_s1)
condition = z3.Bool('c0x%0.16x' % result)
solver.add(z3.Implies(condition, (sym_r & mask) == result & mask))
@karanlyons
karanlyons / splatify.js
Created August 29, 2017 22:39
splatify.js: Add some venom to your coffee
function splatify(func) {
args_string = func.toString().split('(')[1].split(')')[0].split(',').map(function(s) { return s.trim(); });
if (args_string.length && args_string[args_string.length - 1] === 'splat_args') {
pivot = args_string.length - 1;
return function () {
if (arguments.length > pivot + 1) {
args = Array.prototype.slice.call(arguments, 0, pivot);
args.push(Array.prototype.slice.call(arguments, pivot));
@karanlyons
karanlyons / README.md
Created September 25, 2017 15:45
Headspace Challenge

Headspace Challenge

Requirements

  • Python >=3.5 (compiled with sqlite3 support)
  • That’s it.
  • This may have been a bad idea.

Get Started

import os
from http.client import HTTPSConnection
from time import sleep
def request():
connection = HTTPSConnection('httpbin.org')
connection.request('GET', '/headers')
return connection.getresponse().read()
<html>
<head>
<style>
#left, #right, #test {
display: block;
z-index: 0;
}
#left {
float: left;