Skip to content

Instantly share code, notes, and snippets.

View hazcod's full-sized avatar

Niels Hofmans hazcod

View GitHub Profile
@hazcod
hazcod / get-intigriti-program-domains.sh
Created April 7, 2022 09:17
Retrieves domains from the Intigriti public program on the public website.
#!/usr/bin/env bash
join_by()
{
local IFS="$1"
shift
echo "$*"
}
data=$(curl -s https://www.intigriti.com/programs)
@hazcod
hazcod / psycopg2-with-reconnects.py
Created May 28, 2021 13:40
This helper class helps you use Psycopg but with connection reattempts.
class PGDB():
LIMIT_RETRIES = 5
def __init__(self, user:str, password:str, host:str, port:int, database:str, sslmode:str, reconnect:bool):
self.user = user
self.password = password
self.host = host
self.port = port
self.database = database
self._connection = None
@hazcod
hazcod / brew-cleanup
Last active April 6, 2022 03:06
List all top level brew packages
#!/usr/bin/env bash
#EDIT: just use `brew leaves`
brew deps --installed | awk -F'[: ]+' '{
packages[$1]++
for (i = 2; i <= NF; i++)
dependencies[$i]++
}
END {
@hazcod
hazcod / expose-docker-sock
Last active April 6, 2022 03:06
Expose docker.sock on a TCP socket.
FROM alpine
# the group id of the docker group on the host
ENV HOST_DOCKER_GID 101
# SECURITY CONSIDERATIONS:
# Only expose this via a dedicated internal, encrypted net to your webserver/..
# Mount /var/run/docker.sock READONLY, make this container readonly too
RUN addgroup -g $HOST_DOCKER_GID docker \
@hazcod
hazcod / wgcf.sh
Created October 16, 2019 06:10
Connect to Cloudflare Warp from macOS.
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit 2>/dev/null || true
# this script will connect macOS to Cloudflare Warp using Wireguard
# note: this is *absolutely not* an official client from Cloudflare
# Copyright (C) 2019 Jay Freeman (saurik)
# Zero Clause BSD license {{{
@hazcod
hazcod / logger.go
Last active September 22, 2021 14:27
Simple logger that listens for UNIX datagram message and prints them to stdout. We don't like syslog-ng in our postfix container!
package main
import (
"bufio"
"net"
"os"
"syscall"
)
func println(msg string) {
@hazcod
hazcod / CVE-2021-36934.bat
Created July 22, 2021 11:32
CVE-2021-36934 manual mitigation in commandprompt.
echo > CVE-2021-36934 fixer
echo See https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-36934
echo Deleting current shadow copies...
vssadmin delete shadows /all /quiet
echo Fixing privilege issue...
icacls %windir%\system32\config\*.* /inheritance:e
echo Creating brand new shadow copy...
@hazcod
hazcod / yubi.go
Created August 2, 2021 14:05
YubiKey example
package main
import (
"flag"
"fmt"
"github.com/go-piv/piv-go/piv"
conf "github.com/hazcod/sop/config"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"os"
@hazcod
hazcod / gist:e50779fa6403364d1ceee1c9ecb3f552
Last active July 22, 2021 11:34
disables the printer spooler (disables local and remote printing) to fix PrintNightmare vulnerabilities.
<wap-provisioningdoc id="1162DF07-F217-449B-95F8-FB85A34D3CA5" name="windows-printerspooler-disable">
<characteristic type="com.airwatch.winrt.registryoperation" uuid="3fa91319-eac0-4a16-9d10-093ba845b698">
<parm RegistryPath="HKLM\SYSTEM\CurrentControlSet\Services\Spooler" Action="Replace">
<Value Name="Start" Data="4" Type="DWORD" />
</parm>
</characteristic>
</wap-provisioningdoc>
@hazcod
hazcod / gist:e9c0e600e0c8d0f72f4f
Last active December 11, 2020 06:34
How to setup Xbox 360 (wireless) controller on xbian
ssh xbian@IP_OF_YOUR_XBIAN
sudo apt-get install xboxdrv
mkdir xbox
nano xbox/mapping
```
[xboxdrv]
silent = true
ui-clear = true