This question already has an answer here:
In Chamber of Secrets, how did Dumbledore know Harry and Ron were there?
‘However,’ said Dumbledore, speaking very slowly and clearly, so that none of them could miss a word, ‘you will find that I will only truly have left this school when none here are loyal to me. You will also find that help will always be given at Hogwarts to those who ask for it.’
For a second, Harry was almost sure Dumbledore’s eyes flickered towards the corner where he and Ron stood hidden.
Chamber of Secrets - page 195 - Bloomsbury - chapter fourteen, Cornelius Fudge