The way Chebhou showed is rather simple:
for each of the 8 bones conected to the box, ad a transform-constraint(constraint-tab in the properties-panel)
use location of the middlebone as input and the rotation on x or y as output
or try this:
parent 4 bones to the top one, each placed at the top of a wall.
for each wall: place the mid a bit outside of the box and add an ik-constraint to the upper bone;
with chainlength=2 and tail=True, the targetbone being the bone placed on top of each wall.
the green one on the top is what you move, the big ones are to deform the walls, the small gray ones are the targets. they are children of the green one on the top. the green one has a limit-location-constraint(seen on the right), the yellow ones each have an ik-konstraint to the little gray ones, with a chainlength of 2
