Skip to content

Instantly share code, notes, and snippets.

@ezr
ezr / duplicates.go
Last active August 22, 2021 22:19
find duplicate files in the current directory
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@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"
@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 / 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 / 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 / listfattrs.go
Last active November 20, 2020 07:22
Like "getfattr -d"
package main
import (
"fmt"
"log"
"os"
"github.com/pkg/xattr"
)
@ezr
ezr / http-upload-server.go
Last active May 23, 2023 04:25
HTTP server to accept file uploads
package main
/* Taken from https://github.com/TannerGabriel/learning-go/tree/master/beginner-programs/FileUpload with some tweaks
*/
import (
"flag"
"fmt"
"html/template"
"io"
@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 / 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;
}
#!/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