Mishkat al-Masabih 4567
‘Ali said:
When God’s messenger was praying one night he placed his hand on the ground and was stung by a scorpion, so he struck it with his sandal and killed it. Then when he departed he said:
“God curse the scorpion! It does not leave alone one who is praying or anyone else, or a prophet or anyone else.” 
He then called for salt and water, and putting it in a vessel he began to pour it over his finger where it had stung him and wipe it, seeking refuge in God by reciting the Mu’awwidhatan . 

Baihaqi transmitted the two traditions in Shu’ab al-iman .
وَعَن عَليّ قَالَ: بَيْنَا رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ ذَاتَ لَيْلَةٍ يُصَلِّي فَوَضَعَ يَدَهُ عَلَى الْأَرْضِ فَلَدَغَتْهُ عَقْرَبٌ فَنَاوَلَهَا رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ بِنَعْلِهِ فَقَتَلَهَا فَلَمَّا انْصَرَفَ قَالَ: «لَعَنَ اللَّهُ الْعَقْرَبَ مَا تَدَعُ مُصَلِّيًا وَلَا غَيْرَهُ أَوْ نَبِيًّا وَغَيْرَهُ» ثُمَّ دَعَا بملحٍ وماءٍ فَجعله فِي إِناءٍ ثمَّ جَعَلَ يَصُبُّهُ عَلَى أُصْبُعِهِ حَيْثُ لَدَغَتْهُ وَيَمْسَحُهَا وَيُعَوِّذُهَا بِالْمُعَوِّذَتَيْنِ. رَوَاهُمَا الْبَيْهَقِيُّ فِي شُعَبِ الْإِيمَانِ