Boucher hit 40 not out as South Africa made 183 all out, a lead of 26, on a pitch which has helped both pace and spin bowlers.
Pakistan were 22 for one in their second innings at lunch on Saturday.
South Africa, resuming on 131 for five, were soon in trouble when Ashwell Prince was given out in the third over with only two runs added.
Prince was beaten by a Danish Kaneria googly and it seemed that wicketkeeper Kamran Akmal had missed his second stumping chance against the left-hander.
The ball bounced off Akmal's gloves and Yasir Hameed dived forward from silly point to catch it. Umpire Steve Bucknor gave Prince out caught to the batsman's undisguised surprise. Replays suggested Prince had missed the ball.
Two balls later nightwatchman Paul Harris edged Mohammad Asif to Younis Khan at second slip and South Africa had lost two wickets for two runs.
Andrew Hall was quickly caught behind off Kaneria for four but Dale Steyn stayed with Boucher long enough for 43 runs to be added for the ninth wicket.
Boucher went on the attack after a quiet start in which only 18 runs were scored off the first 11 overs, hitting three fours, a two and a straight six in an over from Asif which cost 22 runs. The over included two no-balls.
Boucher slammed Kaneria over midwicket for six in the next over but the partnership was ended when Boucher tried to steal a single off the fifth ball of an over from Mohammad Sami, who replaced Asif.
Boucher dabbed the ball towards third man but Younis Khan chased it from slip and hit the stumps at the batsman's end to run out Steyn.
Boucher did not get a chance to face again because last man Makhaya Ntini was out first ball, leg before to Sami.
Boucher made his runs off 36 balls with five fours and two sixes.
Kaneria, bowling into a large bare area at the Wynberg end, took three for 44 and Asif three for 53.
Mohammad Hafeez did not look comfortable at the start of Pakistan's second innings but just when it seemed he was settling down, hitting two fours off Steyn, he sliced a catch to backward point off Steyn to be out for 10.
Pakistan 157 and 22 for 1( Farhat 11 n o; Steyn 1 for 16) Vs South Africa 183 (Graeme Smith 64, Boucher 40 n o, Kallis 28; Mohd Asif 3 for 53, Kaneria 3 for 44, Mohd Sami 2 for 41)