Using one-dimensional particle-in-cell simulations, the generation of attosecond pulses is studied due to the interaction of a short ultrarelativistic laser pulse with overdense plasma. According to the ultrarelativistic similarity theory, we analyze the motion of the electrons and the generation of high-order harmonics. We find that when the plasma density is constant and the dimensionless similarity parameter S decreases, the conversion efficiency of attosecond pulses first increases and then decreases. So we can choose a laser pulse with an appropriate intensity to obtain an attosecond pulse with a high conversion efficiency. Furthermore, when S is fixed, with the increase of the plasma density, the conversion efficiency of attosecond pulses shows an upward tendency. This implies that we can obtain a higher attosecond pulse when a laser with an appropriate intensity is incident on a denser plasma.