ولو وقفت إمرأةٌ في صف الكفار أو على حصنهم فشتمت المسلمين أو تكشّفت لهم جاز رميُها قصداً لما روى سعيد حدثنا حماد بن زيد عن أيوب عن عكرمة قال لما حاصر رسول الله ﷺ أهل الطائف أشرفت إمرأة فكشفت عن قُبلها فقالت هادونكم فارموا فرماها رجل من المسلمين فما أخطأ ذلك منها ويجوز النظر إلى فرجها للحاجة إلى رميِها لأن ذلك من ضرورة رميها وكذلك يجوز رميها إذا كانت تلتقِط لهم السهام أو تسقيهم الماء أو تحرِّضهم على القتال لأنها في حكم المقاتل وهكذا الحكم في الصبي والشيخ وسائر من مُنع من قتله منهم
المغني لإبن قدامة كتاب الجهاد
If a woman gets up amidst the ranks of the Disbelievers, or on top of their bulwark, and insults the Muslims or exposes herself to them, it is permissible to intentionally shoot at her, based on what Sa’id narrated: Hammad ibn Zayd related to us from Ayub, from ‘Ikrama, who said: When the Messenger of Allah (SAW) besieged the people of Ta’if, a woman got close, exposed her front parts, and said: Here you go, so shoot! And a man from among the Muslims shot at her, and did not miss that part of her. It is permissible, then, to look at a woman’s vagina if needed to shoot at her, since this is out of necessity for shooting at her. Similarly, it is permissible to shoot at a woman if she collects arrows for them, gives them drinking water, or urges them on to fight, since she falls under the ruling for fighters. The ruling similarly applies to children, the elderly, and any others of them who are normally prohibited to be killed.
Ibn Qudama, Al-mughni, The book of jihad