Mishkat al-Masabih 4613
Jabir reported God’s messenger as saying:
"When one of you sees a vision which he dislikes he must spit on his left three times, seek refuge in God from the devil three times, and turn from the side on which he was lying."

Muslim transmitted it.
وَعَنْ جَابِرٍ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِذَا رَأَى أَحَدُكُمُ الرُّؤْيَا يَكْرَهُهَا فَلْيَبْصُقْ عَنْ يَسَارِهِ ثَلَاثًا وَلْيَسْتَعِذْ بِاللَّهِ مِنَ الشَّيْطَانِ ثَلَاثًا وَلْيَتَحَوَّلْ عَنْ جَنْبِهِ الَّذِي كانَ عَلَيْهِ» . رَوَاهُ مُسلم