Tiny Core - Uninstall SSH
0 Votes |
Description
Uninstalls SSH and cleans up files used for persistence
Property Details
26984 | |
Production - Fully Tested and Ready for Production | |
Tiny Core - Uninstall SSH | |
Internal | |
4/5/2022 12:00:00 AM | |
Tiny Core Linux Relay, SSH | |
True | |
JulesM on 12/12/2022 8:02:13 AM | |
JulesM on 12/12/2022 8:02:13 AM | |
125 Views / 1 Download | |
![]() ![]() ![]() ![]() ![]() |
Relevance
Actions
Action 1 (default)
Action Link Click
here to Uninstall SSH.
Script Type
BigFix Action Script
delete __appendfile
appendfile #!/bin/sh
appendfile sudo /usr/local/etc/init.d/openssh stop
appendfile sleep 10
appendfile su -c "tce-audit builddb" tc
appendfile su -c "tce-audit delete openssh" tc
appendfile sudo rm -rf /var/lib/sshd/
appendfile sudo rm -f /var/opt/BESClient/__BESData/__Global/UsageData/sshd.stat
appendfile sudo rm -f /var/opt/BESClient/__BESData/__Global/UsageData/ssh-keygen.stat
//Delete .ssh directory and public key
appendfile sudo rm -rf /home/tc/.ssh/
//Delete the ssh monitoring script
appendfile sudo rm -f /home/tc/scripts/sshmon.sh
//The following removes lines from files used for persistence
if {exists (lines whose (it = "openssh.tcz") of files "/mnt/sda1/tce/onboot.lst")}
appendfile sed -i '/openssh.tcz/d' /mnt/sda1/tce/onboot.lst
endif
if {exists (lines whose (it = "usr/local/etc/ssh/") of files "/opt/.filetool.lst")}
appendfile sed -i '/usr\/local\/etc\/ssh\//d' /opt/.filetool.lst
endif
if {exists (lines whose (it = "opt/var/lib/sshd/") of files "/opt/.filetool.lst")}
appendfile sed -i '/opt\/var\/lib\/sshd\//d' /opt/.filetool.lst
endif
if {exists (lines whose (it = "sudo /usr/local/etc/init.d/openssh start") of files "/opt/bootlocal.sh")}
appendfile sed -i '/sudo \/usr\/local\/etc\/init.d\/openssh start/d' /opt/bootlocal.sh
endif
appendfile sudo filetool.sh -b
appendfile sleep 10
delete /var/opt/BESClient/uninstallssh.sh
move __appendfile /var/opt/BESClient/uninstallssh.sh
wait chmod 750 /var/opt/BESClient/uninstallssh.sh
wait /bin/sh /var/opt/BESClient/uninstallssh.sh
if {exists file "/home/tc/.ssh/authorized_keys"}
exit 1
endif
delete /var/opt/BESClient/uninstallssh.sh
run sudo reboot
Success Criteria
This action will be considered successful when the applicability relevance evaluates to false.
Sharing
Social Media: |