Skip to content

Instantly share code, notes, and snippets.

Avatar

David Wittman DavidWittman

View GitHub Profile
View supermicro-mount-iso.sh
#!/usr/bin/env bash
# Loads and mounts an ISO over SMB via the
# SuperMicro IPMI web interface
#
# usage: supermicro-mount-iso.sh <ipmi-host> <smb-host> <path>
# e.g.: supermicro-mount-iso.sh 10.0.0.1 10.0.0.2 '\foo\bar\windows.iso'
set -x
View iptables-nat.md

iptables n'at

Source NAT

Source NAT changes the source address in IP header of a packet. It may also change the source port in the TCP/UDP headers. The typical usage is to change the a private (rfc1918) address/port into a public address/port for packets leaving your network. Available only in the POSTROUTING chain in iptables.

Syntax

iptables -t nat -A POSTROUTING -i eth1 -j SNAT --to-source 1.2.3.4[:port]

Example

@DavidWittman
DavidWittman / ansible-dynamic-inventory-converter.py
Created Apr 12, 2016
Script for converting Ansible dynamic inventory to static files. It's not perfect, but it'll get you 90% of the way there.
View ansible-dynamic-inventory-converter.py
#!/usr/bin/env python
# Converts Ansible dynamic inventory sources to static files
# Input is received via stdin from the dynamic inventory file
# ex:
# ec2.py --list | ansible-dynamic-inventory-converter.py
import json
import os
import sys
@DavidWittman
DavidWittman / notes.md
Created Feb 22, 2012
A Brief Introduction to Fabric
View notes.md

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

@DavidWittman
DavidWittman / http-get.nse
Created Apr 6, 2012
Nmap HTTP GET request script
View http-get.nse
description = [[
Issues an arbitrary HTTP GET request
]]
---
-- @usage
-- nmap --script http-get [--script-args http-get.path=/status] -p <port> <host>
-- @args http-get.path The path to request (defaults to /)
-- http-get.match String to match in the HTTP response (incl. headers)
-- @output
@DavidWittman
DavidWittman / supermicro-ipmi-mac-address.md
Last active May 3, 2020
Pull the LAN1/eth0 MAC address from SuperMicro IPMI
View supermicro-ipmi-mac-address.md

You can find the MAC address for LAN1/eth0 (not the BMC MAC) via the SuperMicro IPMI interface by running the following command:

$ ipmitool -U $IPMI_USER -P $IPMI_PASS -H $IPMI_HOST raw 0x30 0x21 | tail -c 18

The eth0 MAC address will be output in this format:

00 25 90 f0 be ef
@DavidWittman
DavidWittman / ms120-020.py
Created Apr 5, 2012
MS12-020/CVE-2012-0002 Vulnerability Tester
View ms120-020.py
#!/usr/bin/env python
"""
MS12-020/CVE-2012-0002 Vulnerability Tester
based on sleepya's version @ http://pastebin.com/Ks2PhKb4
"""
import socket
import struct
import sys
@DavidWittman
DavidWittman / audit_iam_accounts.py
Created Apr 14, 2016
Parses the output from AWS credential reports and displays users which have been inactive for 60+ days.
View audit_iam_accounts.py
#!/usr/bin/env python
# Parses the output from AWS credential reports and displays
# users which have been inactive for 60+ days.
#
# Usage:
# audit_iam_accounts.py credential_report.csv <days>
#
import csv
View windows-vm-openstack.md

Create a Windows OpenStack VM with VirtualBox

0. Obtain Windows ISO

  • Use an existing ISO or copy from a CD with dd if=/dev/cdrom of=image.iso

1. Boot VirtualBox VM from Windows ISO

  • Qcow disk type
  • 40GB Root Disk
  • Load your Windows ISO to the Primary CD drive
  • Add a secondary CD drive and attach the VirtIO ISO to it
@DavidWittman
DavidWittman / supermicro-java-console.sh
Last active Dec 5, 2019
Retrieves the plaintext JNLP for the iKVM console from a SuperMicro IPMI webserver
View supermicro-java-console.sh
#!/usr/bin/env bash
# Retrieves the plaintext JNLP from a SuperMicro IPMI webserver
# Usage: supermicro-java-console.sh <hostname>
# supermicro-java-console.sh 10.1.2.34 > login.jnlp
set -x
HOST="$1"
IPMI_USER=${IPMI_USER:-ADMIN}
You can’t perform that action at this time.