Skip to content

Instantly share code, notes, and snippets.

View hazcod's full-sized avatar

Niels Hofmans hazcod

View GitHub Profile
function sendingRequest(origMsg, initiator, helper)
{
// skip if it isn't for the API scope
if (! origMsg.getRequestHeader().getHostName().contains("mywebapi")) { return; }
var httpRequestHeader = origMsg.cloneAll().getRequestHeader();
// add the Accept header if not exists
if (origMsg.getRequestHeader().getHeader("Accept") == null)
{
package tls.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
public class MTLSBackendHandler
extends ChannelInboundHandlerAdapter
{
@hazcod
hazcod / ttlmap.go
Created September 15, 2020 09:44
Go sync.map with TTL and per-second scavenging
type TTLMap struct {
TTL time.Duration
data sync.Map
}
type expireEntry struct {
ExpiresAt time.Time
Value interface{}
}
@hazcod
hazcod / plexdrive.service
Created August 25, 2020 05:33
plexdrive systemd settings
#### systemd script (/etc/systemd/system/plexdrive.service):
[Unit]
Description=Plexdrive
AssertPathIsDirectory=/media/plex/
After=network-online.target
### CONFIGURED FOR MAX ~58GB of MEMORY (change max-chunks to lower)
@hazcod
hazcod / osquery-queries.json
Created June 16, 2020 19:35
osquery queries extracted from kolide.
{
"options": {
"disable_audit": false,
"disable_events": false,
"enable_mouse_events": false,
"enable_keyboard_events": false,
"events_max": 10000,
"events_expiry": 3600,
"read_max": 52428800,
"logger_event_type": false,
@hazcod
hazcod / plex.sh
Last active May 12, 2020 12:36
Sonarr & Plex plex scanner.
#!/usr/bin/env bash
type="$1"
PLEXSCAN="/Applications/Plex Media Server.app/Contents/MacOS/Plex Media Scanner"
if [ "$type" != "Series" ] && [ "$type" != "Movies" ]; then
echo "Unknown type: $type"
exit 1
fi
@hazcod
hazcod / port-scanner.go
Last active April 21, 2020 15:57
Simple port scanner. Scans full host in 24sec.
package main
import (
"context"
"fmt"
"github.com/pkg/errors"
"net"
"strings"
"sync"
"syscall"
@hazcod
hazcod / telenet-modem-firewall.txt
Created March 26, 2020 14:54
Telenet modem firewall ruleset.
# Generated by iptables-save v1.4.21 on Sun Jan 19 08:14:54 2020
*raw
:PREROUTING ACCEPT [17478:786616]
:OUTPUT ACCEPT [15285:6842393]
COMMIT
# Completed on Sun Jan 19 08:14:54 2020
# Generated by iptables-save v1.4.21 on Sun Jan 19 08:14:54 2020
*nat
:PREROUTING ACCEPT [412:43501]
:INPUT ACCEPT [54:3686]
@hazcod
hazcod / github-archive-org.sh
Created November 28, 2019 10:47
Clone all your organization repositories on GitHub.
#!/usr/bin/env bash
# will ask for your personal access token
GH_USER=""
GH_ORG=""
curl -u "${GH_USERNAME}" -s "https://api.github.com/orgs/${GH_ORG}/repos?per_page=200" | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@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 {{{