Skip to content

Instantly share code, notes, and snippets.

View kkirsche's full-sized avatar

Kevin Kirsche kkirsche

View GitHub Profile
#!/usr/bin/env python
from __future__ import annotations
from uuid import uuid4, UUID
from typing import Sequence
class Node:
node_id: UUID
time_to_complete: int
children: Sequence[Node]
import re
# https://github.com/sqlalchemy/alembic/blob/c97d5b3dd6fde31acb8e9e0c67d0ebc54fa0d809/alembic/script/base.py#L682
_slug_re = re.compile(r"\w+")
truncate_slug_length = 40
def generate_slug(message: str) -> str:
slug = "_".join(_slug_re.findall(message or "")).lower()
if len(slug) > truncate_slug_length:
slug = slug[: truncate_slug_length].rsplit("_", 1)[0] + "_"
@kkirsche
kkirsche / ConventionalCommitsEmoji.md
Last active June 17, 2021 18:03 — forked from parmentf/ConventionalCommitsEmoji.md
Emoji for Conventional Commits
Type Emoji code
build 📦 :package:
chore 🔧 :wrench:
ci 👷 :construction_worker:
docs 📚 :books:
feat :sparkles:
fix 🐛 :bug:
perf 🚀 :rocket:
refactor 🔨 :hammer:
@kkirsche
kkirsche / exit_codes.py
Created December 29, 2020 06:06
Exit Codes Python
from enum import IntEnum
class ExitCode(IntEnum):
"""The following exit codes are defined and can be used with SystemExit, although they
are not required. These are typically used for system programs written in Python,
such as a mail server’s external command delivery program.
* EX_OK: Exit code that means no error occurred.
* EX_USAGE: Exit code that means the command was used incorrectly, such as when the wrong number of arguments are given.
* EX_DATAERR: Exit code that means the input data was incorrect.
@kkirsche
kkirsche / cat-danger.py
Created January 8, 2020 21:57
The danger of just trusting the cat command
#!/usr/bin/env python3
hidden_cmd = "echo 'You forgot to check `cat -A`!' > oops"
visible_cmd = "echo 'Hello world!'"
if __name__ == "__main__":
with open("demo.sh", "w") as f:
txt = "#!/bin/sh\n"
txt += hidden_cmd + ";" + visible_cmd + " #\r" + visible_cmd + " " * (len(hidden_cmd) + 3) + "\n"
f.write(txt)
@kkirsche
kkirsche / arkham-week1.py
Last active October 1, 2019 14:30
Arkham Walkthrough
#!/usr/bin/env python3
from requests import post
from base64 import b64encode, b64decode
from hashlib import sha1
from pyDes import des, ECB, PAD_PKCS5
import hmac
def create_payload():
@kkirsche
kkirsche / README.md
Last active July 29, 2019 16:34
Patch for rbenv's ree-1.8.7-2012.02 Installer
@kkirsche
kkirsche / mount-shared-folders
Last active May 17, 2022 14:09
Mount or restart open VM toolchain
#!/bin/sh
# to install:
# git clone https://gist.github.com/381e17fab1457ccf3b8b750edbc40b79.git msd
# mv ./msd/mount-shared-folders /usr/local/bin
# rm -rf ./msd
# chmod +x /usr/local/bin/mount-shared-folders
# Source: https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/data/mount-shared-folders
@kkirsche
kkirsche / lfi-tester.py
Last active October 20, 2018 10:58
LFI Tester
import requests
import webbrowser
# formatted using Black
# https://blog.rapid7.com/2016/07/29/pentesting-in-the-real-world-local-file-inclusion-with-windows-server-files/
url = "http://www.testpage.com?page="
LFI = "../../../../../../../../../"
pages = [
@kkirsche
kkirsche / split-file.py
Created October 17, 2018 15:26
Antivirus Checking
#!/usr/bin/env python
from jinja2 import Template
from subprocess import call
lhost = '192.168.102.69'
binary = 'ncx99.exe'
split_num = 50
tmpl = Template('''open {{ lhost }} 21
BINARY
{%- for f in split_files %}