[root@localhost Desktop]# cat script.sh2. Tạo file encode base64
#!/usr/bin/env bash
echo "Day la noi dung test"
[root@localhost Desktop]# echo '#!/usr/bin/env bash' > other.sh3. Encode sử dụng hex
[root@localhost Desktop]# echo "echo '$(base64 script.sh)' | base64 -d | sh" >> other.sh
[root@localhost Desktop]# cat other.sh
#!/usr/bin/env bash
echo 'IyEvdXNyL2Jpbi9lbnYgYmFzaAplY2hvICJEYXkgbGEgbm9pIGR1bmcgdGVzdCIK' | base64 -d | sh
[root@localhost Desktop]# cat ./obfuscate.sh4. Run code obfuscate.sh
#!/bin/bash
if [[ $# -ne 1 ]] ; then
CMD="echo 'IyEvdXNyL2Jpbi9lbnYgYmFzaAplY2hvICJEYXkgbGEgbm9pIGR1bmcgdGVzdCIK' | base64 -d | sh"
else
CMD=$1
fi
B64=$(echo -n $CMD | base64)
MIDDLE="eval \`echo \"$B64\" | base64 -di\`"
CODE=$(echo -n $MIDDLE | hexdump -v -e '"\\\x" 1/1 "%02x"')
LOL="eval \`echo -e \"$CODE\"\`"
echo $LOL
[root@localhost Desktop]#
[root@localhost Desktop]#echo '#!/usr/bin/env bash' > script_enc.sh
[root@localhost Desktop]# ./obfuscate.sh >> script_enc.sh
Done
Ta được file đã encode:
[root@localhost Desktop]# cat script_enc.sh
#!/usr/bin/env bash
eval `echo -e "\x65\x76\x61\x6c\x20\x60\x65\x63\x68\x6f\x20\x22\x5a\x57\x4e\x6f\x62\x79\x41\x6e\x53\x58\x6c\x46\x64\x6d\x52\x59\x54\x6e\x6c\x4d\x4d\x6b\x70\x77\x59\x6d\x6b\x35\x62\x47\x4a\x75\x57\x57\x64\x5a\x62\x55\x5a\x36\x59\x55\x46\x77\x62\x46\x6b\x79\x61\x48\x5a\x4a\x51\x30\x70\x46\x57\x56\x68\x72\x5a\x32\x4a\x48\x52\x57\x64\x69\x62\x54\x6c\x77\x53\x55\x64\x53\x20\x4d\x57\x4a\x74\x59\x32\x64\x6b\x52\x31\x5a\x36\x5a\x45\x4e\x4a\x53\x79\x63\x67\x66\x43\x42\x69\x59\x58\x4e\x6c\x4e\x6a\x51\x67\x4c\x57\x51\x67\x66\x43\x42\x7a\x61\x41\x3d\x3d\x22\x20\x7c\x20\x62\x61\x73\x65\x36\x34\x20\x2d\x64\x69\x60"`
Không có nhận xét nào:
Đăng nhận xét