diff options
Diffstat (limited to 'util/bin')
-rwxr-xr-x | util/bin/anonbox.net | 57 | ||||
-rwxr-xr-x | util/bin/google.suggest | 8 | ||||
-rwxr-xr-x | util/bin/krebdate | 10 | ||||
-rwxr-xr-x | util/bin/make-data-url | 7 | ||||
-rwxr-xr-x | util/bin/my-global-ipv4-addr | 51 | ||||
-rwxr-xr-x | util/bin/randline | 2 | ||||
-rwxr-xr-x | util/bin/translate.google | 44 |
7 files changed, 179 insertions, 0 deletions
diff --git a/util/bin/anonbox.net b/util/bin/anonbox.net new file mode 100755 index 00000000..d038cd0a --- /dev/null +++ b/util/bin/anonbox.net @@ -0,0 +1,57 @@ +#! /bin/bash +#### anonbox.net [--check] +#### anonbox account creator +set -euf + +## +script_begin_date="`date --rfc-3339=ns`" + +## +GET() { + wget --quiet --no-check-certificate -O- https://anonbox.net/en/ +} + +## retrieve data +eval "$(${GET-GET} | + sed -rn ' +s^<dd><p>([[:alnum:]@.]+)</p></dd>$\ + email="\1" ; p +s^<dd><p><a href="([^"\\]+)">.*</a></p></dd>$\ + uri="\1/" ; p +s^<dd><p>([0-9]+)/([0-9]+)/([0-9]+) ([0-9]+):([0-9]+) ([ap]).m.</p></dd>$\ + Y=20\3 ; \ + m=\1 ; \ + d=\2 ; \ + H=\4 ; \ + M=\5 ; \ + p=\6 ; p')" + +## make best-before-date RFC-3339-(seconds)-conform +case "$p" in + p) H="`echo $H+12 | bc`" ;; +esac +s=00 +z=+02:00 +best_before="$Y-$m-$d $H:$M$z" + +## +script_end_date="`date --rfc-3339=ns`" + +## +for key in email uri best_before script_begin_date script_end_date ; do + eval "val=\"\$$key\"" + echo "$key=\"$val\"" +done + +## +if echo "$*" | tr "$IFS" ' ' | egrep -q "(^| )--check( |$)"; then + file="/tmp/save-$email" + echo "file=\"$file\"" + echo >&2 + echo "# downloading email..." >&2 + while ! curl -ksS "$uri" | tee "$file" | grep .; do + sleep 10 + done +fi + +#### end of file. diff --git a/util/bin/google.suggest b/util/bin/google.suggest new file mode 100755 index 00000000..9bde17dc --- /dev/null +++ b/util/bin/google.suggest @@ -0,0 +1,8 @@ +#! /bin/sh + +uri="http://google.com/complete/search?output=json&q=$*" + +curl -sS "$uri" | sed -n ' + s:^window.google.ac.h(\|)$::gp +' +echo diff --git a/util/bin/krebdate b/util/bin/krebdate new file mode 100755 index 00000000..b2aa02d2 --- /dev/null +++ b/util/bin/krebdate @@ -0,0 +1,10 @@ +#! /bin/sh +set -euf + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +date --date="`ssh krebs 'date --rfc-3339=s'`" diff --git a/util/bin/make-data-url b/util/bin/make-data-url new file mode 100755 index 00000000..a9d014e6 --- /dev/null +++ b/util/bin/make-data-url @@ -0,0 +1,7 @@ +#! /bin/sh +set -euf +for path; do + type="`file -bi "$path"`" + data="`base64 -w 0 "$path"`" + echo "data:$type;base64,$data" +done diff --git a/util/bin/my-global-ipv4-addr b/util/bin/my-global-ipv4-addr new file mode 100755 index 00000000..305d3f80 --- /dev/null +++ b/util/bin/my-global-ipv4-addr @@ -0,0 +1,51 @@ +#! /bin/sh +# +# usage: my-global-ipv4-addr [URL] +# +# if URL is provided then fetch and parse it for IPv4 addrs +# else try all known urls +# +if test $# = 1; then + has() { type "$1" 1>/dev/null 2>/dev/null; } + parse() { + sed -rn 's/.*((1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])).*/\1/p' | grep . + } + get () { + # TODO get random valid user agent + if has curl; then + curl -m 1 -A Mozilla -sS "$1" 2>/dev/null + elif has wget; then + wget -T 1 -U Mozilla -O "$1" 2>/dev/null + else + echo 'Error 1: You are made of stupid!' >&2 + exit 23 + fi + } + + #addrs="`get "$1" | parse`" + #echo "$1:" $addrs >&2 + #echo "$addrs" + get "$1" | parse +else + + vote() { + sort | uniq -c | sort -r -n + } + winner() { + head -n 1 | awk '{print$2}' + } + + grep -v ^# | + sed -n '1,$p' | + xargs -P 42 -n 1 "$0" | vote | winner +fi<<EOF +checkip.dyndns.com +www.whatismyip.de +www.eigene-ip.de +whatismyip.org +www.ipaddressworld.com +http://ip-check.info/?lang=de +http://www.ip-adress.com/what_is_my_ip/ +http://www.spyber.com/ +http://www.ipchicken.com/ +EOF diff --git a/util/bin/randline b/util/bin/randline new file mode 100755 index 00000000..df36b344 --- /dev/null +++ b/util/bin/randline @@ -0,0 +1,2 @@ +#! /bin/sh +cat | shuf | head -n 1 diff --git a/util/bin/translate.google b/util/bin/translate.google new file mode 100755 index 00000000..1a1be6b6 --- /dev/null +++ b/util/bin/translate.google @@ -0,0 +1,44 @@ +#! /bin/sh +set -euf + +A=Mozilla +url=http://translate.google.com/ + +pwd="$(dirname "$(readlink -f "$0")")" + +for x in \ + "$pwd/../../submodules/github/tmpvar" \ + "$pwd/../../submodules/github/mikeal" \ + "$pwd/../../submodules/github/NV" \ + "$pwd/../../submodules/github/tautologistics" \ +; do + export NODE_PATH="`readlink -f "$x"`${NODE_PATH+:$NODE_PATH}" +done + +# ensure query is ready +(cd "$pwd/../.." && git submodule update --init) + +{ + for arg; do echo "$arg"; done | sed -rn ' + s/^--(.*=.*)/\1/p;t + s/.*/text="${text+$text }&"/p;t + ' + cat<<EOF + query() { + node "$(readlink -f "$pwd/../../submodules/github/visionmedia/query")" "\$@" + } + curl -sS -A "\${A-Mozilla}" \\ + -d "js=\${js-n}" \\ + -d "prev=\${prev-_t}" \\ + -d "hl=\${hl-en}" \\ + -d "layout=\${layout-2}" \\ + -d "eotf=\${eotf-1}" \\ + -d "ie=UTF-8" \\ + -d "oe=UTF-8" \\ + -d "sl=\${sl-auto}" \\ + -d "tl=\${tl-en}" \\ + -d "text=\$text" \\ + "$url" | + query '#result_box' text +EOF +} | sh |