A homeless man confessed to fatally bludgeoning four sleeping vagrants and critically injuring a fifth during a bloody rampage through Chinatown, a prosecutor said in court on Sunday.

Randy Santos, 24, came clean when cops confronted him with evidence of the grisly attacks, Manhattan Assistant District Attorney Alfred Peterson said.

“While he was in the 5th Precinct, he was shown video of the attacks and he admitted that he was the person in the video,” Peterson said.

Randy Santos is arraigned in criminal court for the murder of four homeless men, Sunday, Oct. 6, 2019, in New York. (Rashid Umar Abbasi/New York Post via AP, Pool)

Randy Santos is arraigned in criminal court for the murder of four homeless men, Sunday, Oct. 6, 2019, in New York. (Rashid Umar Abbasi/New York Post via AP, Pool)

Peterson also revealed that the weapon Santos allegedly used – described by law enforcement sources as a 3-foot, 15-pound piece of construction metal – was “covered in blood and hair” when cops caught him carrying it over his shoulder.

Nabbing Santos likely prevented further carnage, because “the way he was walking, it looked like he was looking for more victims,” a source has said.

Read more from the New York Post.