Hadithcore
Mishkat al-Masabih, 3125

Al-Hasan told in <i>mursal</i> form that he heard God’s Messenger had said, “God curse the one who looks and the one who is looked at!” Baihaqi transmitted it in <i>Shu'ab al-iman</i>.

وَعَنِ الْحَسَنِ مُرْسَلًا قَالَ: بَلَغَنِي أَنَّ رَسُولَ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ: «لَعَنَ اللَّهُ النَّاظِرَ وَالْمَنْظُورَ إِلَيْهِ» . رَوَاهُ الْبَيْهَقِيُّ فِي شُعَبِ الْإِيمَانِ

References1 variant
In-Book Reference
Book 13, Hadith 46