Yea, that's ugly. When it's reroof time, your roofer can patch that in with little effort. Take a picture of that mess, and some measurements to a local HVAC contractor that does their own ductwork fabrication. They can quickly make you a galvanized box, of sorts, that you can slide over the top and secure with a few sheet metal screws. Good luck.
If you are reroofing soon, and don't have aesthetic concerns, you can also take a pair of tin snips and cut the side off of that flashing. Bang any loose edges flat, then just take a sheet metal patch, roughly 16" x 16" slide it up under the shingles above, cover the hole, and put a roofing nail through the two lower corners of the patch. Seal with some roof tar or silicone. Might look like shit on a white horse, as my old cowboy buddy would say, but it won't leak, and outlast the roof.