Disclaimer: I don't know the answer. But I know how I would figure it out. One problem you have is that you have to know relatively how far away the box and the object are. Otherwise the box could be twice as big and twice as far away and the picture would look exactly the same (I'm discounting DoF effects.)
You're trying to back out 3-dimensional data from a 2-dimensional projection, which is ordinarily impossible. Fortunately, you have the extra information that the box is rectangular. I'd use a symbolic manipulator (Mathematica, Maple, or their ilk) and work out the formulas for the projection of the corners of an arbitrarily rotated box. Yes, this is doable by hand, but I've gotten lazy and computers are powerful. Then solve for the original box dimensions given the positions of the visible corners in your photograph. There will be a single undetermined scale factor that you'll have to get from the object (see the paragraph above), but that's the easy part.
Good luck, and have fun!
Matt