Being "foreclosed on Monday" isn't specific enough information to know exactly what is going-on. Do a google search for the property address and "foreclosure notice"; try to find a newspaper notice published with the sheriff's sale auction date.
Starting from the first missed mortgage payment, the bank can start the foreclosure process. The main step important to you is that the sheriff's sale is scheduled 6 months in the future. You can purchase the home at the sheriff's sale auction by out-bidding (the bank).
After the sheriff's sale, the tenant still has six months (maybe this was changed recently to 1-year) period. They have this amount of time to live in the home and bring the mortgage to current. Otherwise you can have the sheriff evict them. (The tenant can also waive some rights and leave earlier.) I believe this is the point where you take possession. Note, your money will have been tied-up this entire time without having access to the home.
Look-up "redemption period" to confirm some of these statements. I may not have all the lingo and current law correct.
If/when you take possession, the banks won't (can't) cash-out refi for six months after you take title.
Even if the home is in the foreclosure process, the best solution might be to buy the home from the bank as a Short-sale. The existing tenant can't be included on that deal; it would just be you and the bank.