Skip to content

Instantly share code, notes, and snippets.

bonsaiviking /
Last active May 7, 2024 13:17
A simple/simplistic implementation of AES in pure Python.
#My AES implementation
# By Daniel Miller
def xor(s1, s2):
return tuple(a^b for a,b in zip(s1, s2))
class AES(object):
class __metaclass__(type):
def __init__(cls, name, bases, classdict):
cls.Gmul = {}
bonsaiviking /
Created April 9, 2014 16:49
Check for bugs and code quality issues in Nmap source files.
PEP8=$(which pep8)
if [ -z $PEP8 ]; then
echo "No pep8 in your path. Skipping Python checks"
for file in $(find "$@" -name '*.py'); do
"$PEP8" -r "$file" > "$OUTPUT"
bonsaiviking / pre-commit
Last active April 11, 2024 16:10
Pre-commit git hook for Nmap (WIP)
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
if git rev-parse --verify HEAD >/dev/null 2>&1
bonsaiviking / slammer.nse
Created July 16, 2012 20:38
Nmap script launcher for SQL Slammer worm
local nmap = require "nmap"
local shortport = require "shortport"
local bin = require "bin"
description = [[Sends the SQL Slammer worm to a host.
If vulnerable, it will attempt to propagate to other IP addresses.
DO NOT RUN THIS SCRIPT ON THE INTERNET. For use in closed environments
for educational purpose only.]]
license = "Same as Nmap--See"
bonsaiviking /
Created June 6, 2014 15:07
Display progress reading/writing a file according to position information on the file descriptor.
# Usage: $(pgrep myprocess) $FD_NUMBER
# Find $FD_NUMBER by doing: ls -l /proc/$(pgrep myprocess)/fd/
name=$(readlink $fd)
size=$(wc -c $fd | awk '{print $1}')
while [ -e $fd ]; do
bonsaiviking / lua.vim
Last active April 4, 2022 14:38
A Vim indent file for the Lua scripting language. Install as ~/.vim/indent/lua.vim
" Vim indent file
" Language: Lua
" Maintainer: Daniel Miller <>
" Original Author: Daniel Miller <>
" Last Change: 2014 Feb 6
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
bonsaiviking /
Last active September 20, 2021 23:31
Guide to using Nmap to scan for the Heartbleed bug.


  1. Nmap. The script requires version 6.25 or newer. The latest version, 6.47, already includes the next 3 dependencies, so you can skip directly to the Scanning section below.
    • An easy way to get the latest Nmap release is to use Kali Linux.
    • Binary installers are available for Windows.
    • RPM installer available for Linux, or install from source.
    • .dmg installer available for Mac OS X.
  2. tls.lua. The script requires this Lua library for TLS handshaking.
  3. ssl-heartbleed.nse. This is the script itself.
bonsaiviking /
Created May 24, 2013 15:41
Simple MD4 digest implementation in pure Python
#!/usr/bin/env python
import struct
def leftrotate(i, n):
return ((i << n) & 0xffffffff) | (i >> (32 - n))
def F(x,y,z):
return (x & y) | (~x & z)
def G(x,y,z):
bonsaiviking /
Created December 20, 2013 22:18
YMMV, but this should export a PNG of a zenmap topology from a Nmap XML file
#!/usr/bin/env python
import sys
if len(sys.argv) != 4:
print """{0} - Output a PNG from Nmap XML
Usage: {0} <scan.xml> <out.png> <width_in_pixels>""".format(sys.argv[0])
bonsaiviking /
Created June 13, 2013 16:54
Pure-python SHA-2 implementation, including all FIPS 180-2 specified variants (SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256)
#!/usr/bin/env python
import struct
def rightrotate(i, n, wsize):
return ((i << (wsize-n)) & (2**wsize-1)) | (i >> n)
class SHA2(object):
"""Abstract class for SHA-2 variants"""
def __init__(self):