Bayern saw a lot of the ball in the opening 10 minutes but did not muster a real chance until the 16th, which they converted.
However, not long before the interval Hannover were back in it as Didier Ya Konan rifled in a volley.
As Hannover pressed for the leveller, Bayern struck again for the decisive goal and it was Muller again this time guiding a Shaqiri free kick into the net.
Franck Ribery extended his side's advantage with 10 minutes to play to secure Bayern's safe passage.
Elsewhere in the Cup, Schalke 04 beat Darmstadt 3-1, Freiburg edged out Stuttgart 2-1 and Union Berlin squeezed past Osnarbruck 1-0.