Thawban reported,

The Messenger of Allah ﷺ said, "Three will fight one another at your treasure, each of them a son of a caliph, yet none of them will gain it. Then the black banners will appear from the direction of the east, and they will slaughter you with a slaughter unlike any people have ever inflicted."Then he mentioned something I do not remember, and said, "When you see him, pledge allegiance to him, even if you must crawl over the snow, for he is the Caliph of Allah, the Mahdi."

Ibn Majah 4084

Daif

حدثنا محمد بن يحيى وأحمد بن يوسف قالا حدثنا عبد الرزاق عن سفيان الثوري عن خالد الحذاء عن أبي قلابة عن أبي أسماء الرحبي

عن ثوبان قال

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

ابن ماجه 4084ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Tribulations
Chapter
Emergence of Mahdi
Numbering
Darussalam 4084
Ibn Majah 4084