Hope you used Malwarebytes for Mac to remove malware.
Go step by step and test.
1. Remove unknown profiles.
System Preferences > Profiles
Open System Preferences, click the “Profiles” icon ( a checkmark on a gear) .
When Profiles pane opens, select the unknown profile and click the minus button at the bottom.
2. Remove unknown Login item.
System Preferences > Users & Groups > Login items
Authenticate and unlock the lock.
Highlight the unknown login item and click the “-“ button at the bottom left to remove it.
3. Reset search engine: https://support.apple.com/guide/safari/customize-your-search-ibrwe75c2a3c/mac
Change Home Page
4. Reset Homepage. https://support.apple.com/guide/safari/set-your-homepage-ibrw1020/mac
Section: Check other browser settings.
5. Ref: https://forums.malwarebytes.com/topic/236261-how-to-remove-weknow-malware-and-others/
6. Shutdown the computer from menu. Start your Mac using the Power button.