Skip to content

Instantly share code, notes, and snippets.

@lbonanomi
Created August 5, 2021 01:48
Show Gist options
  • Save lbonanomi/5a987b5f0987f3b1863245d54ae00848 to your computer and use it in GitHub Desktop.
Save lbonanomi/5a987b5f0987f3b1863245d54ae00848 to your computer and use it in GitHub Desktop.
BASH_ENV script to nag users about piping curl calls into bash
# The construction `curl http://example.com/shellscript.sh | bash` fills me with boiling rage
#
# export BASH_ENV=/usr/local/bin/blockCurlPipeBash.sh
if [[ $(grep "$(cat /proc/$$/cmdline | tr '\000' "\n" | tail -1)$" /etc/shells) ]]
then
# |- In case of non-interactive session -| |- dump PID table to find all sibling PIDs -|
#
echo $- | grep -qv i && ps awwwx -ocmd,pid,ppid | grep "$(ps -p $$ -o ppid | tail -1)$" | while read p
do
sib=$(echo "$p" | awk '{ print $(NF-1) }')
egrep -q ":0050|:01BB|:1F90|:20FB" /proc/$sib/net/tcp 2>/dev/null && kill -SIGSTOP $sib 2>/dev/null &&\
echo "If you 𝙧𝙚𝙖𝙡𝙡𝙮 want to execute some random-ass script from the Internet type ctrl-Z and then 𝗳𝗴"
done | uniq
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment