Skip to content

Instantly share code, notes, and snippets.

@klustic
klustic / bongcloud.go
Created December 16, 2022 20:05
Bongcloud CTF challenge
package main
import (
"errors"
"fmt"
"net"
"time"
)
type ChessState struct {
@klustic
klustic / known_hosts_hash.py
Created September 15, 2021 21:37
Test hostname against hashed entry in SSH known_hosts file
import hashlib, hmac
from base64 import b64decode as b64d, b64decode as b64d
line = input('hashed known_hosts line> ').strip()
host = input('suspected host> ').strip()
_, _, e_hkey, e_hdigest = line.split()[0].encode().split(b'|')
hkey, hdigest = b64d(e_hkey), b64d(e_hdigest)
d = hmac.digest(hkey, host.encode(), hashlib.sha1)
@klustic
klustic / aes.js
Last active August 13, 2021 06:14
ServiceNow script include that implements AES in ECB and CFB modes
/*
License:
ServiceNow script include that implements AES in ECB and CFB modes.
Copyright (C) 2021 K. Lustic
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#!/usr/bin/env python
import logging
import random
import select
import shlex
import signal
import socket
import ssl
import struct
import sys
@klustic
klustic / rghog.py
Last active February 11, 2021 16:13
Run ripgrep using Trufflehog patterns
#!/usr/bin/env python3
# Deps:
# ripgrep: https://github.com/BurntSushi/ripgrep
# Credit:
# Trufflehog: https://github.com/dxa4481/truffleHog
import argparse
import logging
import os
import pathlib
import subprocess
@klustic
klustic / gauth-export-parser.py
Created December 22, 2020 06:21
Parse seeds out of Google Authenticator migration QR codes
# Scan the Google Authenticator export QR code to get a otpauth-migration:// URI
# Then, provide that URL here and get your precious seeds back.
# The last components on each line of output are the 80-bit TOTP conforming seeds Authenticator uses, e.g.
#
# Output looks like this
# Some Service 1 (Andres) - JBUSYICBNZSHEZLT
# Some Service 2 (Kevin) - JZXXIICTN4QEEYLE
from urllib.parse import unquote
def consume(b: bytes):
@klustic
klustic / tracert.sh
Last active July 30, 2019 17:59
Traceroute for Linux hosts without traceroute/tracepath available
# To use this Bash function:
# [user]$ source tracert.sh
# [user]$ tracert
# Tracing to 8.8.8.8...
# 1 250.50.224.1
# ...
# [user]$ tracert 1.1.1.1
# Tracing to 1.1.1.1...
# 1 250.50.224.1
# ...
@klustic
klustic / arox.py
Created November 20, 2018 23:18
arox
#!/usr/bin/env python
import logging
import random
import select
import shlex
import signal
import socket
import ssl
import struct
import sys
@klustic
klustic / gen_aws_sig.py
Created May 25, 2018 05:58
Generate signature for AWS REST API calls and embed in request parameters
# Modified from here:
# https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html#sig-v4-examples-get-query-string
import sys, os, base64, datetime, hashlib, hmac, urllib
# ************* REQUEST VALUES *************
method = 'GET'
service = 'ec2'
host = 'ec2.amazonaws.com'
region = 'us-east-1'
endpoint = 'https://ec2.amazonaws.com'
@klustic
klustic / CVE-2017-12617.py
Last active October 5, 2017 22:10
Scan for CVE-2017-12617
import argparse
import itertools
import logging
import requests
import sys
import threading
import urllib3
class Scanner(object):