For a cyber security competition I participate in, I\'m given a Debian virtual machine with many packages installed and asked to clean extraneous or malicious packages.
This command may shorten your work:
apt-mark showmanual
It is supposed to show what packages were installed "manually". It is not 100% reliable though, as many automatically installed packages are flagged as manually installed (because of reasons too long to describe here).
You may also (if allowed) run security tools such as clamav
and/or rkhunter
to scan your computer for malicious programs.