Skip to content

Instantly share code, notes, and snippets.

View liath's full-sized avatar

John Jones liath

  • Bugcrowd
  • Las Vegas, NV
View GitHub Profile
@liath
liath / ICG-algo.js
Last active March 20, 2020 23:47
Emulating C-style integer maths in javascript
/* eslint no-console:0, func-names:0 */
// JS ints are signed, which isn't useful here. Unfortunately,
// this means << can flip the sign bit and give a negative
// number which throws everything off. Luckily, we know how to
// handle this. The below is an unsigned leftshift implementation.
const ls = (input, shift) => ((input << shift) >>> 1) * 2;
// Integer casts that drop overflowing data (Just like grandma used to make)
const u8 = i => (i << 24) >>> 24;
@liath
liath / exe-metadata.sh
Last active November 30, 2020 19:46
Extracts FileVersion and other fun fields as seen in the Properties dialog for dll and exe files Like https://gist.github.com/Liath/c148ce9f72a64457150e16f2a880e7c4, but this time using only bash, sed, tac, tr, and xxd (which afaik are pretty standard) so hopefully this is portable :)
#!/usr/bin/env bash
FILE=$1
BUF_SIZE=64
function getBytes {
xxd -seek "$1" -len "$2" -p "$FILE" | tr -d '\n'
}
function getIntBytesLE {
@liath
liath / version-extract.js
Last active November 30, 2020 20:06
Extracts FileVersion and other fun fields as seen in the Properties dialog for dll and exe files
const fs = require('fs');
const file = fs.readFileSync(process.argv[2]);
let at = file.readUInt32LE(0x3c);
if (file.slice(at, at + 0x4).toString('utf-8') !== 'PE\x00\x00') {
// bail if not PE header
console.error('Did not see PE magic constant');
process.exit(1);
}
@liath
liath / log.txt
Created February 11, 2021 22:00
aws_elastic_beanstalk_application issue
2021/02/11 13:34:34 [INFO] Terraform version: 0.14.2
2021/02/11 13:34:34 [INFO] Go runtime version: go1.15.2
2021/02/11 13:34:34 [INFO] CLI args: []string{"~/.asdf/installs/terraform/0.14.2/bin/terraform", "apply"}
2021/02/11 13:34:34 [DEBUG] Attempting to open CLI config file: ~/.terraformrc
2021/02/11 13:34:34 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/02/11 13:34:34 Loading CLI configuration from ~/.terraform.d/credentials.tfrc.json
2021/02/11 13:34:34 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/02/11 13:34:34 [DEBUG] ignoring non-existing provider search directory ~/.terraform.d/plugins
2021/02/11 13:34:34 [DEBUG] ignoring non-existing provider search directory ~/.local/share/terraform/plugins
2021/02/11 13:34:34 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
@liath
liath / Dockerfile
Created August 29, 2021 05:46
pyca/cryptography musllinux Dockerfile
FROM ghcr.io/pyca/cryptography-musllinux_1_1:x86_64
RUN /opt/pypy3.7/bin/pypy -m venv .venv && \
.venv/bin/pip install -U pip wheel cffi setuptools-rust && \
.venv/bin/pip download cryptography==3.4.8 --no-deps --no-binary cryptography && \
tar zxvf cryptography*.tar.gz && mkdir tmpwheelhouse && \
cd cryptography* ; \
LDFLAGS="-L/opt/pyca/cryptography/openssl/lib" \
CFLAGS="-I/opt/pyca/cryptography/openssl/include -Wl,--exclude-libs,ALL" \
../.venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/cryptography*.whl ../tmpwheelhouse
@liath
liath / pollux.js
Created August 25, 2018 00:33
Darknet 7: Krux's Silk Screen Challenge
/* This script will attempt to brute force any pollux ciphertext you hand it.
Most of the output is useless but for every ciphertext I could create on
[dcode](https://www.dcode.fr/pollux-cipher), it had the correct result in its
output somewhere. Usually towards the middle. Unfortunately it does not give
any useful results for the actual challenge. ¯\_(ツ)_/¯ */
/* eslint no-console:0, no-param-reassign:["error", { "props": false }] */
/* eslint-disable sort-keys */
const morse2char = {
'.-': 'a',
@liath
liath / fedtax.js
Created November 23, 2015 23:24
US Federal Income Tax calculator in javascript
// Weekly Employee Income Withholding Calculator by GitHub#Liath
// Based on IRS Circular E - http://www.irs.gov/pub/irs-pdf/p15.pdf
// Per the "Percentage Method"
var w = {
s : { // Single
0 : { p : 0, s : 0 },
44 : { p: 0.1, s: 0 },
222 : { p: 0.15, s: 17.8 },
764 : { p: 0.25, s: 99.1 },
1789 : { p: 0.28, s: 355.35 },
@liath
liath / base64.js
Last active May 14, 2024 17:49
Base64 encoder golfing in JS
(i,f=([a,b,c,...z])=>1+a?[a>>2,(a<<4)+(b>>4),(b<<2)+(c>>6),c,...f(z)]:z)=>f(i).map(x=>String.fromCharCode((x%=64)+1?x+71-(x<26?6:x<52?0:x<62?75:x&1?87:90):61)).join``