This question already has an answer here:
I am trying to draw a fractal in tikz that is not a 'common' one - so I'm a little stuck.
It is essentially the Sierpinski Casket but with a square instead of a triangle. Start with the (solid) unit square, remove the centre 9-th, and repeat with the remaining 8 squares. So you end up with 8^k squares of size 1/9^k.
Preferably the 'last' image will be of stage 5 or 6 but, if possible, a nice definable end stage would be great (like other fractals in LaTeX).