Skip to content

Instantly share code, notes, and snippets.

@bannsec
bannsec / Creating ssh-key from yubikey
Last active December 24, 2017 22:33
Couple commands to export your ssh-key from a yubikey
# Assuming you already generated the private key using some other method, this will extract and create a ssh-key OpenSSH format that can be used for authenticating to openssh.
# This is most useful for ECC keys for right now, as ssh-keygen does not read it correctly.
# Lists out what keys you have on the device. Note the "ID" of the key you want
pkcs15-tool --list-public-keys
# Dump it out
pkcs15-tool --read-public-key <id> > my_key.pub
@bannsec
bannsec / dump_win_key.vbs
Created January 31, 2018 13:17
Dump Windows Product Key
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
@bannsec
bannsec / .gdbinit
Created February 5, 2018 17:38
GDB PIE Breakpoint Script
#
# Add this to your .gdbinit script to create a pie breakpoint helper. Once added, you can create a PIE breakpoint by the following
# breakpoint_pie file_name offset
# file_name == string name of the file. This can be the main binary, a library, etc.
# offset == Offset to set breakpoint at. This could be an integer or a symbol name if that symbol is resolvable. For instance "main".
#
python
import re
import os
@bannsec
bannsec / pwntools-r2-gdb
Last active November 18, 2018 23:46
pwntools-r2
#!/usr/bin/env python3
"""
This enables use of radare2 for pwntools
Steps to enable
1. Download and save as "pwntools-gdb" somewhere in your PATH
2. chmod u+x pwntools-gdb
3. In your gdbscript, start lines with hashtag "#" that you want to get executed by radare2. For instance, to set a breakpoint automatically, you would use gdbscript="#r2.cmd('db sym.amin')"
4. Update line 60 if you're not a screen user..
"""
pyppeteer downloads a version of chrome, but doesn't bother to install deps...
sudo apt install -y libx11-6 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxi6 libxtst6 libglib2.0-0 libnss3 libcups2 libxss1 libxrandr2 libpangocairo-1.0-0 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0
Also can disable sanbox if needed:
/usr/local/lib/python3.8/dist-packages/pyppeteer/launcher.py
--no-sandbox
@bannsec
bannsec / change_docker_shm
Created November 27, 2021 02:47
Change shm size of existing docker container
# https://github.com/docker/cli/issues/1278
Stop docker daemon (with your container)
Modify hostconfig.json as you want
Now you can start docker daemon and your container with updated ShmSize.
@bannsec
bannsec / ainput.py
Created November 30, 2021 04:53
python await input
import asyncio
from concurrent.futures import ThreadPoolExecutor
async def ainput(prompt: str = ''):
with ThreadPoolExecutor(1, 'ainput') as executor:
return (await asyncio.get_event_loop().run_in_executor(executor, input, prompt)).rstrip()
@bannsec
bannsec / load-modules.sh
Created February 1, 2022 04:06
Re-sign VMWare mods on linux
#!/bin/bash
sudo modprobe vmmon
sudo modprobe vmnet
sudo /usr/bin/vmware-networks --start
@bannsec
bannsec / pdfmerge
Created July 21, 2022 03:16
Merging two pdfs interleafed
Merges every other page, starting page 1 of A, page 1 of B, page 2 of A, page 2 of B, etc.
pdftk A=A.pdf B=B.pdf shuffle A B output merged.pdf
@bannsec
bannsec / wsl2_nvidia.md
Last active October 17, 2023 02:27
WSL2 (Ubuntu 22.04) NVidia Notes.md