It is unlikely you will get back the rent you already paid. However, you can still be evicted in an unlawful detainer lawsuit.
You should argue to the court that under the case of Gruzen v. Henry (1978) 84 Cal.App.3d 515, the landlord is not entitled to collect or request any rent.
If the landlord tries to evict you, the landlord will likely get restitution of the premises (an order that you be removed from the illegal structure without owing rent) but not any money damages in an unlawful detainer judgment. The legal basis for such ruling is that the courts will not enforce any illegal contract.
In some cases, you may be able to sue to recover the rent you paid. However, not all judges will agree on whether a tenant in your situation is entitled to get back rent paid to the landlord.
Frank W. Chen has been licensed to practice law in California since 1988. The information presented here is general in nature and is not intended, nor should be construed, as legal advice for a particular case. This Avvo.com posting does not create any attorney-client relationship with the author. For specific advice about your particular situation, please consult with your own attorney.