Two dihydropyrimidinone derivatives (DHPM) were synthesized via the multi-component reaction, the yield of the synthesis reached 90%, and their structures were proved by IR, 1H and 13C NMR spectroscopy. The identified molecules were used for studying the corrosion inhibition of XC48 carbon steel in 0.5 mol L−1 H2SO4 solution. The inhibitory potentials of these compounds were determined by electrochemical methods exploiting the potentiodynamic polarization curves (Tafel method) and electrochemical impedance spectroscopy. Surface phenomena have been illustrated by atomic force microscopy. The results obtained show that the synthesized molecules are effective inhibitors, whose efficiency corrosion inhibition depends on the architecture of their structure, and it is proportional to the concentrations; it exceeds 94% for one of these inhibitors. The adsorption of these compounds on the metal surface approached the Langmuir’s adsorption isotherm. Furthermore, the electronic properties obtained using density function theory are in a good consensus with the experimental efficiencies of inhibition. The molecular dynamics simulations have allowed also simulating the interactions between the inhibitors and the metallic surface.