Issue
I'm running into an issue where Chromedriver will die immediately on launch after I've modified it to not be detected as a bot by websites.
To access my data on my bank website, I've built a java based tool which uses Selenium and Chromedriver. My bank is using some bot detection software, so if you just run the regular chromedriver, you'll get detected and it will throw up a generic error. On my older Intel Mac, to get around this, I would simply run this command and everything would work:
perl -pi -e 's/cdc_/dog_/g' `which chromedriver`
When I run this on my Apple Silicon Mac, chromedriver is killed immediately on launch
╭─ motopascyyy@mbp2022 ➜ ~
➜ perl -pi -e 's/cdc_/dog_/g' `which chromedriver`
╭─ motopascyyy@mbp2022 ➜ ~
➜ chromedriver
[1] 16612 killed chromedriver
If I revert the command with perl -pi -e 's/dog_/cdc_/g' /path/to/chromedriver
, it will start running again.
╭─ motopascyyy@mbp2022 ➜ ~
137 x perl -pi -e 's/dog_/cdc_/g' `which chromedriver`
╭─ motopascyyy@mbp2022 ➜ ~
➜ chromedriver
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Per a suggestion on a few different threads, I've changed the perl command to look for $cdc_
instead of $dog_
, and while chromedriver will still launch, the bot detection logic won't work.
I've done a diff between the chromedriver before and after it was modified, and see no major differences (both Intel and Appel Silicon look the same)
63464c63464
< var key = '$cdc_asdjflasutopfhvcZLmcfl_';
---
> var key = '$dog_asdjflasutopfhvcZLmcfl_';
63504c63504
< const Symbol = window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol || window.Symbol;
---
> const Symbol = window.dog_adoQpoasnfa76pfcZLmcfl_Symbol || window.Symbol;
63531c63531
< const Array = window.cdc_adoQpoasnfa76pfcZLmcfl_Array || window.Array;
---
> const Array = window.dog_adoQpoasnfa76pfcZLmcfl_Array || window.Array;
63688c63688
< const Promise = window.cdc_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
---
> const Promise = window.dog_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
63757c63757
< const Promise = window.cdc_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
---
> const Promise = window.dog_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
63829c63829
< const Promise = window.cdc_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
---
> const Promise = window.dog_adoQpoasnfa76pfcZLmcfl_Promise || window.Promise;
Has anyone else encountered a similar problem?
Edit 2022-05-09
I looked at the console and it seems like running the perl command modifies the package enough to make the code signature invalid. According to the console, the process is killed because of:
Exception Type: EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
It's unclear why this isn't a problem on the Intel machine.
Solution
Did some google-ing and can strip out the old signature and force an "ad-hoc" signature. Afterwards, the chromedriver is operational for personal use.
perl -pi -e 's/cdc_/dog_/g' /path/to/chromedriver
codesign --remove-signature /path/to/chromedriver
codesign --force --deep -s - /path/to/chromedriver
This modifies the executable, removes the signature, and adds a new signature. Below are the links where I gleaned those commands:
https://eclecticlight.co/2020/11/03/code-signatures-3-fixing-signature-problems/ https://www.purebasic.fr/english/viewtopic.php?t=78137
I was spinning around in circles after encountering the same problem on my recently purchased M1 today. I bought that M1 Powerbook to develop crawling jobs, so I was very frustrated. Thanks for making me aware of the M1 code signing requirements.
Answered By - brianj
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.