In what was an even and keenly contested first-half, the National League North side proved a real test for Steve Cotterill's men.
And they were the better side for long spells in the second-half and deservedly took the lead through Miles Storey.
With around 10 minutes to go, though, Town upped the ante with Udoh seizing the initiative to grab the win for his side.
The striker first did well to send in a pinpoint cross which Whalley converted with a little help from a deflection.
And then just minutes later, Udoh won the game with a clever finish from inside the area.
In what was their second pre-season outing of the summer, Cotterill made two changes from the side that secured a 3-2 victory over AFC Telford United last Tuesday.
One of those changes allowed Town fans to get a first glimpse of Marko Marosi - with the shot-stopper getting the nod in goal ahead of Harry Burgoyne.
Sticking with their familar 3-5-2 formation, Matt Pennington, Ethan Ebanks-Landell and Luke Leahy continued at centre-back for Town with Nathanael Ogbeta and Elliott Bennett deployed as wing-backs.
In midfield, David Davis and Josh Vela sat centrally while Whalley was given licence to roam.
Up front, promising striker Tom Bloxham got his first start of pre-season alongside Ryan Bowman.
Aaron Pierre and Ollie Norburn continued to miss out due to being on international duty with Grenada.
In what proved to be a keenly contested first-half, Shrewsbury moved the ball around well in spells.
But Hereford were full of endeavour as they looked to show they were good enough to go toe-to-toe with their League One rivals.
Ten minutes in, though, and Town were hugely unfortunate not to be ahead when Bloxham picked up the ball 20-yards out before arrowing a strike into the bottom corner.
It really was a cracking hit from the teenager that gave goalkeeper Brandon Hall no chance.
But the linesman, somewhat harshly, judged the striker had received the ball in an offside position and raised his flag.
Salop continued to cause problems with Ogbeta hitting a cross-come-shot which Bowman turned towards goal.
His effort, though, was too close to Hall who made a comfortable stop.
Shrewsbury had looked in control but Hereford gradually began to grow in stature with wideman Ryan McLean particularly impressive.
The winger first beat Ebanks-Landell for pace before being cynically hacked down by the defender who deservedly picked up a yellow card.
Then just past the half-hour mark, McLean latched onto a long ball from Hall before entering the box and hitting a low drive which Marosi had to parry away.
And from that point on, the half continued to be fairly even with Hereford's aggression and desire comfortably keeping Shrewsbury at bay.
Town were dealt a major blow early in the second half when Bloxham collided with a defender before hitting the ground in some pain.
It was nothing more than a coming together, but the teenager was unable to carry on and was promptly replaced by Udoh.
Moments after his introduction, Udoh stung the palms of Hall with a fierce strike from 18-yards.
Suddenly, though, the hosts went up a gear.
They almost opened the scoring when former Walsall winger Maz Kouhyer whipped in a free-kick which Ryan Lloyd headed over.
But just before the hour mark they did get themselves ahead with Miles Storey firing in from 10-yards following a cross from the right.
Shrewsbury simply hadn't shown up for the second-half with Cotterill deciding to introduce Josh Daniels for Bennett with 15 minutes to go.
It was Hereford, though, who continued to be the brighter of the teams with Kouyar entering the box and hitting a fierce low drive which Marosi did really well to keep out.
Shrewsbury didn't deserve to be on terms but in the 81st minute they managed to drag themselves level.
Udoh did well to escape down the left and send in a cross.
And that was met by Whalley whose shot deflected off a defender before flying past the keeper.
Incredibly, three minutes later Town were ahead when Udoh produced a smart finish in the box to fire past a trialist who had taken over in the Hereford goal.
And once they were ahead, Salop saw out the game comfortably to register their second win of pre-season.
Hereford: Hall (Trialist 65), Hodgkiss, Bodenham (Trialist 78), Hancox, Vincent, Lloyd, Owen-Evans (Kouhyer 53), McLean (Trialist 58), Butlin (Trialist 59), Storey, Pollock (Raison 78).
Shrewsbury (3-5-2): Marosi, Ogbeta, Leahy, Ebanks-Landell, Pennington, Bennett (Daniels 73), Davis, Vela, Whalley, Bloxham (Udoh 50), Bowman (Pyke 84).
Not used: Burgoyne, Gregory.