Before applying Gauss' law it's usually helpful to take note of the symmetries of the problem. In the case of an infinite sheet of charge, there is a symmetry of rotation about the z axis (where the sheet is in the xy plane). This means the electric field can only have a z component. There is also a symmetry of translation in the xy directions, so the magnitude of the field can only depend on z (let me know if you're not familiar with these kinds of arguments). Finally, there is a symmetry of reflection through the plane, so the field at z is the reflection of the field at -z.
So we take the pillbox to straddle the sheet, and so that its faces are parallel to the xy,yz, and xz planes. Then the vertical faces have no flux, since the field is perpendicular to them, and the flux of the two horizontal faces is just equal to their area times the field at a point on the face, since the field is constant across the face. This allows you to solve for the field.
For the shell, you do have to pass through the shell when calculating the potential, but because the field is doesn't blow up, the contribution to the line integral from just around the shell is negligible, and doesn't affect the calculation. This is just an example of the integral of a non-continuous function (such as f(x)=-1, x<0, f(x)=1, x>0) being a continuous function (in this case, |x|, which is true regardless of what you set f(0) to be).