We present a novel algorithm for determining the fundamental modes and cutoff wavenumbers in metallic waveguides with arbitrary cross-section, possibly loaded with inhomogencous dielectrics. The method is based upon a generalized Donsker-Kač formula which leads to a closed-form expression for the sought quantities in terms of asymptotic generalized Wiener-Ito integrals. These path integrals arc computed by means of Monte Carlo methods, leading to a completely parallel algorithm with mild memory requirements. The method can be easily generalized to 3D problems including electromagnetic resonators.