Skip to content

Instantly share code, notes, and snippets.

View nexus166's full-sized avatar
🌪️
🐧

nexus166

🌪️
🐧
  • Earth
View GitHub Profile
@nexus166
nexus166 / sping
Last active March 17, 2020 14:23
fastest ping scan of the World Wide West
#!/bin/sh -e
SUBNET="${1}";
TIMEOUT="${2:-2}";
pingw8="-w";
uname | grep -i darwin && export pingw8="-W";
ping_cmd() { for octet in $(seq 1 254); do ( ping "$1.$octet" -c 1 "$pingw8" "$TIMEOUT" > /dev/null 2> /dev/null && printf "%s.%s\n" "$1" "$octet" ) & done | sort -V; };
if [ ! -t 0 ]; then
#!/bin/sh
COUNTRY="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
if [ -z "$COUNTRY" ]; then printf "\\n\\tNO COUNTRY CODE SPECIFIED\\n\\n" && exit 1; fi
IPSET_SET="${COUNTRY}-subnets"
IPSET="$(command -v ipset || exit 1)"
printf "\\n\\tPREPARING IPSET SET\\t\\t\\t[%s]" "$IPSET_SET" && \
"$IPSET" flush "$IPSET_SET" || "$IPSET" create "$IPSET_SET" hash:net && \
printf "\\n\\tDOWNLOADING AND IMPORTING SUBNETS.." && \
curl -s -o- "http://www.ipdeny.com/ipblocks/data/countries/$COUNTRY.zone" | \
grep -Eo '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+/[0-9]+' | \
@nexus166
nexus166 / msg
Last active March 3, 2019 16:55
sexy logging for shell scripts
#!/bin/sh
msg()
{
tstamp()
{
tput setaf 7;
date "+%d.%m.%Y %T.%N %Z";
tput sgr0
};
@nexus166
nexus166 / golang-tls.md
Last active March 9, 2019 19:51 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
#!/bin/sh
# add this function to your env and then import other scripts with:
# eval "$(ghload gist nexus166/msg 581472463579c73e15aa71e6db610cb7)"
ghload() {
MOD_TYPE=${1}; TOLOAD=${2}; MODULE=${3};
GH_NAME="$(echo ${TOLOAD} | cut -d'/' -f1)"; GH_REPO="$(echo $TOLOAD | cut -d'/' -f2)";
ghGISTS="https://gist.github.com"; ghREPOS="https://raw.githubusercontent.com";
_man() { printf "Usage:\\n\\t\$> ghload gist nexus166/msg 581472463579c73e15aa71e6db610cb7\n\\t\$> ghload repo Spajderix/barc README.md\\n"; };
@nexus166
nexus166 / web-servers.md
Created March 16, 2019 15:19 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@nexus166
nexus166 / flask-auth_request-proxy.py
Created March 18, 2019 11:52
delegate BasicAuth to a Vault instance (ngx_http_auth_request_module)
import os
import hvac
import json
from flask import Flask, request, make_response
app = Flask(__name__, template_folder='templates')
app.config['SECRET_KEY'] = 'https:/your.vault.instance:8200/'
app.config['FLASK_ENV'] = 'production'
#!/usr/bin/env bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
V4=$(which iptables)
V6=$(which ip6tables)
[[ $(id -u) -eq 0 ]] || exit 1
_install() {
if [[ ! -e /usr/local/sbin/fwbase.sh ]]; then cat ${0} | tee /usr/local/sbin/fwbase.sh; fi
#!/bin/sh -e
printf "%s" "$(tr -cd '[:graph:]' < ${2:-/dev/urandom} | tr -d '\-#&\+,\.\/\:\`\"'\' | head -c${1:-32})";

tldr

docker plugin install rexray/s3fs \
  S3FS_OPTIONS="allow_other,use_path_request_style,nonempty,url=https://s3.my.xyz" \
  S3FS_ENDPOINT="https://s3.my.xyz" \
  3FS_ACCESSKEY="xxx" \
  3FS_SECRETKEY="yyy"