Did you get title insurance if so contact them, if you can get permits your own legal recourse is cost of permits.
Did you put money into escrow?
Are you planning to rent it out? If so why do you care abuot this
I believe this also should have been picked up but your attorney, however only the most vigilant real estate attorneys would probably even know this. If you used someone who was a friend or relative, or picked the attorney who was the least expensive, my guess is they would not have.
The listing realtor is supposed to check with the City to make sure the house was a legal 2 family before listing it as a 2 family. A complaint should be filed with MLS and NYS (realtors are licensed by the state).
Your CO is probably fraudalent since the City never gives it out unless everything was done right. You also have a claim against the person who gave you the CO.