Skip to content

Instantly share code, notes, and snippets.

@ezr
ezr / doh-lookup.py
Created November 29, 2019 21:52
basic script to look up DNS entries using DNS over HTTPS. Similar dig/nslookup.
#!/usr/bin/env python3
import argparse
import base64
import dnslib # https://github.com/paulc/dnslib
import requests
parser = argparse.ArgumentParser(description='script to look up DNS records using DNS over HTTPs')
parser.add_argument('-s', '--server', help='the server to query', required=False)
parser.add_argument('-q', '--question', help='usually a hostname', required=True)
#!/usr/bin/python3
from glob import glob
import os
session_files = glob(os.environ["HOME"] + "/.putty/sessions/*")
out_file = open("putty-sessions.reg", "w")
header = '''Windows Registry Editor Version 5.00
@ezr
ezr / dates.html
Created April 17, 2020 03:54
date calculator web page
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
background-color: #2E2E2E;
color: #E2E2E2;
font-size: 1.3em;
}
@ezr
ezr / ipv6-to-mac.py
Created July 11, 2020 06:19
Converts an IPv6 link-local address to a MAC address
#!/usr/bin/env python3
'''
thanks https://ben.akrin.com/?p=1347
To convert from an IPv6 link-local address to a MAC address:
- the 1st 64 bits go away (the fe80:: part)
- bit 71 gets flipped (after fe80:: is gone this would be the 7th bit)
- bits 89 through 112 go away (the ff:fe)
'''
@ezr
ezr / listfattrs.go
Last active November 20, 2020 07:22
Like "getfattr -d"
package main
import (
"fmt"
"log"
"os"
"github.com/pkg/xattr"
)
@ezr
ezr / lambda-bczp.sh
Last active January 12, 2021 04:06
#!/usr/bin/env bash
if [ -z ${1+x} ]; then
echo "Usage: $0 <source.go>"
echo
echo "Or in order to also publish:"
echo " $0 <source.go> <function name>"
exit 2
fi
@ezr
ezr / redirect.go
Created January 12, 2021 04:11
AWS lambda function to return an HTTP redirect (golang)
package main
import (
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
type Response events.APIGatewayProxyResponse
func Handler() (Response, error) {
@ezr
ezr / changedns.py
Created June 7, 2021 21:47
A script to change DNS servers when using systemd-resolved
#!/usr/bin/env python3
from os import listdir
from pydbus import SystemBus
import socket
nics = listdir("/sys/class/net/")
nics.remove("lo")
for idx, nic in enumerate(nics):
@ezr
ezr / sshlurp.go
Created July 5, 2021 16:41
A fake ssh server that logs usernames/passwords that get submitted
// A fake SSH server that logs passwords
// tweaked from https://gist.github.com/jpillora/b480fde82bff51a06238
//
// # generate server keypair with
// ssh-keygen -t rsa
// the server expects to find id_rsa in the PWD
package main
import (
@ezr
ezr / tcping.go
Created August 10, 2021 02:52
Test connecting to a given tcp port. Can specify source address
package main
import (
"fmt"
"log"
"net"
"os"
"strconv"
"strings"
"time"