Skip to content

Instantly share code, notes, and snippets.

@zb3
zb3 / replaceParallel.js
Last active August 29, 2015 14:25
Replace multiple strings with other strings in parallel in JS
/*
* search and replace are arrays (btw string is an array of characters)
* replaceParallel('ab', 'ba', 'abc') -> bac
* replaceParallel(['123', '2', '3', 'a'], ['2', '123', 'a', '3'], '1232322ac3') -> 2123a1231233ca
* Note: order matters if one search string begins with another
*/
function replaceParallel(search, replace, str) {
var t, ret = '', replaced = false, cursor = 0;
while (cursor<str.length) {
@zb3
zb3 / shout-history.user.js
Created January 7, 2016 11:23
Log songs you've heard on shoutcast.com to a file. Requires a http server and Greasemonkey/Tampermonkey browser extensions.
// ==UserScript==
// @name ShoutCast.com song history
// @author zb3
// @include http://*shoutcast.com*
// @include https://*shoutcast.com*
// @grant none
// ==/UserScript==
(function(){
@zb3
zb3 / make_netoff.sh
Last active March 27, 2016 14:53
netoff command to run a process without access to the network. This should be a suid binary (of course the code is unsafe, just a PoC) (won't work with unified cgroup hierarchy)
gcc netoff.c -o netoff
cp netoff /usr/bin/
cp netoff /usr/bin/netlo
chmod 4755 /usr/bin/netoff
chmod 4755 /usr/bin/netlo
@zb3
zb3 / firefox_crack_linux.sh
Created August 22, 2016 08:45
Crack firefox so that you can run unsigned extensions on linux, without recompiling firefox
#cracks for open source software are always cool....
#requires root privileges to replace omni.ja
#needs to be reapplied on reinstall
#you'll also need to set xpinstall.signatures.required to false
#and restart your browser
#tested on arch with FF48
OMNI_PATH=${1:-/usr/lib/firefox}
@zb3
zb3 / equine.js
Created December 8, 2016 13:24
Shannon entropy quine generator....
//Entropy quine generator....
//of course it all depends on precision...
function display(entropy) {
return 'Shannon entropy of this text is about ' + entropy; //+', 2X entropy: '+(2*entropy);
}
var precision = 15;
var maxTriesPerIter = 400;
var maxIters = 400;
@zb3
zb3 / leave-only-date.py
Created February 4, 2017 16:58
Recursively strip all EXIF info + metadata, BUT preserve date and time
import os
import sys
import subprocess
# recursively strip all EXIF info + metadata, BUT preserve date and time
# requires jhead (tested on jhead v3.00)
if len(sys.argv) < 2:
print('%s [path]')
exit()
@zb3
zb3 / deobf.php
Last active November 28, 2022 17:30
PHP deobfuscation utils
<?php
/*
note this is not "correct"
it was made to deobfuscate particular obfuscated files
"proper" tool should probably operate on AST to properly parse the file
but even that's not enough - you can't assume things we do here
*/
function unwrap_hexstr_literals($src) //currently only \xHH and \nnn supported
@zb3
zb3 / stopwatch.c
Created February 19, 2017 18:03
"pauseable" linux terminal stopwatch
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/select.h>
#include <termios.h>
//pauseable terminal stopwatch.
//couldn't find it anywhere :<
//ok maybe I can't name it properly
//and that's why I couldn't find it
@zb3
zb3 / mips-stringref.py
Last active June 12, 2017 16:18
Script to display function calls and string constant references in MIPS executables (lui + addiu/ori), disassembled by objdump. Needs objdump and readelf
import subprocess
import sys
import re
import os
from collections import defaultdict
#
# similar tool exists: https://sourceware.org/ml/binutils/2010-07/msg00172.html
# but we aim to support string literals... by "interpreting" selected instructions
@zb3
zb3 / partyover.py
Created August 23, 2017 13:46
Use Z3 to "crack" xoroshiro128+
from z3 import *
"""
Solver for this kind of stuff (z3 is the solver here, this tool simply uses it):
http://www.pcg-random.org/posts/predictability-party-tricks.html
https://lemire.me/blog/2017/08/22/cracking-random-number-generators-xoroshiro128/
I still don't know how they did it, but it seems solvers can crack this pretty easily.
This generates the same output though :)