Skip to content

Instantly share code, notes, and snippets.

@joekir
joekir / no_redos.js
Created March 15, 2016 02:18
Uses the Node.js vm to isolate a RegExp so catastrophic backtracks do not halt the node process.
const util = require('util');
const vm = require('vm');
var sandbox = {
result: null
};
var context = vm.createContext(sandbox);
console.log('Sandbox initialized: ' + vm.isContext(sandbox));
@joekir
joekir / solveModIntegers.py
Last active March 22, 2016 03:42
Solves equations of the form z^(1/q) = x in the cyclic integer group Zp. e.g. 7^(1/3) =x in Z11 group
from decimal import Decimal
'''
Hunts for the solution to things like
7^(1/3) = x in the group modulo 11
to solve things like this, you can absorb the modulus into the equation
e.g. (7+11n)^(1/3) = x
This script will then rip through that and find the first integer solution to that.

Keybase proof

I hereby claim:

  • I am joekir on github.
  • I am joekirwin (https://keybase.io/joekirwin) on keybase.
  • I have a public key whose fingerprint is 1B3E 55CA FB40 6C6B 6E34 AD3B 18C1 8EC7 1A6C 32A6

To claim this, I am signing this object:

@joekir
joekir / examples.txt
Created August 7, 2016 02:51
Catastrophic Backtrack Examples
Some samples I collected from sites around the web on this topic.
^(A+)*B
^([a-zA-Z0-9]+\s?)*$
(a+)+b
There seems to be a pretty common theme of
>>> r = re.compile('^(A+)+B$',re.DEBUG)
AT AT_BEGINNING
@joekir
joekir / rc.local
Created September 8, 2016 18:23
/etc/rc.local script to lock down some linux kernel settings
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@joekir
joekir / .vimrc
Last active October 3, 2018 22:07
~/.vimrc
colorscheme desert
set expandtab
set tabstop=2
set clipboard+=unnamedplus
syntax enable
filetype plugin indent on
:map <S-n> :NERDTreeToggle<CR>
@joekir
joekir / chromium-flags.conf
Created October 4, 2016 17:53
Chromium Startup Flags (~/.config/chromium-flags.conf)
# Used in location ~/.config/chromium-flags.conf
--enable-dom-distiller
@joekir
joekir / headerListener.js
Created October 21, 2016 06:01
chrome extension header listener
// https://developer.chrome.com/extensions/declarativeWebRequest
chrome.declarativeWebRequest.onMessage.addListener(details => {
console.log(details)
});
var rule1 = {
conditions: [
new chrome.declarativeWebRequest.RequestMatcher({
// We at least should have the header being returned!
@joekir
joekir / README.md
Last active June 14, 2017 03:00
BOSH setup on GCP
  • You'll need to setup a GCP network/subnetwork and obtain some access creds in the json format. All boxes on there should be internal only
  • You'll then need to create a jumpbox/bastion (as per this design) with a static ip that has public access. Exposing a firewall rule to allow ssh (port 22, tcp), also setup automatic, unattended security updates
  • To allow bosh to route through this "bastion" you'll need to run the following at the commandline
# -D : the local SOCKS5 port
# -f : forks the process in the background
# -C : compresses the data before sending
# -q : quiet mode (wrt the ssh output)
# -N : Tells SSH that no command will be sent once the tunnel is up
@joekir
joekir / sshd_config
Created May 16, 2017 06:38
sshd hardened config
Port <some high port>
PermitRootLogin no
PubkeyAuthentication yes
IgnoreRhosts yes
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding no
PrintMotd no
PrintLastLog yes