Mo Diame and Mark Noble were also on target in an entertaining contest and the Hammers gave themselves a welcome lift ahead of next week’s Premier League opener against Tottenham.
The hosts began brightly but then found themselves behind after 15 minutes when Stefan Okaka held off James Collins and shot past Adrian.
New boy Cheikhou Kouyate was impressive for the Hammers, who had a Carlton Cole goal disallowed for offside.
And the hosts levelled in first-half injury-time, Noble sending the goalkeeper the wrong way from the spot after Dan Potts was tripped in the box by Lorenzo De Silvestri.
However, the Italian visitors reclaimed the lead just after the hour-mark as Citadin Eder received from Roberto Soriano and then beat Adrian with a low shot.
But Diame (77) produced a moment of magic to bring West Ham level again, cutting inside from the right and beating a pair of defenders as he went, before finding the corner of the net.
West Ham pressed for a winner but Stuart Downing hit the crossbar and Potts put the rebound over the top.
And a penalty shoot-out appeared to be on the cards, only for the hosts to snatch it in the last minute, Elliot Lee doing really well to wait for his moment and then slip a perfect pass into the box, leaving Burke to side-foot the ball into the net from close range.