For comment spam: you can use Hide My WP Ghost to hide: wp-comments-post.php.
Note! Hiding the file wp-comments-post.php will NOT stop the people who fill in the comment forms on your site and send you spam comments.
To completely stop spam comments, we recommend also installing a dedicated Anti-Spam plugin which has a database of spam emails and messages.
^^ Those were related to measures against automatic spam.
We also help against spammers who find your site has Elementor (for example) or WordPress and then spam you based on knowing that info. They think they are “targeting” you that way and that you’ll be interested in their offers.
However, strictly for contact form spam: we don’t currently offer a feature inside Hide My WP Ghost against that.
HMWP Ghost was made mostly for blocking the access of bots to the login, admin, and vulnerable themes/plugins.
It also stops the bots submission on the wp-comments-posts.php path but does not stop the comments made through the form submission.
For this, we recommend using a dedicated plugin such as AntiSpam Bee.