This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import pickletools | |
import payload_crafter | |
class RunLengthCrafter(payload_crafter.Crafter): | |
def __init__(self, *, check_stop=False) -> None: | |
super().__init__(check_stop=check_stop) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utility functions | |
// convert float64 <-> uint64 | |
let buf = new ArrayBuffer(8); | |
let float_buf = new Float64Array(buf); | |
let uint_buf = new BigUint64Array(buf); | |
function f2i(v) { | |
float_buf[0] = v; | |
return uint_buf[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utility functions | |
// convert float64 <-> uint64 | |
let buf = new ArrayBuffer(8); | |
let float_buf = new Float64Array(buf); | |
let uint_buf = new BigUint64Array(buf); | |
function f2i(v) { | |
float_buf[0] = v; | |
return uint_buf[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utility functions | |
// convert float64 <-> uint64 | |
let buf = new ArrayBuffer(8); | |
let float_buf = new Float64Array(buf); | |
let uint_buf = new BigUint64Array(buf); | |
function f2i(v) { | |
float_buf[0] = v; | |
return uint_buf[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only tested by `./d8 exploit.js` | |
// utility functions | |
// convert float64 <-> uint64 | |
let buf = new ArrayBuffer(8); | |
let float_buf = new Float64Array(buf); | |
let uint_buf = new BigUint64Array(buf); | |
function f2i(v) { | |
float_buf[0] = v; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Optional | |
def calc_f(f: List[int], x: int, m: Optional[int]=None) -> int: | |
ret = 0 | |
for i, a in enumerate(f): | |
term = a * x**i | |
if m is not None: | |
term %= m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Util.number import getPrime, getRandomInteger, long_to_bytes | |
# ceil(numerator / denominator) | |
def frac_ceil(numerator, denominator): | |
if numerator % denominator == 0: | |
return numerator // denominator | |
return numerator // denominator + 1 | |