The Prophet ﷺ said, "If someone peeps at you without permission and you throw a pebble at him and put out his eye, you bear no blame for it." On another occasion he said, "no sin."
أخبرنا محمد بن منصور قال حدثنا سفيان عن أبي الزناد عن الأعرج
عن النبي ﷺ قال لو أن امرأ اطلع عليك بغير إذن فخذفته ففقأت عينه ما كان عليك حرج وقال مرة أخرى جناح
Bukhari transmitted it in the Book of Blood Money, chapter, "Whoever peers into the house of a people and they gouge out his eye owes no blood money," no. 6902, and Muslim, in the Book of Manners, chapter on the prohibition of looking into another person's house, no. 44/2158, from the hadith of Sufyan Ibn Uyayna, with the same wording. It is also found in Al-Kubra, no. 7066.