We have developed a new method based on two cavities containing $chi^{(2)}$ media to reshape optical pulses by an all-optical technique. The system is entirely passive emph{i.e.}, all the energy is brought by the incoming pulse and uses two successive optical cavities with independent thresholds. The output pulse is close to a rectangular shape. We show that this technique could be extended to high bit rates and telecommunication wavelength using very small cavities containing current nonlinear materials.