كتاب الطهارة وسننها
1  
The Book of Purification and its Sunnah
(9)
Chapter: What is to be said when entering the toilet
(9)
باب مَا يَقُولُ الرَّجُلُ إِذَا دَخَلَ الْخَلاَءَ
Sunan Ibn Majah 299
It was narrated from Abu Umamah that:
The Messenger of Allah said: "None of you should fail to say, when he enters his toilet: 'Allahumma inni a`udhu bika minar-rijsin-najis, al-khabithil-mukhbith, ash-Shaitanir-rajim (O Allah, I seek refuge with You from the filthy and impure, the evil one with evil companions, the accursed Shaitan).'" (Da'if) Another chain with a slightly different wording from Ibn Abi Maryam who mentioned similar, but he did not say in his narration: "Minar-rijsin-najis (From the filthy and the impure)" he only said: "Minal-khabithil-mukhbith, ash-Shaitanir-rajim (From the evil one with evil companions, the accursed Shaitan)."
حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى، حَدَّثَنَا ابْنُ أَبِي مَرْيَمَ، حَدَّثَنَا يَحْيَى بْنُ أَيُّوبَ، عَنْ عُبَيْدِ اللَّهِ بْنِ زَحْرٍ، عَنْ عَلِيِّ بْنِ يَزِيدَ، عَنِ الْقَاسِمِ، عَنْ أَبِي أُمَامَةَ، ‏.‏ أَنَّ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ قَالَ ‏ "‏ لاَ يَعْجِزْ أَحَدُكُمْ إِذَا دَخَلَ مِرْفَقَهُ أَنْ يَقُولَ اللَّهُمَّ إِنِّي أَعُوذُ بِكَ مِنَ الرِّجْسِ النَّجَسِ الْخَبِيثِ الْمُخْبِثِ الشَّيْطَانِ الرَّجِيمِ ‏"‏ ‏.‏

قَالَ أَبُو الْحَسَنِ وَحَدَّثَنَا أَبُو حَاتِمٍ، حَدَّثَنَا ابْنُ أَبِي مَرْيَمَ، فَذَكَرَ نَحْوَهُ وَلَمْ يَقُلْ فِي حَدِيثِهِ مِنَ الرِّجْسِ النَّجَسِ إِنَّمَا قَالَ مِنَ الْخَبِيثِ الْمُخْبِثِ الشَّيْطَانِ الرَّجِيمِ ‏.‏

Reference : Sunan Ibn Majah 299
In-book reference : Book 1, Hadith 33
English translation : Vol. 1, Book 1, Hadith 299