Generally, whoever owns the property gets the income. Your question, however, does need to be directed to an attorney.
The moment it goes to foreclosure ownership transfers and therefore the right to the income transfers. I do know,however, that in Virginia a lease supercedes a sale but not a foreclosure. Therefore, before recent federal legislation technically when a residential property was foreclosed, the tenant no longer had rights to the property and the owner no longer had rights to the rent. If an owner accepted rent, he was creating a lease. By not accepting rent he could exercise his rights to possession of the property and easily have the tenants removed. Recent federal legislation trumps the state law and now there are laws to protect the tenants in those cases. But this is all residential. Commercial could be different, especially considering the federal laws were specifically for residential properties. So if state law does not differentiate, then it could be true that there is simply no lease in place from a legal standpoint and a new one needs to be negotiated. In the meantime, the owner has legal right to posession and the tenant has no obligation to pay rent. If the owner accepts the rent, a lease is likely being created by this act.
Did I help or confuse you more? Sorry.