Fine, I'll go into details, since others don't seem to want to.
Han uses tarot cards, and sees that he's in deep shit.
He uses his prep to make golems, magic stones, and statamps prior to the battle starting.
He goes in an ID with time dilatation, giving him 70 days prep instead of a week (X30 time dilatation seemingly got retconned).
Puts golems around the battleground.
He hides, and his stealth is good enough to get around Madara's enhanced senses (and extraordinary ones too, obviously. Sage mode is no more impressive than Kwon's, and by extention Yoohwa's, enhanced senses).
Han's golems are oblitarated by limbo, Infinite Tsukuyomi is activated (Han resists) and Madara likely stops worrying since he has no idea Han is around.
Han checks his resistances and either space crushes him (which he might regen from, admittedly), mindhaxes (because of the whole downgrade of Naruto mindhax by kep) or maybe even manages to get of the slave spell.
Aadmittedly, Han might not start with stealth (tough that is unlikely), but Madara likely wouldn't worry much about him if he'd feel how weak Han is. Heck, he might even leave him to be chakra sucked by the tree or just leave him in IT, not that either would work.