The Messenger of Allah ﷺ said, "When you hear the crowing of roosters at night, it is because they have seen an angel, so ask Allah of His bounty. And when you hear the braying of a donkey, it is because it has seen a devil, so seek refuge with Allah from Satan."
حدثنا هاشم حدثنا ليث عن جعفر بن ربيعة عن عبد الرحمن بن هرمز
عن رسول الله ﷺ أنه قال إذا سمعتم صياح الديكة من الليل فإنما رأت ملكا سلوا الله من فضله وإذا سمعتم نهاق الحمار فإنه رأى شيطانا فتعوذوا بالله من الشيطان
Its isnad is sahih. Hashim is Ibn Qasim, Abu Nadr. Layth is Ibn Saad, the Imam. Bukhari related the hadith in 6:251 of Fath [Bari], and Muslim in 2:318, both of them from Qutayba bin Saeed, from Layth bin Saad, with the same wording.