Today i was doing a manual search for my website in google and received an error on the listing page (the site may have been compromised), so i did a manual check for my wordpress website pages and found link back to third party sites which were not visible on the front end but was visible when i viewed the source code. I have already deleted it from the header.php file in WordPress, but i just wanted to know how can i prevent this from happening in the future, does WordPress provides any security measures to avoid such attacks like XFF, code injectin and sql injection. The code inserted was seen between the <body> tag and <div id="header">. I searched for plugins in WordPress, does those plugin help in avoiding such cases, there are hundreds of plugin's available, and it is very hard to choose one, can any one recommend a good plugin.
I have never liked the way that these CMS require leaving so many files and folders writable just so that you can update plugins easily. But this may not be where the problem lays if they are editing database records to get to your templates.
Keep the core files and plugins up to date. Avoid using little known or unsupported plugins. Sift through your log files looking for attacks. Try WP Monitor to watch over changes to your files. Also read Hardening WordPress: [codex.wordpress.org...]