Yesterday I found out there is this http://pastebin.com/MRRny4Ht PHP file in my friends server. I want to know how was the hacker able to upload it there? I read the similar questions but couldn't find a correct answer.
EDIT:-
Today I got to know that the WordPress site has been breached by brute-forcing the password (The password is strong). I still don't know how they managed to crack that password.
After cracking the password they logged in and uploaded the php files.After googling about Donnazmi.txt I found out that so many other sites are also hacked on or around the same day (july 13th). The hacks using the same script are still going on. The password for the WordPress server has been changed to more complex one and those php files have been deleted.
Thank you for the answers and comments. Sorry, I should have given more information while posting the question.
What steps can be taken to retrace a Shell Upload on a WordPress installation
it might still be closed as too broad, but I could at least imagine possible answers (look at logs, look at vulnerability databases for new vulnerabilities in your plugins/themes, check the versions of your software, etc), which might be nice as a canonical answer for these types of questions, which do come up quite often.