Worldwide abatement of untreated sewage discharge into surface water is a challenging task. Sewage discharging into surface waters has a detrimental impact on water quality. This paper presents a MATLAB (R2018b) framework designed to identify sewage flow discharges into rivers from an inverse problem-solving perspective. The computational tool integrates a hydrodynamic model using the Hydrologic Engineering Center’s River Analysis System (HEC-RAS 5.0.0) and an open-source toolbox for Differential Evolution Adaptive Metropolis (DREAM) as the inverse problem method. The proposed framework can effectively infer discharge sources in scenarios of highly transient flow based on hydraulic data at pre-set monitoring sites. To validate its capabilities, one hypothetical case and two real cases of sewage flow discharges entering a river were used to test the developed modeling framework. The results based on three performance metrics showed that this mathematical tool can be extended to simulate complex hydrodynamic flow patterns. This accomplishment underscores its potential as a valuable asset for environmental monitoring and water quality restoration efforts.