Sorry you got hacked. Several things can be done to make it harder for an internet based address to attack your router. Here are a few suggestions:
1) Of course if you don't need remote access, simply firewall any access from your internet port in the input chain completely.
2) If you do need remote access, determine what services you REALLY need from the internet, and permit only those.
3) Use non-standard ports for services that you really need.
4) If you only need remote access from a very few specific IP addresses, only allow those addresses. For example, most of the time I remote into mine is from work on a specific IP address. Limit access to only that address or addresses.
5) Use of port knocking adds another layer to making it harder for someone to get in. Change the ports from time to time. For example, I have a different Port Knock setup if I'm coming from the one allowed work address vs from any other IP on the internet. If I have to use the "from the internet" Port Knock procedure, I change the ports so even if someone captured what I was doing, it would not work for someone else later.
6) Use only secure formats for your remote access which makes it harder for a man in the middle attack to steal credentials. For example, I generally use WinBox - make sure the "Secure Mode" checkbox is selected.
7) Have a firewall rule that will detect and drop port scanner attempts. Have that log any drops.
Use complex passwords, and change them from time to time.
9) Don't use "standard" user account names for administrator access. Although this is not router related, but it amazes me how many attempts I see in my mail server logs for attempts to send mail via my mail server using accounts of: admin, administrator, MailAdmin, Mailadministrator, SuperUser, SU, PostMaster, and a few others. Guess what - none of those accounts exist.
None of these steps makes it impossible for someone to get in, but each one make it a little harder
After you have the various security layers operational, a couple more steps.
1) Check the logs regularly and look for anything that does not look right.
2) From a remote location, test your firewall with a port scanner and make SURE that every open port is accounted for. I use NMap and scan the most common 1000 ports, and after I'm satisfied with those results, then I scan all 65K ports. Make sure ANY port that is reported can be accounted for. There are also some websites that can do a port scan (but I've never used one so I can't recommend any). BTW, if you have a firewall rule set to detect and drop port scanners, you should disable that rule set prior to attempting an external port scan. Leaving a port scanner rule set turned on while you are running a port scan will give you some interesting results because you will end up with ports that should have been open not showing up because the port scanner rule set dropped it. Yes, that's how I learned that one. It did verify that the port scanner rule set worked however so it's not a bad idea to try a scan once with the port scanner rule set turned on just to make sure that works the way you want it to. REMEMBER to turn your port scanner rule set back on after your port scan attempt!
3) Next step I did is that I set up a script that sends me an E-Mail any time anyone logs in or out of the router. That way I will at least know that someone got in. I got the script from the Scripting section here on the forum (I think).
4) Make sure you have a backup of the router configuration, so if you really have to take the last resort and factory restore the router, you can restore your configuration easily. In my case I have the router create both a backup and script file every night. It then sends both of those files to me via E-Mail. That means that I have every night's backup files saved both on my primary PC as E-Mail attachments, and also in the Sent Mail folder on the cloud based E-Mail account that the router uses to send the E-Mail.