Skip to content

Instantly share code, notes, and snippets.

View CaledoniaProject's full-sized avatar

CaledoniaProject

View GitHub Profile
@CaledoniaProject
CaledoniaProject / write_cr0.c
Last active July 17, 2023 07:57
Disable write protection on Linux kernel >= 5.3.0
// https://medium.com/@hadfiabdelmoumene/change-value-of-wp-bit-in-cr0-when-cr0-is-panned-45a12c7e8411
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
inline void write_cr0_new(unsigned long cr0)
{
asm volatile("mov %0,%%cr0" : "+r"(cr0), "+m"(__force_order));
}
#else
#define write_cr0_new write_cr0
#endif
@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 / 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 / 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 / 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 / Get-WlanEnterprisePassword.ps1
Created November 10, 2018 15:11
Get-WlanEnterprisePassword
// Original post
// https://0x00-0x00.github.io/research/2018/11/06/Recovering-Plaintext-Domain-Credentials-From-WPA2-Enterprise-on-a-compromised-host.html
function Get-String
{
Param(
[Parameter(Mandatory = $true, Position = 0)]
[byte[]]$InputStream
)
[byte[]]$Output = @();
@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