Harry and Hermione were able to get to the Shrieking Shack only because Crookshanks (Hermione's pet ginger cat) knew that prodding on the knot present on the bark of the tree would stop it from beating up people. How did Crookshanks know how to stop the Whomping Willow? Was he the pet of any of the Marauders, i.e, Moony, Wormtail, Padfoot and Prongs; or better known as Lupin, Peter, Sirius and James?
He could have found out from Sirius (as a dog) at Hogwarts.
Crookshanks was able to communicate with Sirius when Sirius was in Animagus form. Once he’d earned Crookshanks’s trust, Sirius was able to tell him what he wanted and get his help.
“He’s the most intelligent of his kind I’ve ever met. He recognised Peter for what he was straight away. And when he met me, he knew I was no dog. It was a while before he trusted me. Finally, I managed to communicate to him what I was after, and he’s been helping me …”
- Harry Potter and the Prisoner of Azkaban, Chapter 19 (The Servant of Lord Voldemort)
Sirius could then have also told him to poke the knot on the tree. Crookshanks wouldn’t have needed to know this before meeting Sirius, when Sirius could have simply told him.
Because the book says that the Sirius and Crookshanks communicate with each other (which is why Crookshanks tries to kill Peter Pettigrew while he's still a rat
I'm warning you Hermione! Keep that bloody beast of yours away from Scabbers or I'll turn it into a tea cozy! Hermione: It's a cat, Ronald! What do you expect? It's in his nature. Ron: A cat? Is that what they told you? It looks more like a pig with hair if you ask me. Hermione: That's rich, coming from the owner of that smelly old shoe brush. It's alright, Crookshanks. Just ignore the mean little boy
and so Sirius communicated with Crookshanks frequently, after Crookshanks tells him that Peter was the rat (Remember, Crookshanks was extreamly inteligent) with even Sirius saying
Sirius said, “Finally, I managed to communicate to him what I was after, and he’s been helping me…”, and, “The cat - Crookshanks, did you call him? - told me Peter had left blood on the sheets.”
While it is never stated how the two communicated, the evidence makes it clear that they did, making it extremely possible that Sirius explained how to gain acces to the Whomping Willow, so that if Crookshanks ever needed to chase Peter into it (remember, Sirius had 'recruited' Crooksanks to help capture Peter, even though Crookshanks was already trying too because he saw Peter as a threat to Hermione).