Skip to content

Instantly share code, notes, and snippets.

@denisde4ev
Last active February 20, 2025 23:05
Show Gist options
  • Save denisde4ev/8c71044a9a170239eaf36ad524ce9e4a to your computer and use it in GitHub Desktop.
Save denisde4ev/8c71044a9a170239eaf36ad524ce9e4a to your computer and use it in GitHub Desktop.
solving Arch Linux registration "Captcha" in pure shell script
#!/bin/bash
# only need bash for md5
set -eu
eval "curl(){ '$(which curl)' \"\$@\"; }" # only curl needed for md5 source;
# TODO/CONSIDER: https://stackoverflow.com/q/7765004 "TCP connection, bash only". also needs to resolve domain.
PATH='' # enshure we are pure shell
main() {
#!/bin/sh
# solving Arch Linux registration "Captcha" in pure shell script
# > To protect the AUR against automated account creation,
# > we kindly ask you to provide the output of the following
# > command: `LC_ALL=C pacman -V|sed -r 's#[0-9]+#e77#g'|md5sum|cut -c1-6`
#
# what, copy/pasting to terminal from internet.. NO! let me just sh it
# and yes in the end it worked! I registrated using the output from this script :D
{
# src: https://gitlab.archlinux.org/pacman/pacman/-/blob/ff7c6c8e570bcf5e07876397af864adf8cbf2987/src/pacman/pacman.c#L240-250
printf "\n"
printf " .--. Pacman v%s - libalpm v%s\n" ${RANDOM}.${RANDOM}.${RANDOM} ${RANDOM}.${RANDOM}.${RANDOM}
printf "/ _.-' .-. .-. .-. Copyright (C) 2006-2022 Pacman Development Team\n"
printf "\\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet\n"
printf " '--'\n"
printf " This program may be freely redistributed under\n"
printf " the terms of the GNU General Public License.\n"
printf "\n"
} | {
# for string replacing consider: https://github.com/kisslinux/kiss/blob/990eba374e685b841266ce025773e62af93912db/kiss#L106-L118
# wokrs, but too much of recursion
#s() {
# case $1 in
# *[0-9]*) printf %s\\n "$(s "${1%[0-9]*}")e77${1##*[0-9]}";;
# *) printf %s\\n "$1";;
# esac
#}
# sed -r 's#[0-9]+#???#g' # note: replaced string in '???' seems to be randomized
while IFS= read -r i; do
#for bash just use: ( shopt -s extglob; echo "${i//+([0-9])/e77}" )
while case $i in *[0-9]*) ;; *) false; esac; do
printf %s "${i%%[0-9]*}${1:?'usage: ${0##*/} <replace digit string>'}";
i=${i#*[0-9]}
while case $i in [0-9]*) ;; *) false; esac; do
i=${i#?}
done
done
printf %s\\n "$i"
done
} | md5sum | {
# cut -c1-6
read i
printf %s\\n "${i%"${i#??????}"}"
}
}
md5sum() { ( # src: https://raw.githubusercontent.com/waldner/baSHA123/190b1a225d616a60463e00196c3d1bd57036bd25/md5.sh
#!/bin/bash
set +e
if [ -f ./md5.bash ]; then
. ./md5.bash
else
eval "$(curl -sL https://raw.githubusercontent.com/waldner/baSHA123/190b1a225d616a60463e00196c3d1bd57036bd25/md5.sh)"
fi
); }
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment