Abu Hurairah reported,

The Messenger of Allah ﷺ said, "When the call to prayer is made, Satan turns and flees, passing wind so that he does not hear the call. When the muezzin falls silent, he returns. When the iqamah is pronounced, he flees again, and when it ends, he comes back. He keeps whispering to a man, telling him to remember things he had not been thinking about, until the man no longer knows how much he has prayed."Abu Salama bin Abdul-Rahman said, "When this happens to one of you, let him perform two prostrations while seated."Abu Salama heard this from Abu Hurairah رضي الله عنه.

Bukhari 1222

Sahih

حدثنا يحيى بن بكير حدثنا الليث عن جعفر عن الأعرج قال قال

أبو هريرة رضي الله عنه قال

رسول الله ﷺ إذا أذن بالصلاة أدبر الشيطان له ضراط حتى لا يسمع التأذين فإذا سكت المؤذن أقبل فإذا ثوب أدبر فإذا سكت أقبل فلا يزال بالمرء يقول له اذكر ما لم يكن يذكر حتى لا يدري كم صلى قال أبو سلمة بن عبد الرحمن إذا فعل أحدكم ذلك فليسجد سجدتين وهو قاعد وسمعه أبو سلمة من أبي هريرة رضي الله عنه

البخاري 1222صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Work during prayer
Chapter
A man thinking about something during prayer
Numbering
Darussalam 1222
Bukhari 1222