The Book of Zuhd and Softening of Hearts
Ṣaḥīḥ Muslim 7465
لاَ تَدْخُلُوا مَسَاكِنَ الَّذِينَ ظَلَمُوا أَنْفُسَهُمْ إِلاَّ أَنْ تَكُونُوا بَاكِينَ حَذَرًا أَنْ يُصِيبَكُمْ مِثْلُ مَا أَصَابَهُمْ
lā tadkhulūā masākina adh-dhīna ẓalamūā anfusahum illā an takūnūā bākīna ḥadharan an yuṣībakum mithlu mā aṣābahum
Transliteration generated from the Arabic vowel marks
The full narration
Ibn Shihab reported, and he had been talking about the stony abodes of Thamud, and he said:Salim b. 'Abdullah reported that 'Abdullah b. Umar said: We were passing along with Allah's Messenger (ﷺ) through the habitations of Hijr, and Allah's Messenger (ﷺ) said: Do not enter but weepingly the habitations of these persons who committed tyranny among themselves, lest the same calamity should fall upon you as it fell upon them. He then urged his mount to proceed quickly and pass through that valley hurriedly
Source
Ṣaḥīḥ Muslim · 7465