Valmiki Ramayana Sundara Kanda Sarga 48 Shloka 40
Original Shlokaतत स्स्वायम्बुवैर्मन्त्रैर्ब्रह्मास्त्रमभिमन्त्रितम्। हनुमांश्चिन्तयामास वरदानं पितामहात्।।5.48.40।।
1 source checked for this shloka
ततः then, हनुमान् Hanuman, स्वायंभुवैः by Brahma the creator, मन्त्रै mantra, अभिमन्त्रितम् appiled mantra, ब्रह्मास्त्रम् Brahmastram, पितामहात् grand sire, वरदानम् boon, चिन्तयामास started thinking
Hanuman realised that it was by invoking creator Brahma and applying the mantra that he was caught by Brahmastram. On that occasion he started thinking of the boon given to him by Grandsire Brahma :