Please follow the below steps to clean the Hacked and malware code.
- Backup full database and files.
- Change FTP(cpanel) and database password.
NOTE: Once updated the database password, we need to update new password information in config file. For wordpress, wp-config.php is config file. This file located in wordpress root folder. It will change based on CMS and framework which one you have used. Please find below image to update wp-config.php file.
- Scan full site using online tool and security plugins.
We could use Wordfence for wordpress and Scan full site using your local antivirus software with download backup files. Please find the below image to scan the full site using Wordfence.

Online Scan Sites:
https://sitecheck.sucuri.net/
https://www.stopbadware.org/request-review
http://evuln.com/tools/malware-scanner/
4. Search and clean malware code in server files.
Remove all malware code which is you found using Step 3 scan steps.
Also, you could recheck the below files and remove any malware code if exist. You could found malware code very easy. Because, Surely malware code different from default function and code.
1. Index.php files in wordpress root folder and theme.
2. Header.php, footer.php and template files within all Themes which exist in /wp-content/themes/
3. config.php and htaccess file in root folder.
5. Search and clean within database.
Search the code within database using phpMyAdmin or other interface. Search keyword, you could take some part of malware code from scanned result. Remove it from database tables,if you found.
6. Now, surely your site back to live.
7. Also, ask you server support team to scan the full site and do the action based on support team scan result.
8. Finally need to do the below points to make sure to avoid hacking again! Please check other post in below link.
Update your wordpress site security settings