msoliver
(usa Debian)
Enviado em 20/11/2019 - 19:34h
Saiko escreveu:
Olá galera :) Comecei a estudar shell há um tempo mas ainda estou no nível básico e não cheguei em funções. Apesar disso gostaria de entender como essa função que tirei de um script funciona, eu tentei utilizar ela mas não obtive nenhum resultado e ela não está funcionando no script de onde a tirei porque ele não estava obsfucado. Se puderem me ajudar, talvez com exemplos de uso, ficaria muito grato. Segue abaixo a função:
ofuscate_fun () {
unset link_list
unset txt_ofuscatw
unset txtofus
number=$(expr length $1)
for((i=1; i<$number+1; i++)); do
txt[$i]=$(echo "$1" | cut -b $i)
case ${txt[$i]} in
".") txt[$i]="#";;
"$") txt[$i]=".";;
"1") txt[$i]="@";;
"@") txt[$i]="1";;
"2") txt[$i]="?";;
"?") txt[$i]="2";;
"3") txt[$i]="&";;
"&") txt[$i]="3";;
esac
txtofus+="${txt[$i]}"
done
link_list=$(echo $txtofus|rev)
txt_ofuscatw=$(echo $txtofus|rev)
}
Pelo que entendi, essa função faz o mesmo que o comando abaixo:
sed 'y/abcdefghij/0123456789/' <<< 'marcelo'|rev
Troca os caracteres e inverte o texto, bem "ruinzinho"..... kkkkkk
Coloquei a SAÍDA, não existia.
#!/bin/bash
ofuscate_fun () {
number=$(expr length "$1")
for((i=1; i<$number+1; i++)); do
txt[$i]=$(echo $1 | cut -b $i)
case ${txt[$i]} in
a) txt[$i]="0";;
b) txt[$i]="1";;
c) txt[$i]="2";;
d) txt[$i]="3";;
e) txt[$i]="4";;
f) txt[$i]="5";;
g) txt[$i]="6";;
h) txt[$i]="7";;
i) txt[$i]="8";;
j) txt[$i]="9";;
esac
txtofus+="${txt[$i]}"
done
link_list=$(echo $txtofus|rev)
txt_ofuscatw=$(echo $txtofus|rev)
echo "SAÍDA: $txt_ofuscatw"
}
ofuscate_fun $1
Chame o script com um parâmetro,
Exemplo: ./script "vivaolinux"
SAÍDA: xun8lo0v8v
__________________________________________________________________
Importante: echo -e "$(lynx --dump goo.gl/a9KeFc|sed -nr '/^[ ]+Se/,/dou.$/p')"
Att.: Marcelo Oliver