Lawyer defending criminals in court

Q: I am a lawyer by profession. I represent people who are being prosecuted for criminal charges and defend them in court.

In many instances, the accused party confesses to me that they are guilty of the crime for which they are being charged, even though they plead 'not guilty' to the court. In such situations, is it permissible for me to defend the accused in court, knowing that I am defending a guilty person who is lying to the court?