Skip to content

Instantly share code, notes, and snippets.

@Storyyeller
Storyyeller / jacobi.py
Created December 16, 2018 01:05
Implementation of the Jacobi symbol
_s2 = {1:1, 3:-1, 5:-1, 7:1}
def jacobi(a,n):
a = a % n
assert(a)
res = 1
while not a&1:
res *= _s2[n % 8]
a = a//2
@Storyyeller
Storyyeller / besquare.py
Created December 16, 2018 00:45
Besquare challenge for 2014 Greyhat crypto CTF
from hashlib import sha512,sha1
import random,sys,struct
import SocketServer
import base64 as b64
import os
import hmac
from time import time
password = open('password.txt','rb').read()
flag = open('flag.txt','rb').read()
@Storyyeller
Storyyeller / csaw.py
Created December 16, 2018 00:09
2013 CSAW qualifier challenge by Ben Agre
from hashlib import sha512,sha1
import random,sys,struct
import SocketServer
import base64 as b64
import os
import hmac
from time import time
// Modified version of https://github.com/cdiggins/type-inference/blob/5491b3454e02a86c2b7c7a91882b310fb687fed7/test.ts
// that demonstrates the inability to type expressions which require higher ranked types
import { TypeInference as ti } from "./type_inference";
import { Myna as m } from "./node_modules/myna-parser/myna";
var verbose = false;
// Defines syntax parsers for type expressions and a simple lambda calculus
function registerGrammars()
function Child(...args) {
const {constructor} = Object.getPrototypeOf(homeObject);
const $this = Reflect.construct(constructor, args, new.target);
// initialize subclass properties
$this.x = 43;
return $this;
}
Object.setPrototypeOf(Child, Base);
Object.setPrototypeOf(Child.prototype, Base.prototype);
function Child(...args) {
const {constructor} = Object.getPrototypeOf(homeObject);
const $this = Reflect.construct(constructor, args);
// initialize subclass properties
$this.x = 43;
return $this;
}
Object.setPrototypeOf(Child, Base);
function Base() {}
Base.prototype.foo = function() {return 'foo in Base';};
Base.bar = function() {return 'bar in Base';};
function Child() {}
Object.setPrototypeOf(Child, Base);
Object.setPrototypeOf(Child.prototype, Base.prototype);
const homeCtor = Child;
const homeProto = Child.prototype;
class Base {
foo() {return 'foo in Base';}
static bar() {return 'bar in Base';}
}
class Child extends Base {
foo() {return super.foo();}
static bar() {return super.bar();}
}
const obj = new Child;
const obj = {
msg: 'Hello, ',
print() {
return this.msg + super.msg;
},
};
Object.setPrototypeOf(obj, {
msg: 'world!',
});
function Base() {}
Base.prototype.foo = function() {return 'foo in Base';};
function Child() {}
Object.setPrototypeOf(Child, Base);
Object.setPrototypeOf(Child.prototype, Base.prototype);
const homeObject = Child.prototype;
Child.prototype.foo = function() {return 'foo in Child';};
Child.prototype.bar = function() {