Machshavos Zaros & The Thorn Bush
וַיֵּרָא מַלְאַךְ יְהוָה אֵלָיו, בְּלַבַּת-אֵשׁ- מִתּוֹךְ הַסְּנֶה; וַיַּרְא, וְהִנֵּה הַסְּנֶה בֹּעֵר בָּאֵשׁ, וְהַסְּנֶה, אֵינֶנּוּ אֻכָּל. וַיֹּאמֶר מֹשֶׁה-אָסֻרָה-נָּא וְאֶרְאֶה, אֶת-הַמַּרְאֶה הַגָּדֹל הַזֶּה: מַדּוּעַ, לֹא-יִבְעַר הַסְּנֶה. וַיַּרְא יְהוָה, כִּי סָר לִרְאוֹת; וַיִּקְרָא אֵלָיו אֱלֹהִים מִתּוֹךְ הַסְּנֶה, וַיֹּאמֶר מֹשֶׁה מֹשֶׁה-וַיֹּאמֶר הִנֵּנִי. וַיֹּאמֶר, אַל-תִּקְרַב הֲלֹם; שַׁל-נְעָלֶיךָ, מֵעַל רַגְלֶיךָ-כִּי הַמָּקוֹם אֲשֶׁר אַתָּה עוֹמֵד עָלָיו, אַדְמַת-קֹדֶשׁ הוּא. וַיֹּאמֶר, אָנֹכִי אֱלֹהֵי אָבִיךָ, אֱלֹהֵי אַבְרָהָם אֱלֹהֵי יִצְחָק, וֵאלֹהֵי יַעֲקֹב
An angel of Hashem appeared to him in a flame of fire from within the thorn bush, and behold, the thorn bush was burning with fire, but the thorn bush was not being consumed. So Moshe said, "Let me turn now and see this great spectacle why does the thorn bush not burn up?" Hashem saw that he had turned to see, and Hashem called to him from within the thorn bush, and He said, "Moshe, Moshe!" And he said, "Here I am!" And He said, "Do not draw near here. Take your sandals off your feet, because the place upon which you stand is holy soil." And He said, "I am the G-d of your father, the G-d of Avraham, the G-d of Yitzchok, and the G-d of Yaakov..." (Shemos 3:2-6)
Degel Machaneh Ephraim, Parshas Shemos:
Machshavos zaros (strange and evil thoughts) that come to a person in the midst of davening come in order that one may mend and raise up the holy sparks which are clothed in those thoughts. It is necessary to know how to elevate them and attach them to their root.
For example, if evil thoughts of illicit relations come to a person, chas v'shalom, he should understand that they are from the root of chesed which has fallen from above to the very lowest levels. One should raise them up and attach them to their root which is the supernal chesed. Similarly, if thoughts of any dread or external fears come, one should attach himself to the root which is the highest awe and root of all fear. Likewise, when any arrogance and boasting break into one's thoughts, he should join himself to the attribute of tiferes in which is the root of all boasting.
An illusion to this idea can be found the following verses in which a thorn bush refers to machshavos zaros that come to a person in the midst of davening:
An angel of Hashem appeared to him in a flame of fire from within the thorn bush: In the midst of his avoda with hislahavus (fiery enthusiasm) and great deveykus the machshavos zaros come to him.
So Moshe said, "Let me turn now...": I will clear my thoughts and turn aside every disturbing thing.
and see... why does the thorn bush not burn: It is perplexing to a person how could any machshavos zaros come close to him and try to stop him. For it should have been that all the klippos and machshavos zaros would have been burned and destroyed by the breath of his holy mouth and by his hislahavus and the strength of his deveykus.
Hashem saw that he had turned to see: Hashem immediately saw that he turned aside to look and yearned to know the truth of things. At once He became visible and was revealed to him out of those same machshavos zaros.
Hashem called to him from within the thorn bush: And he revealed this secret to him.
Take your sandals off your feet: Take care to turn aside your machshavos zaros and bring them to the sphere of goodness and attach them to their root.
the place upon which you stand is holy soil: You are the one standing on a holy level and your prayer is holy even when machshavos zaros come to you.
I am the G-d of your father: Because of the aspect of divinity which is in those desires and machshavos zaros, they come to you they are thrust upon you during davening. (אָבִיך your father) can also refer to teyva (desire), as in the piyut which reads ואבית תהלה You desire praise).
In this regard there are a number of levels:
the G-d of Avraham: Thoughts that come from the root of chesed.
the G-d of Yitzchok: Thoughts that come from the root of gevura.
and the G-d of Yaakov: Thoughts that come from the root of tiferes.
All of this occurs in order to elevate machshavos zaros to their root, and not to prevent you, chas v'shalom, from davening.
Excerpt from Understanding the Tanya by Rabbi Adin Steinsaltz:
It goes without saying that to engage in this discipline, one must be able to distinguish between these two components: in other words, to see the object of one's this-worldly desire as a mask behind which to find the true reality. For instance, a person who desires something of beauty must get beyond the object to the first source of beauty. He can then ask himself, Why should I chase something that is a little part, a dim copy, when I can chase and embrace the source of beauty and eternity, such as G-d himself.
One raises a "foreign thought" by delving into it to change its direction, objective, and purpose until it is utterly transformed.