Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
if [[ $(id -u) -ne 0 ]] ; then echo "Run with sudo!" ; exit 1 ; fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
sudo apt install -y python3-pip libfuzzy-dev libssl-dev automake libtool make cmake gcc pkg-config flex bison libmagic-dev
if [ ! -f "/usr/local/bin/pycdc" ]; then
git clone https://github.com/zrax/pycdc.git
@packmad
packmad / printable_x86.py
Created April 12, 2022 09:49
Printable ASCII characters which are also valid x86 instructions
import string
from capstone import *
modes = [CS_MODE_32, CS_MODE_64]
for mode in modes:
md = Cs(CS_ARCH_X86, mode)
printables = string.printable[:-5]
valid = 0
for c in printables:
@packmad
packmad / install_imhex
Created August 5, 2021 08:45
Install ImHex on Ubuntu
#!/bin/bash
# Installer for https://github.com/WerWolv/ImHex
sudo apt install wget libcapstone3 libglfw3 libmbedcrypto3 libmbedtls12
cd /tmp
wget https://nightly.link/WerWolv/ImHex/workflows/build/master/Linux%20ELF.zip
unzip Linux\ ELF.zip -d tmpimhex
cd tmpimhex
sudo cp bin/imhex /usr/bin
@packmad
packmad / check_pe_signatures.py
Created March 1, 2021 18:25
Checks PortableExecutable signatures using signify package
import sys
import os
from os.path import isdir
from collections import defaultdict
from signify.signed_pe import SignedPEFile
def is_pe(file_path: str) -> bool:
try:
@packmad
packmad / remaining_time.py
Created December 4, 2020 22:54
Pretty prints how much time is left to a deadline
#!/usr/bin/python3
import sys
from datetime import datetime, timedelta, timezone
def get_remaining_time(total_seconds: int) -> str:
months, remainder = divmod(total_seconds, 2592000)
days, remainder = divmod(remainder, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
@packmad
packmad / multiprocess_json_load.py
Created November 26, 2020 09:40
Load all json files from an input folder using multiprocess
import os
import json
import sys
import time
from multiprocessing import Pool
from os.path import isdir, abspath, join
from typing import List, Dict
@packmad
packmad / check_valid_jsons_folder.sh
Created October 28, 2020 11:21
Bash function that finds if a directory contains invalid JSON files
function check_valid_jsons_folder() {
if [ -d "$1" ]; then
find $1 -type f -iname "*json" | while read p; do if ! jq empty < $p > /dev/null 2>&1; then echo '> Invalid JSON: '$p; fi; done
else
echo "'$1' is not a directory!"
fi
}
@packmad
packmad / plothemall.sh
Created September 29, 2020 11:10
Plots all Graphviz layouts
#!/bin/bash
# /usr/sbin/libgvc6-config-update
# Use one of: circo dot fdp neato osage patchwork sfdp twopi
declare -a graphviz=("circo" "dot" "fdp" "neato" "osage" "patchwork" "sfdp" "twopi")
if [ -f "$1" ]; then
pardir="$(dirname "$1")"
bname="$(basename "$1")"
for i in "${graphviz[@]}"
@packmad
packmad / get_steam_exe_hashes.ps1
Created September 15, 2020 15:27
PS script which writes all exe sha256 hashes of Steam games to a txt file
$scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$outputTxtFile = Join-Path -Path $scriptPath -ChildPath "hashes.txt"
Get-ChildItem -Path "C:\Program Files (x86)\Steam\steamapps\common" -recurse -include *.exe | foreach-object {
(Get-FileHash $_.FullName -Algorithm SHA256).Hash | Out-File -Encoding Ascii -append $outputTxtFile
}
Write-Host ("Results written in: {0}" -f $outputTxtFile)
@packmad
packmad / get_nordvpn_upd_configs.sh
Created June 19, 2020 10:28
Get all openvpn (udp) config files of nordvpn
#!/bin/bash
wget https://nordvpn.com/ovpn/
cat index.html | grep udp1194.ovpn | cut -d \" -f2 > configlinklist.txt
rm index.html
mkdir nordvpnconfigs/
xargs wget -P nordvpnconfigs/ < configlinklist.txt