danyelmorales1991

obfuscator.sh

May 7th, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. output=$3
  4. filex=tmpmainfile.sh
  5. echo $"$(cat $2)" > $filex
  6. banner=$(figlet "$1" | gzip | base64)
  7. banner="base64 -d <<<\"$banner\" | gunzip"
  8. key="# ===BANNER==="
  9. perl -i -pe  "s@$key@$banner@gms" ${filex}
  10.  
  11. currentDir=$(dirname "$0")
  12. cp $currentDir/template.sh $output
  13.  
  14. funcaname="xf"$(dbus-uuidgen)
  15. barridoName="b"$(dbus-uuidgen)
  16. markerName="m"$(dbus-uuidgen)
  17. markerNameVar="m"$(dbus-uuidgen)
  18.  
  19. echo -n $markerNameVar"=\$(awk '/^___"$markerName"___/ {print NR+1; exit 0; }' \"\${0}\");" >> $output
  20. echo -n $barridoName"=\$(tail -n+\${"$markerNameVar"} \"\${0}\");" >> $output
  21.  
  22. echo "" >> $output
  23. echo 'function '$funcaname'(){' >> $output
  24. echo 'echo $(base64 -d <<< "$1"| gunzip);' >> $output
  25. echo '}' >> $output
  26.  
  27. REGX=()
  28. IN=$(cat $filex)
  29. while IFS=$'\n' read -ra ADDR; do
  30.   for i in "${ADDR[@]}"; do
  31.     varxxa="X02D"$(dbus-uuidgen)
  32.     cz=$(echo $"$i" | tr -d '\0'| gzip| base64 )
  33.     echo -n $varxxa"=\$($funcaname \"$cz\");" >> $output
  34.     REGX+=($varxxa)
  35.   done
  36. done <<< "$IN"
  37.  
  38. echo -n $"pbv921=\$(eval \"echo \$\\\"\$"$barridoName"\\\"\");" >> $output
  39. echo -n "b17320=\"\$(cat \${0})\";" >> $output
  40. echo -n "echo \$\"\$pbv921\" > \${0};" >> $output
  41. echo -n "echo \$\"\$(\${0} \${@})\" && echo \$\"\$b17320\" > \${0};" >> $output
  42.  
  43. echo "exit 0;"  >> $output
  44. echo "___"$markerName"___" >> $output
  45. for i in "${REGX[@]}"; do
  46.   echo -n "$"$i"\$z" >> $output
  47. done
  48. echo -n "\"\"" >> $output
  49. rm $filex &2>/dev/null
Add Comment
Please, Sign In to add comment