Where did the poem blackwood recited in prison in Sherlock Holmes come from?

And I saw a beast coming up from the sea, with ten horns and seven heads, and ten crowns on its horns, and blasphemous names on its heads. The beast I saw was shaped like a leopard, with feet like those of a bear and a mouth like the mouth of a lion. The dragon gave it strength, seat and great authority. I saw that one of the seven heads of the beast seemed to be killed or injured, but it was all right. All the people of the whole earth followed the beast in amazement and worshipped the dragon, because it gave the beast its authority and worshipped it, saying, "Who can compete with this beast? Who can compete with it? "He was given a mouth to speak exaggerated and blasphemous words, and he was given the authority to do whatever he wanted within forty-two months. Then the beast opened his mouth and blasphemed God, his name, his tabernacle and those who lived in heaven. And let it confront the saints and win. He also gave it the power to conquer all ethnic groups, people, political parties and countries. Everyone who lives on the ground and whose name has not been recorded in the book of life of the slain lamb since the creation of the world should worship it. Anyone who has ears should listen: whoever takes a prisoner will be taken captive; He who kills with a sword will also be killed with a sword. This is the patience and confidence of a saint. I saw another beast coming up from the earth. He had two horns like a lamb, and he spoke like a dragon. Before the first beast, exercise all the authority of the first beast, and make the earth and those who live on it worship the first beast whose casualties have been healed. He did great wonders again, even before people, causing fire to fall from heaven to the earth. Because it gave it the right to do wonders in front of the beast, it puzzled people who lived on the ground and said, "Make an image of the beast that was still alive after being wounded by a knife." And power was given to it, so that the beast could breathe and speak, and everyone who did not worship the beast was killed. It also makes all people, big or small, rich or poor, free and slave, leave marks on their hands or foreheads. No one can buy or sell animals except those who know their names or numbers. There is wisdom here. Anyone who has understanding can count the number of beasts, because this is the number of people, and its number is 666.

Revelation from the Bible.