If you can still establish an online connection (even if you can't access the program), you can perform a factory reset. Online & Diagnostics for the CPU. Reset to factory settings Check the box

Reviewing the Siemens S7-1500 password reset process reveals it is designed as a high-security measure; there is no "backdoor"