When TeX decides it's time to eject a page (because one has been filled up or the user has issued a command to the same effect), it does some maintenance work and then packs the page's contents into the box register 255.
Next it calls the output routine, which is supposed to do several things: adding the header and the footer, incrementing the page number and so on.
The simplest output routine would be
\output{\shipout\box255}
which would do nothing to the page other than shipping it out. The standard output routine in Plain TeX is (in simplified form)
\output={\plainoutput}
\def\plainoutput{\shipout\vbox{\makeheadline\pagebody\makefootline}%
\advancepageno
\ifnum\outputpenalty>-20000 \else\dosupereject\fi}
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \pagecontents}}
\def\makeheadline{\vbox to 0pt{\vskip-22.5pt
\line{\vbox to8.5pt{}\the\headline}\vss}\nointerlineskip}
\def\makefootline{\baselineskip=24pt \lineskiplimit=0pt
\line{\the\footline}}
\def\dosupereject{\ifnum\insertpenalties>0 % something is being held over
\line{}\kern-\topskip\nobreak\vfill\supereject\fi}
\def\pagecontents{\ifvoid\topins\else\unvbox\topins\fi
\dimen@=\dp255 \unvbox255
\ifvoid\footins\else % footnote info is present
\vskip\skip\footins \footnoterule \unvbox\footins\fi
\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
\def\footnoterule{\kern-3pt
\hrule width 2truein \kern 2.6pt} % the \hrule is .4pt high
where the usage of \box255 is more complicated because it keeps track of insertions such as floating figures and footnotes; the \shipout operations is performed to another box which is in turn built using the contents of \box255.
(I'm not even trying and confront the LaTeX output routine, which is vastly more complicated than this one, but the sense of the thing is just the same.)
This box register is automatically managed by TeX and it's quite dangerous to make use of it (if your name isn't Heiko Oberdiek).
The package atbegshi does some trick by redefining \shipout, adding hooks to it so the contents of the box being shipped out can be tweaked in various ways.
The first set of macros doing something of this can be found in quire.tex, a remarkable piece of code that I believe is still usable even with LaTeX; but there are easier ways now to achieve the same effect.
% quire.tex: Macros for making booklets, printing double pages, and
% printing outlines and crop marks.
% version: 1.0 release: 19 January 1991
%
% copyright (c) 1991 Marcel R. van der Goot
that used a similar trick for producing quires, that is, sets of pages to be printed on the same sheet of paper and then cut and folded.
\box255.\box<number>is just a way to reference one of TeX box registers. TeX (at least the non-extended version) has only 256 box registers (0-255) and 255 is simply the last one. For some reason it is reserved for the output routine. – Martin Scharrer May 26 '12 at 17:29atbegshipackage "is a modern reimplementation of packageeveryshi" (sic) and uses\AtBeginShipoutBoxinstead of\box255. However it might use box #255 internally anyway. – Martin Scharrer May 26 '12 at 17:35:)Btw, would you mind putting your\box255comments as an answer? I think they are a perfectly acceptable explanation (unless a more in-depth answer shows up). Many thanks - cheers! – sdaau May 26 '12 at 17:40