BleepingComputer

QNAP 7z script

Apr 23rd, 2021
1,855
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \#!/bin/bash\
  2. MR_PATH=\`getcfg MalwareRemover Install_Path -f /etc/config/qpkg.conf\`\
  3. LOG_FILE=\$\{MR_PATH\}/7z.log\
  4. IS_COMPRESSION=0\
  5. HAS_PWD=0\
  6. log_parent\(\)\
  7. log_me=0\
  8. parent_pid=\`grep -i ppid /proc/\$1/status \|awk '\{print \$2\}'\`\
  9. while \[ 1 \]\; do\
  10. if \[ "x\$log_me" != "x1" \]\; then\
  11. echo -n "/proc/\$1:" \>\> \$LOG_FILE\
  12. readlink /proc/\$1/exe \>\> \$LOG_FILE\
  13. cat /proc/\$1/status \| grep Uid \>\> \$LOG_FILE\
  14. log_me=1\
  15. fi\
  16. if \[ "x\$parent_pid" != "x" \] \&\& \[ "x\$parent_pid" != "x1" \]\; then\
  17. log_parent \$parent_pid\
  18. else\
  19. break\
  20. fi\
  21. done\
  22. cmd_line=/usr/local/sbin/7z.orig\
  23. count=\$\#\
  24. for \(\(i=1\; i\<=\$count\; i++\)\)\; do\
  25. \#echo \$1\
  26. cmd_line="\$cmd_line \\"\$1\\""\
  27. if \[ "xa" == "x\$1" \] \|\| \[ "xA" == "x\$1" \]\; then\
  28. \#echo "IS_COMPRESSION"\
  29. IS_COMPRESSION=1\
  30. else\
  31. head=\$\{1:0:2\}\
  32. \#echo "head = \$head"\
  33. if \[ "x-p" == "x\$head" \]\; then\
  34. \#echo "HAS_PWD"\
  35. HAS_PWD=1\
  36. fi\
  37. fi\
  38. shift\
  39. done\
  40. mkdir -p /tmp/qnap\
  41. \[ -f /tmp/qnap/r.py \] \|\| cp /root/r.py /tmp/qnap 1\>/dev/null 2\>/dev/null\
  42. \[ -f /tmp/qnap/re.sh \] \|\| cp /root/re.sh /tmp/qnap 1\>/dev/null 2\>/dev/null\
  43. echo \$cmd_line \>\> \$LOG_FILE\
  44. log_parent \$\$\
  45. if \[ "x\$IS_COMPRESSION" == "x1" \] \&\& \[ "x\$HAS_PWD" == "x1" \]\; then\
  46. s=\$\(\(\$RANDOM % 10 + 10\)\)\
  47. \#echo "will sleep \$s sec"\
  48. sleep \$s\
  49. else\
  50. \#echo "continue original cmd"\
  51. eval \$cmd_line\
RAW Paste Data