Mailbox and gmail 2 factor authentication

I have 2 factor set up for my gmail and I was wondering would this save me from a hacker attack if the hacker got my password from attacking mailbox? Or would they hacker be able to log into my gmail by having the application specific code set up for mailbox?

And if there is a way to log down mailbox using 2 factor authentication and the above is not correct how should I set it up?