calebstewart / pwncat

Fancy reverse and bind shell handler
https://pwncat.readthedocs.io
MIT License
2.58k stars 250 forks source link

Methodically check existence and permissions before adding authkeys #263

Closed lavafroth closed 1 year ago

lavafroth commented 2 years ago

Description of Changes

Addresses https://github.com/calebstewart/pwncat/issues/260. The Linux implant module for authorized keys now checks for the existence of the .ssh directory and the key file. Any file or directory created in the process as well as permission changes will be reverted on calling remove on the implant.

The implant now keeps track of all the tampers it has committed and the remove function rolls back all the changes.

Please note any noqa: comments needed to appease flake8.

Major Changes Implemented:

Pre-Merge Tasks

pytest results

4 failed, 26 passed

tests/test_platform.py::test_platform_su[ubuntu] FAILED
tests/test_platform.py::test_platform_su[centos] FAILED
tests/test_platform.py::test_platform_sudo[ubuntu] FAILED 
tests/test_platform.py::test_platform_sudo[centos] FAILED

Note: Running these tests on the pwncat master branch returned the same results for me.

For issues with pre-merge tasks, see CONTRIBUTING.md