If you know for certain the router has been hacked, it would be far simpler to reset the router. Also, if it is the router, then doing anything to the Mac, no matter what, won't help in the least.
It's a given that if a hacker has already gotten into your router, they also know admin name and password to get at all of rest of the configuration pages. Your main goal here is to keep them from getting back into your router once you've reset it.
Poorly configured routers (and there's a LOT of them) come with admin as the admin name, and no password (or visa versa, a blank admin name and "admin" as the password). This makes access much too easy for anyone who's taken the time to look up the default name and password for various makes and models of routers. Another thing that makes access easier are poor default settings in the router itself.
The following looks like a lot, but doesn't really take all that long to do. Less than 30 minutes.
The very first step with the router is to reset it to the factory defaults. This is usually accomplished by holding in a small, recessed button for about 10 seconds. When released, the router will reboot. Check your router's manual as different routers have different methods. For some, you turn the router off first (or unplug it if it has no power button), then hold the reset button in.
The reason for resetting the router to its defaults is the crooks may have bridged it to another router, or added other redirecting commands. That means even with new passwords (we'll get to that), they could still enter your network, or at least continue to watch what you're doing.
After the reset, the router will boot back up to the defaults. Open your browser and type in 192.168.0.1 as the address. This is the default IP address for nearly all routers. You should be prompted to enter the default admin name and password. Check the manual to see what these are. On newer routers, it's usually on a sticker on the router itself.
It's not enough to have the router on WPA2 or WPA3 if a crook can otherwise easily access it without even entering your home. Many router manufacturers have finally woken up and made the login name and password difficult to guess, but others still don't seem to get it. My oldest brother just got a new router/modem for his Internet connection, and it stupidly came with blank for the admin name, and "admin" as the password.
This is bad! All anyone within range or your router needs to do is type 192.168.0.1 into a web browser and see what responds. If it's your router, and if it has this same kind of useless login credentials, they can easily get into the router's settings and see your wireless password. From there, they can ride on your Internet account and see much of what you do. Including (if they have the skills), see what your devices are doing since they are now on the same side of the router's firewall as you are. And as your hackers did, add redirecting entries.
Once logged in to the router, open its setting pages. Go into wireless security, disable all wireless broadcasting and save the settings. You must do this first. Doing so will instantly kick anyone off of your network who shouldn't be there, and will prevent them from seeing what you're going to do next. Resetting the router will have already broken their connection, but you also want to make it difficult for them to get back in.