commit cddfc813b3536445c4689ee47710b54c1a4f8027
parent 9bb66a8b42e50d5094d14abb3fecd1f37e834cac
Author: parazyd <parazyd@dyne.org>
Date: Sun, 2 Apr 2017 14:25:05 +0200
add moar
Diffstat:
18 files changed, 445 insertions(+), 33 deletions(-)
diff --git a/autoup b/autoup
@@ -12,6 +12,14 @@ test "$1" = -n && {
}
test -z "$1" && exit 1 || filename=$(basename $1)
+
+case "$filename" in
+ *_scrot.png)
+ webdir=tmp/screenshots
+ filename="screenshot$(( $(basename $(lynx -dump https://pub.parazyd.cf/tmp/screenshots | tail -n1 | tr -d '[a-z]./:' | awk '{print $2}')) + 1 )).png"
+ ;;
+esac
+
scp -i "$sshkey" "$1" "${sshuser}@${server}:${webroot}/${webdir}/${filename}" || exit 1
echo "https://$server/$webdir/$filename" | xclip -i
echo "https://$server/$webdir/$filename"
diff --git a/blck b/blck
@@ -0,0 +1,6 @@
+#!/bin/sh
+## shorten a url with blck.cf
+
+url="$1"
+
+curl -F "url=$url" https://blck.cf/
diff --git a/define b/define
@@ -0,0 +1,5 @@
+#!/bin/dash
+
+[ -n "$TORIFY" ] && proxy="--proxy socks5://127.0.0.1:9050"
+
+curl -s ${proxy} dict://dict.org/d:${1} | grep -E -v '^[0-9]|\[*\]' | less
diff --git a/dn b/dn
@@ -27,7 +27,7 @@ use() {
case "$1" in
o) use "out" "127.0.0.1";;
- h) use "fq" "10.0.2.1";;
+ h) use "fq" "10.66.66.1";;
b) use "bridge" "10.11.11.1";;
g) use "goog" "8.8.8.8";;
dv) use "dvn" "10.8.0.1";;
diff --git a/glyph b/glyph
@@ -0,0 +1,6 @@
+#!/bin/dash
+
+glyphs="$HOME/glyphs"
+
+cat "$glyphs" | dmenu -l 20 | cut -d' ' -f1 | tr -d '\n' | xclip -i
+xdotool key shift+Insert
diff --git a/gw b/gw
@@ -0,0 +1,6 @@
+#!/bin/dash
+
+#This prints random words from the linux dictionary.
+
+echo "$(shuf -n 32 /usr/share/dict/words --random-source=/dev/urandom | tr '\n' ' ')"
+
diff --git a/macspoof.sh b/macspoof.sh
@@ -1,24 +1,18 @@
#!/bin/sh
#
-# parazyd - (c) wtfpl 2016
+# parazyd - (c) wtfpl 2017
# spoof or restore mac
case "$1" in
- random|rand|r)
- echo "(*) randomizing $2's MAC"
- ip link set dev $2 down
- macchanger -r $2
- ip link set dev $2 up
- echo "(*) done!"
+ -p)
+ sup net "$2" stop
+ sudo macchanger -A "$2"
;;
- permanent|orig)
- echo "(*) restoring $2's MAC"
- ip link set dev $2 down
- macchanger -p $2
- ip link set dev $2 up
- echo "(*) done!"
+ -r)
+ sup net "$2" stop
+ sudo macchanger -p "$2"
;;
*)
- echo `basename $0` '{random|orig} {device}'
+ printf "usage: %s {-p [orig]|-r [random]} netdev\n" "$(basename $0)"
;;
esac
diff --git a/newifi b/newifi
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+usage() {
+ printf "usage: %s [essid] [bssid] [psk]\n" "$(basename $0)"
+ exit 1
+}
+
+wpasup=/etc/wpa_supplicant/wpa_supplicant.conf
+
+essid="$1"
+bssid="$2"
+psk="$3"
+
+[ -n "$essid" ] || usage
+[ -n "$bssid" ] || usage
+
+printf "[essid]: %s\n[bssid]: %s\n[psk]: %s\n" \
+ "$essid" "$bssid" "$psk"
+
+if [ -n "$psk" ]; then
+ cat <<EOF | sudo tee -a $wpasup
+
+network={
+ ssid="${essid}"
+ disabled=0
+ bssid=${bssid}
+ psk="${psk}"
+}
+EOF
+else
+ cat <<EOF | sudo tee -a $wpasup
+
+network={
+ ssid="${essid}"
+ disabled=0
+ bssid=${bssid}
+ auth_alg=OPEN
+ key_mgmt=NONE
+}
+EOF
+fi
diff --git a/obsolete/skrot b/obsolete/skrot
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-shotdir="$HOME/screenshots"
-
-case "x$1" in
- x-s)
- import "$shotdir/last.png" && \
- ;;
- x)
- import -window root "$shotdir/$(date +%Y-%m-%d-%H-%M-%S)-1366x768.png"
- ;;
- *)
- >&2 printf "skrot: internal error\n"
- exit 1
- ;;
-esac
diff --git a/parcimonie.sh b/parcimonie.sh
@@ -0,0 +1,227 @@
+#!/usr/bin/env bash
+
+# Copyright © 2015 Etienne Perot <etienne at perot dot me>
+# This work is free. You can redistribute it and/or modify it under the
+# terms of the Do What The Fuck You Want To Public License, Version 2,
+# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
+
+if [ -n "$PARCIMONIE_CONF" ]; then
+ source "$PARCIMONIE_CONF" || exit 'Bad configuration file.'
+ export PARCIMONIE_CONF='' # Children spawned by this script (if any) should not inherit those values
+fi
+
+parcimonieUser="${PARCIMONIE_USER:-$(whoami)}"
+gnupgBinary="${GNUPG_BINARY:-}"
+torsocksBinary="${TORSOCKS_BINARY:-torsocks}"
+gnupgHomedir="${GNUPG_HOMEDIR:-}"
+gnupgKeyserver="${GNUPG_KEYSERVER:-}"
+gnupgKeyserverOptions="${GNUPG_KEYSERVER_OPTIONS:-http-proxy=}"
+torAddress="${TOR_ADDRESS:-127.0.0.1}"
+torPort="${TOR_PORT:-9050}"
+minWaitTime="${MIN_WAIT_TIME:-900}" # 15 minutes
+targetRefreshTime="${TARGET_REFRESH_TIME:-604800}" # 1 week
+computerOnlineFraction="${COMPUTER_ONLINE_FRACTION:-1.0}" # 100% of the time
+useRandom="${USE_RANDOM:-false}"
+dirmngrPath="${DIRMNGR_PATH-}"
+dirmngrClientPath="${DIRMNGR_CLIENT_PATH-}"
+
+# -----------------------------------------------------------------------------
+
+if [ "$(whoami)" != "$parcimonieUser" ]; then
+ if [ "$parcimonieUser" == '*' ]; then # If user requested the script to run for all users
+ if [ "$(id -u)" != 0 ]; then
+ echo 'Error: Must be run as root in order to support PARCIMONIE_USER="*".'
+ exit 1
+ fi
+ gnupgUsers=()
+ for user in $(cut -d ':' -f 1 < /etc/passwd); do
+ if [ -d "$(eval "echo ~$user")/.gnupg" ]; then
+ gnupgUsers+=("$user")
+ fi
+ done
+ # If we have 0 users, error out
+ if [ "${#gnupgUsers[@]}" -eq 0 ]; then
+ echo 'Error: No users found with a ~/.gnupg directory.'
+ exit 1
+ fi
+ # If we just have one user, just su to it
+ if [ "${#gnupgUsers[@]}" -eq 1 ]; then
+ export PARCIMONIE_USER="${gnupgUsers[0]}"
+ export GNUPG_HOMEDIR="$(eval "echo ~"${gnupgUsers[0]}"")/.gnupg"
+ exec su -c "$0" "${gnupgUsers[0]}"
+ fi
+ # If we have more than one, spawn children processes for each
+ childrenPids=()
+ for user in "${gnupgUsers[@]}"; do
+ PARCIMONIE_USER="$user" GNUPG_HOMEDIR="$(eval "echo ~$user")/.gnupg" su -c "$0" "$user" &
+ childrenPids+=("$!")
+ done
+ for childPid in "${childrenPids[@]}"; do
+ wait "$childPid"
+ done
+ exit 0
+ else # If the user requested the script to run for a specific user which is not the current one
+ exec su -c "$0" "$parcimonieUser"
+ fi
+fi
+
+# If we get here, we know that we are the right user.
+
+# Find the gpg binary.
+if [ -n "$gnupgBinary" ]; then
+ if [ ! -x "$gnupgBinary" ]; then
+ echo "Error: GNUPG_BINARY '$GNUPG_BINARY' does not exist or is not executable."
+ exit 1
+ fi
+elif which gpg2 &> /dev/null; then
+ # Try to find it in $PATH.
+ gnupgBinary="$(which gpg2)"
+ echo "Detected gpg2 at '$gnupgBinary'."
+elif which gpg &> /dev/null; then
+ gnupgBinary="$(which gpg)"
+ echo "Detected gpg at '$gnupgBinary'."
+else
+ echo 'gpg not found. Please make sure you have installed GnuPG.'
+ echo 'You may manually specify the full path to gpg with GNUPG_BINARY.'
+ exit 1
+fi
+
+# Test for dirmngr, used in GnuPG >= 2.1 for keyserver communication.
+if [ -n "$dirmngrPath" ]; then
+ if [ ! -x "$dirmngrPath" ]; then
+ echo "Error: DIRMNGR_PATH '$DIRMNGR_PATH' does not exist or is not executable."
+ exit 1
+ fi
+elif which dirmngr &> /dev/null; then
+ # Try to find dirmngr in $PATH.
+ dirmngrPath="$(which dirmngr)"
+ echo "Detected dirmngr at '$dirmngrPath'; assuming GnuPG >= 2.1."
+else
+ echo 'dirmngr not specified, and not found in $PATH. Assuming GnuPG < 2.1.'
+fi
+
+if [ -n "$dirmngrPath" ]; then
+ # If we are using dirmngr, we must also have dirmngr-client.
+ if [ -n "$dirmngrClientPath" ]; then
+ if [ ! -x "$dirmngrClientPath" ]; then
+ echo "Error: DIRMNGR_CLIENT_PATH '$DIRMNGR_CLIENT_PATH' does not exist or is not executable."
+ exit 1
+ fi
+ elif which dirmngr-client &> /dev/null; then
+ # Try to find it in $PATH. Unlike dirmngr, it is a fatal error if we cannot find it,
+ # because we need it to handle dirmngr properly.
+ dirmngrClientPath="$(which dirmngr-client)"
+ echo "Detected dirmngr-client at '$dirmngrClientPath'."
+ else
+ echo "dirmngr-client not found, while dirmngr was found at '$dirmngrPath'."
+ echo 'Please make sure your installation of GnuPG is complete.'
+ echo 'You may manually specify the full path to dirmngr-client with DIRMNGR_CLIENT_PATH.'
+ exit 1
+ fi
+fi
+
+gnupgExec=("$gnupgBinary" --batch --with-colons)
+if [ -n "$gnupgHomedir" ]; then
+ gnupgExec+=(--homedir "$gnupgHomedir")
+fi
+if [ -n "$gnupgKeyserver" ]; then
+ gnupgExec+=(--keyserver "$gnupgKeyserver")
+fi
+if [ -n "$gnupgKeyserverOptions" ]; then
+ gnupgExec+=(--keyserver-options "$gnupgKeyserverOptions")
+fi
+
+# Test for GNU `sed`, or use a `sed` fallback in sedExtRegexp
+sedExec=(sed)
+if [ "$(echo 'abc' | sed -r 's/abc/def/' 2> /dev/null || true)" == 'def' ]; then
+ # GNU Linux sed
+ sedExec+=(-r)
+else
+ # Mac OS X sed
+ sedExec+=(-E)
+fi
+
+sedExtRegexp() {
+ "${sedExec[@]}" "$@"
+}
+
+keepDigitsOnly() {
+ sedExtRegexp -e 's/[^[:digit:]]//g' -e '/^$/d'
+}
+
+getRandom() {
+ if [ -z "$useRandom" -o "$useRandom" == 'false' ]; then
+ od -vAn -N4 -tu4 < /dev/urandom | keepDigitsOnly
+ else
+ od -vAn -N4 -tu4 < /dev/random | keepDigitsOnly
+ fi
+}
+
+nontor_gnupg() {
+ "${gnupgExec[@]}" "$@"
+ return "$?"
+}
+
+tor_gnupg() {
+ "$torsocksBinary" --isolate "${gnupgExec[@]}" "$@"
+}
+
+getPublicKeys() {
+ nontor_gnupg --list-public-keys --with-colons --fixed-list-mode --with-fingerprint --with-fingerprint --with-key-data |
+ grep -a -A 1 '^pub:' | # only allow fingerprints of public keys (not subkeys)
+ grep -E '^fpr:+[0-9a-fA-F]{40,}:' | # only allow fingerprints of v4 pgp keys
+ # (v3 fingerprints consist of 32 hex characters)
+ sedExtRegexp 's/^fpr:+([0-9a-fA-F]+):+$/\1/' # extract the fingerprint
+}
+
+getNumKeys() {
+ getPublicKeys | wc -l | keepDigitsOnly
+}
+
+getRandomKey() {
+ local allPublicKeys fingerprint
+ allPublicKeys=()
+ for fingerprint in $(getPublicKeys); do
+ allPublicKeys+=("$fingerprint")
+ done
+ echo "${allPublicKeys[$(expr "$(getRandom)" % "${#allPublicKeys[@]}")]}"
+}
+
+getTimeToWait() {
+ # The target refresh time is scaled by the fraction of time that the computer is expected to be online.
+ # expr or bash's $(()) don't support fractional math. Use awk.
+ local scaledRefreshTime
+ scaledRefreshTime="$targetRefreshTime"
+ if [ "$computerOnlineFraction" != '1.0' -a "$computerOnlineFraction" != '1' ]; then
+ scaledRefreshTime="$(echo "$scaledRefreshTime" "$computerOnlineFraction" | awk 'BEGIN {print sprintf("%.0f", $1 * $2)}')"
+ fi
+ # minimum wait time + rand(2 * (refresh time / number of pubkeys))
+ # = $minWaitTime + $(getRandom) % (2 * $scaledRefreshTime / $(getNumKeys))
+ # But if we have a lot of keys or a very short refresh time (2 * refresh time < number of keys),
+ # then we can encounter a modulo by zero. In this case, we use the following as fallback:
+ # minimum wait time + rand(minimum wait time)
+ # = $minWaitTime + $(getRandom) % $minWaitTime
+ if [ "$(expr '2' '*' "$scaledRefreshTime")" -le "$(getNumKeys)" ]; then
+ expr "$minWaitTime" '+' "$(getRandom)" '%' "$minWaitTime"
+ else
+ expr "$minWaitTime" '+' "$(getRandom)" '%' '(' '2' '*' "$scaledRefreshTime" '/' "$(getNumKeys)" ')'
+ fi
+}
+
+if [ "$(getNumKeys)" -eq 0 ]; then
+ echo 'No GnuPG keys found.'
+ exit 1
+fi
+
+if [ "$(echo "$computerOnlineFraction" | awk '{ print ($1 < 0.1 || $1 > 1.0) ? "bad" : "good" }')" == 'bad' ]; then
+ echo 'COMPUTER_ONLINE_FRACTION must be between 0.1 and 1.0.' >&2
+ exit 1
+fi
+
+while true; do
+ keyToRefresh="$(getRandomKey)"
+ timeToSleep="$(getTimeToWait)"
+ echo "> Sleeping $timeToSleep seconds before refreshing key $keyToRefresh..."
+ sleep "$timeToSleep"
+ tor_gnupg --recv-keys "$keyToRefresh"
+done
diff --git a/portscan.py b/portscan.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+import socket
+import sys
+import threading
+import time
+
+class counter():
+ def __init__(self):
+ self.lock = threading.Lock()
+ self.port = 0
+
+ def nextport(self):
+ self.lock.acquire()
+ if self.port >= 0:
+ self.port += 1
+ if self.port >= 65536:
+ self.port = -1
+ port = self.port
+ self.lock.release()
+ return port
+
+class scanner(threading.Thread):
+ tlist = []
+ pc = counter()
+
+ def __init__(self):
+ threading.Thread.__init__(self)
+ self.port = scanner.pc.nextport()
+
+ def run(self):
+ while (self.port > 0):
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.setblocking(0)
+ try:
+ print("(*) opening conn to %s:%s\r" % (host, self.port))
+ s.connect((host, self.port))
+ except socket.error, e:
+ if e[0] != 155:
+ raise
+
+ try:
+ time.sleep(timo)
+ s.send("")
+ s.shutdown(socket.SHUT_RDWR)
+ print("- port %s is open" % (self.port))
+ except socket.error:
+ #print("- port %s is probably closed" % (self.port))
+ pass
+ finally:
+ s.close()
+ self.port = scanner.pc.nextport()
+
+ def main():
+ global host, timo
+
+ if len(sys.argv) < 2:
+ print("usage: portscan.py [host] [maxthreads] [timeout]")
+ print("scans a host's TCP ports with conn attempts with a given")
+ print("response timeout (default 1s).")
+ sys.exit(1)
+
+ host = sys.argv[1]
+ maxt = int(sys.argv[2]) if len(sys.argv) > 2 else 666
+ timo = int(sys.argv[3]) if len(sys.argv) > 3 else 1
+ start = time.time()
+
+ print("(*) port scanning %s, %s ports at a time, timeout %s seconds" % (host, maxt, timo))
+
+ for i in range(0, maxt):
+ sc = scanner()
+ scanner.tlist.append(sc)
+ sc.start()
+ for sc in scanner.tlist:
+ sc.join()
+
+ print("(*) scan completed in %s seconds!" % (time.time() - start))
+
+ if __name__=="__main__":
+ main()
+
diff --git a/ptpb b/ptpb
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+[ -n "$TORIFY" ] && proxy="--proxy socks5://127.0.0.1:9050"
+
+curl -F c=@- https://ptpb.pw/?u=1
diff --git a/record b/record
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# parazyd - (c) wtfpl 2016
# screencast time
diff --git a/rot47 b/rot47
@@ -0,0 +1,2 @@
+#!/bin/sh
+tr '\!-~' 'P-~\!-O'
diff --git a/skrot b/skrot
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+case "$1" in
+ -s)
+ exec scrot -s '%Y-%m-%d_%H-%M-%S_$wx$h_scrot.png' -e 'mv -f $f /home/parazyd/screenshots/'
+ ;;
+ *)
+ exec scrot '%Y-%m-%d_%H-%M-%S_$wx$h_scrot.png' -e 'mv -f $f /home/parazyd/screenshots/'
+ ;;
+esac
diff --git a/update-gits b/update-gits
@@ -1,6 +1,6 @@
#!/bin/sh
-[ -n "$TORIFY" ] && tor=torsocks
+#[ -n "$TORIFY" ] && tor=torsocks
for i in $(printf %s\\n */); do
test -d "$i/.git" && {
diff --git a/wifi b/wifi
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+dev=wlan0
+wpasup=/etc/wpa_supplicant/wpa_supplicant.conf
+
+usage() {
+ printf "usage: %s new|enable|disable|restart}\n" "$(basename $0)"
+ exit 1
+}
+
+ask() {
+ printf "(*) choose one of these:\n"
+ grep 'ssid="' $wpasup | sed 's/ssid=//'
+ printf "[essid]: " ; read net
+ [ -n "$net" ] || exit 1
+ grep -q "$net" $wpasup || exit 1
+}
+
+en() {
+ [ -n "$net" ] || ask
+ sudo perl -i -0pe 's/disabled=0/disabled=1/g;s/(ssid="'$net'"\n.*)disabled=1/\1disabled=0/' $wpasup
+}
+
+dis() {
+ sudo perl -i -0pe 's/disabled=0/disabled=1/g;' $wpasup
+}
+
+case "$1" in
+ en|ena|enab*) net="$2" en;;
+ di|dis|disa*) net="$2" dis;;
+ d|down) sup net $dev stop;;
+ r|restart) sup net $dev restart;;
+ *) usage;;
+esac
diff --git a/yell b/yell
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+printf "%s" "$*" | sent