From fd468bb05a89fa555facf46814fc1c19d0e328c3 Mon Sep 17 00:00:00 2001 From: Luke Bonanomi Date: Thu, 11 Apr 2019 16:48:47 -0700 Subject: [PATCH] Forget cURL & wget calls with inline passwords in shell history --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index d27c4ec..3f1c178 100644 --- a/README.md +++ b/README.md @@ -1163,6 +1163,25 @@ column -c3 -s " " -t | \ sort -nr | nl | head -n 20 ``` +###### Sterilize bash history + +```bash +function sterile() { + history | awk '$2 != "history" { $1=""; print $0 }' | egrep -vi "\ +curl\b+.*(-E|--cert)\b+.*\b*|\ +curl\b+.*--pass\b+.*\b*|\ +curl\b+.*(-U|--proxy-user).*:.*\b*|\ +curl\b+.*(-u|--user).*:.*\b* +.*(-H|--header).*(token|auth.*)\b+.*|\ +wget\b+.*--.*password\b+.*\b*|\ +http.?://.+:.+@.*\ +" > $HOME/histbuff; history -r $HOME/histbuff; +} + +export PROMPT_COMMAND="sterile" + +``` + ###### Quickly backup a file ```bash