Skip to content

Instantly share code, notes, and snippets.

View CaledoniaProject's full-sized avatar

CaledoniaProject

View GitHub Profile
@CaledoniaProject
CaledoniaProject / main.js
Created January 21, 2022 12:49
Disable CTRL+E/K shortcut key combination on github.com
setTimeout(() => {
document.querySelectorAll("textarea").forEach(e => {
e.addEventListener("keydown", ev => {
if (ev.ctrlKey) {
ev.stopPropagation();
}
})
})
}, 2000)
@CaledoniaProject
CaledoniaProject / main.java
Created January 6, 2022 02:53
Decode and encode BCEL class
package main;
import java.io.*;
import java.nio.*;
import java.nio.file.*;
import org.apache.bcel.classfile.Utility;
public class Main {
public static void help() {
System.out.println(
@CaledoniaProject
CaledoniaProject / hexdump-uint8array.js
Created June 17, 2021 09:34
Improved hexdump with uint8array
function _fillUp(value, count, fillWith) {
var l = count - value.length;
var ret = "";
while (--l > -1)
ret += fillWith;
return ret + value;
}
function hexdump(arrayBuffer, offset, length) {
offset = offset || 0;
@CaledoniaProject
CaledoniaProject / main.cpp
Created March 17, 2021 13:58
system resources physical memory map VM detection trick
// system resources physical memory map VM detection trick
// written by Graham Sutherland (@gsuberland) for Nettitude
// based on prior work done as part of the al-khaser project
// https://github.com/LordNoteworthy/al-khaser/
// ref: https://blog.xpnsec.com/total-meltdown-cve-2018-1038/
// ref: https://gist.github.com/xpn/3792ec34d712425a5c47caf5677de5fe
// compile:
@CaledoniaProject
CaledoniaProject / run.py
Last active January 12, 2021 05:59
Run async methods from non-async methods
class Test:
async def notify_async():
await asyncio.sleep(1)
def notify(self):
loop = None
try:
loop = asyncio.get_running_loop()
except RuntimeError:
@CaledoniaProject
CaledoniaProject / expand-ip.py
Last active January 10, 2021 09:04
Expand IP range with Python, similar to nmap syntax
import itertools
def expand_ip_range(ipstr):
parts = ipstr.split('.')
param = []
for part in parts:
if '-' in part:
tmp = part.split('-')
start = 0
@CaledoniaProject
CaledoniaProject / ubuntu-remove-expired-kernel.sh
Last active October 10, 2020 02:17
Remove expired kernel in Ubuntu
#!/bin/bash
installed=( $(dpkg-query -W --showformat='${Package}\n' | grep -oP '^linux-image-\K\d.*' | sort -r) )
running=$(uname -r)
echo Installed versions: ${installed[@]}
if [[ ${#installed[@]} -le 1 ]]; then
echo Nothing to do
exit
fi
@CaledoniaProject
CaledoniaProject / index.js
Created September 29, 2020 12:25
IndexDB to SQLite3
const sqlite3 = require('sqlite3')
const fs = require('fs')
let dbpath = 'common.db'
let finished = 0, total = 0
let mydb = new sqlite3.Database(dbpath)
if (fs.existsSync(dbpath)) {
fs.unlinkSync(dbpath)
}
@CaledoniaProject
CaledoniaProject / emumipsel.sh
Created September 25, 2020 07:50
emumipsel
#!/bin/bash
if [ ! -f "vmlinux-3.2.0-4-4kc-malta" ]; then
wget https://people.debian.org/~aurel32/qemu/mipsel/vmlinux-3.2.0-4-4kc-malta
fi
if [ ! -f "debian_wheezy_mipsel_standard.qcow2" ]; then
wget https://people.debian.org/~aurel32/qemu/mipsel/debian_wheezy_mipsel_standard.qcow2
fi
sudo qemu-system-mipsel -m 1024M -M malta \
@CaledoniaProject
CaledoniaProject / mac-setup.sh
Created September 21, 2020 01:03
Setup mac and default settings, sudo privilege required
#!/bin/bash
echo Setting up ComputerName and HostName
sudo scutil --set ComputerName XXX
sudo scutil --set HostName XXX
echo Disable spotlight
sudo mdutil -a -i off
echo Disable guest account