Protect from theft at flash level There are a lot of apps that could block your phone in case of theft, take picture of thief remotely and such, but in case of reset any of this security methods will be useless

So I was wondering if there is such thing but at a flash level, shielded from simple ereases? An advanced user only could bypass this settings by re flashing. But regular thief could still be detected.
Yes, that sort of protection is available for Samsung devices: LoJack Device Compatibility

Explanation of what LoJack does:


  LoJack will be embedded in the Galaxy S4's firmware layer, where it
  remains dormant until you awaken it with a monthly subscription that
  becomes your theft insurance. This firmware situation is key -- even
  if robbers wipe your phone to the factory settings, LoJack is still
  active, and unremovable. -- CNET Article


It's difficult to find technical explanations for this software, but from how I understand it, LoJack is installed as an invisible system app, but a copy of it is also kept in the BIOS (pre-bootloader), and is re-installed to any ROM that is flashed. The app is what sends location, signed-in accounts, pictures via standard cell/WiFi protocols. LoJack guarantees to find the thief within 30 days or they send you a new device.

As of late 2015, there is also another type of security introduced with Android Lollipop/Marshmallow called FRP, which forces you to sign in with the previous Google account when you flash a new ROM. But this is hardly a security feature since it has been bypassed, but it is still a good step forward for Android.