luk1337 / ih8sn

331 stars 113 forks source link

Add circumvention of OnePlus' oem unlock counter by @osm0sis #8

Closed linuxct closed 2 years ago

linuxct commented 2 years ago

Adaptation for commit d2676e1@kdrag0n/safetynet-fix, authored by @osm0sis. Original commit message:

  • I recently discovered ro.is_ever_orange on OOS 11, which gets set roughly 32 seconds after boot completed and is equal to the number of times a device has ever been fastboot oem unlocked
  • a fresh MSM (i.e. factory locked device) has it set to 0, and using system.prop to set it to 0 earlier in the boot seems to keep it set to 0 instead of the real unlock count
  • I haven't seen this exploited anywhere, though I presume it exists for a reason, so probably good to manage it as well
luk1337 commented 2 years ago

Hmm, if it's set 32 seconds after boot completed, then does this code really override it?

osm0sis commented 2 years ago

As explained in the commit message, yes.

linuxct commented 2 years ago

Sorry for the late reply, I read the email but forgot to reply.

Hmm, if it's set 32 seconds after boot completed, then does this code really override it?

Just like @osm0sis added, indeed it won't override it. I only took into account the case where ih8sn is called after boot is completed, as part of the RC scripts, hence in most cases it should be earlier than the ~32 seconds needed for the property to be set.

Since this would not cover every use case (running ih8sn as an standalone binary), no need to merge it if you don't find it convenient.

osm0sis commented 2 years ago

No no, you guys misunderstand. Magisk's system.prop functionality gets set well before boot completed, but I found setting it that early actually does keep it at what you set.

using system.prop to set it to 0 earlier in the boot seems to keep it set to 0 instead of the real unlock count

So whatever is setting it in OOS seems to only set it if it doesn't already exist, and we can set it to 0 as early as we want. Your implementation should therefore work fine as well. 🙂