Skip to content

Instantly share code, notes, and snippets.

Daniel Miller bonsaiviking

Block or report user

Report or block bonsaiviking

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bonsaiviking
bonsaiviking / md4.py
Created May 24, 2013
Simple MD4 digest implementation in pure Python
View md4.py
#!/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
bonsaiviking / aes.py
Last active Nov 15, 2019
A simple/simplistic implementation of AES in pure Python.
View aes.py
#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
bonsaiviking / NmapHeartbleed.md
Last active Nov 1, 2019
Guide to using Nmap to scan for the Heartbleed bug.
View NmapHeartbleed.md

Requirements

  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
bonsaiviking / lua.vim
Last active Dec 10, 2018
A Vim indent file for the Lua scripting language. Install as ~/.vim/indent/lua.vim
View lua.vim
" Vim indent file
" Language: Lua
" Maintainer: Daniel Miller <daniel@bonsaiviking.com>
" Original Author: Daniel Miller <daniel@bonsaiviking.com>
" Last Change: 2014 Feb 6
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
@bonsaiviking
bonsaiviking / cli_zenmap_png.py
Created Dec 20, 2013
YMMV, but this should export a PNG of a zenmap topology from a Nmap XML file
View cli_zenmap_png.py
#!/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])
sys.exit(1)
try:
@bonsaiviking
bonsaiviking / sha2.py
Created Jun 13, 2013
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)
View sha2.py
#!/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):
@bonsaiviking
bonsaiviking / sha1.py
Created May 23, 2013
SHA1 implementation in pure Python
View sha1.py
#!/usr/bin/env python
import struct
def leftrotate(i, n):
return ((i << n) & 0xffffffff) | (i >> (32 - n))
class SHA1(object):
def __init__(self, data=""):
self.h = [
@bonsaiviking
bonsaiviking / progress.sh
Created Jun 6, 2014
Display progress reading/writing a file according to position information on the file descriptor.
View progress.sh
#!/bin/bash
# Usage: progress.sh $(pgrep myprocess) $FD_NUMBER
# Find $FD_NUMBER by doing: ls -l /proc/$(pgrep myprocess)/fd/
fd=/proc/$1/fd/$2
fdinfo=/proc/$1/fdinfo/$2
name=$(readlink $fd)
size=$(wc -c $fd | awk '{print $1}')
while [ -e $fd ]; do
@bonsaiviking
bonsaiviking / nmap-check.sh
Created Apr 9, 2014
Check for bugs and code quality issues in Nmap source files.
View nmap-check.sh
#!/bin/bash
PEP8=$(which pep8)
if [ -z $PEP8 ]; then
echo "No pep8 in your path. Skipping Python checks"
else
for file in $(find "$@" -name '*.py'); do
OUTPUT=$(mktemp)
"$PEP8" -r "$file" > "$OUTPUT"
@bonsaiviking
bonsaiviking / mcafee-epo-agent.nse
Created Jun 5, 2012
McAfee ePO Agent detection (Nmap NSE script)
View mcafee-epo-agent.nse
-- mcafee-epo-agent.nse V0.0.2, checks if ePO agent is running
-- Developed by Didier Stevens and Daniel Miller
-- https://DidierStevens.com
-- Use at your own risk
--
-- History:
-- 2012/05/31: Start
-- 2012/06/01: extracting data from XML; tested with ePO 4.5 and 4.6
-- 2012/06/05: V0.0.2 convertion to version script by Daniel Miller
-- 2012/06/20: new portrule by Daniel Miller
You can’t perform that action at this time.