From 903ce1892b312f9b418d9f9a050c5c25c4e9c691 Mon Sep 17 00:00:00 2001 From: lbonanomi <5369016+lbonanomi@users.noreply.github.com> Date: Mon, 11 Nov 2019 08:18:51 -0500 Subject: [PATCH] Update README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 2548037..e24f5cd 100644 --- a/README.md +++ b/README.md @@ -3806,6 +3806,7 @@ grep "\-\-" filename - [Domain resolve](#domain-resolve) - [Get ASN](#get-asn) +- [Store script files as gists](#scriptfiles-to-Gists) ###### Domain resolve @@ -3888,3 +3889,26 @@ shell> GetASN 1.1.1.1 shell> GetASN 0.0.0.0 Unsuccessful ASN gathering. ``` + +###### scriptfiles to Gists + +function scripto() { + # Automatically upload /bin/script scriptfiles as Github.com gists + + # Sane API token? + curl -Insw "%{http_code}" https://api.github.com/user | tail -1 | grep -q 200 || (echo "Can't reach API" && return 1) + + # Instance a gist and clone it + GISTID=$(curl -nksd '{"files":{"sfile":{"content":"scriptfile in-flight"}}}' https://api.github.com/gists | awk -F"\"" '$2 == "id" {print $4}' | head -1); + git clone -q "https://gist.github.com/"$GISTID".git" ~/$GISTID &>/dev/null; + + # API and gist can use the same token but need different addresses, check we can push back a complete gist + if (cd ~/$GISTID && git push &>/dev/null || return 2) + then + script -qf ~/$GISTID/sfile && (cd ~/$GISTID && git add * && git commit -m "." && git push origin && rm -rf ~/$GISTID/.git ~/$GISTID/sfile && rmdir ~/$GISTID); + curl -nks -X PATCH -d '{ "files":{ "sfile": { "filename":"'$(hostname)' typescript"}}}' https://api.github.com/gists/$GISTID >/dev/null + else + echo "No token for gist.github.com" + rm -rf ~/$GISTID/.git ~/$GISTID/sfile && rmdir ~/$GISTID + fi +}