Our Lady in Medjugorje tells you how to overcome bad thoughts

Message dated February 27, 1985
When you feel weakness in your prayer, you do not stop but continue to pray wholeheartedly. And do not listen to the body, but gather yourself completely in your spirit. Pray with even greater force so that your body does not overcome the spirit and your prayer is not empty. All of you who feel weak in prayer, pray with greater ardor, fight and meditate on what you pray for. Do not let any thought deceive you in prayer. Remove all thoughts, except those that unite me and Jesus with you. Drive away the other thoughts with which Satan wants to deceive you and take you away from me.
Some passages from the Bible that can help us understand this message.
Tobias 12,8-12
Good thing is prayer with fasting and almsgiving with justice. Better the little with justice than wealth with injustice. It is better to give alms than to put aside gold. Begging saves from death and purifies from all sin. Those who give alms will enjoy long life. Those who commit sin and injustice are enemies of their lives. I want to show you the whole truth, without hiding anything: I have already taught you that it is good to hide the king's secret, while it is glorious to reveal the works of God. Know therefore that, when you and Sara were in prayer, I would present the witness of your prayer before the glory of the Lord. So even when you buried the dead.
Genesis 3,1-24
The snake was the most cunning of all the wild beasts made by the Lord God. He said to the woman: "Is it true that God said: You must not eat of any tree in the garden?". The woman replied to the snake: "Of the fruits of the trees in the garden we can eat, but of the fruit of the tree that stands in the middle of the garden God said: You must not eat and touch it, otherwise you will die." But the snake said to the woman: “You will not die at all! Indeed, God knows that when you eat them, your eyes would open and you would become like God, knowing the good and the bad ". Then the woman saw that the tree was good to eat, pleasing to the eye and desirable to acquire wisdom; she took some fruit and ate it, then also gave it to her husband, who was with her, and he also ate it. Then both of them opened their eyes and realized they were naked; they braided fig leaves and made themselves belts. Then they heard the Lord God walking in the garden in the breeze of the day and the man and his wife hid from the Lord God in the middle of the trees in the garden. But the Lord God called the man and said to him, "Where are you?". He replied: "I heard your step in the garden: I was afraid, because I am naked, and I hid myself." He went on: “Who let you know you were naked? Have you eaten from the tree of which I commanded you not to eat? ". The man replied: "The woman you placed beside me gave me a tree and I ate it." The Lord God said to the woman, "What have you done?". The woman replied: "The snake has deceived me and I have eaten."

Then the Lord God said to the serpent: “Since you have done this, be you cursed more than all the cattle and more than all the wild beasts; on your belly you will walk and dust you will eat for all the days of your life. I will put enmity between you and the woman, between your lineage and her lineage: this will crush your head and you will undermine her heel ". To the woman she said: “I will multiply your pains and your pregnancies, with pain you will give birth to children. Your instinct will be towards your husband, but he will dominate you. " To the man he said: “For you have listened to your wife's voice and have eaten from the tree, of which I had commanded you: You must not eat from it, damn the ground because of you! With pain you will draw food for all the days of your life. Thorns and thistles will produce for you and you will eat the field grass. With the sweat of your face you will eat bread; until you return to the earth, because you were taken from it: dust you are and to dust you will return! ". The man called his wife Eve, because she was the mother of all living things. The Lord God made man's robes of skins and dressed them. The Lord God then said: “Behold man has become like one of us, for the knowledge of good and evil. Now, let him no longer stretch out his hand and do not even take the tree of life, eat it and always live! ". The Lord God chased him from the garden of Eden, to work the soil from where it was taken. He drove the man away and placed the cherubim and the flame of the dazzling sword to the east of the garden of Eden, to guard the way to the tree of life.