Sunan Abu Dawud #5102
General Behavior (Kitab Al-Adab) 43:330
Abu Hurairah reported the Prophet (May peace be upon him) as saying:
when you hear the cocks crowing, ask Allah for some of His grace, for they have seen as angel; but when you hear an ass braying, seek refuge in Allah from the devil, for it has seen the devil.