buildozer
buildozer copied to clipboard
'Operation not permitted' runtime error
Versions
- Python: 3.8
- OS: Linux
- Buildozer: 1.4
Description
I'm trying to build an APK of a python script that sends ARP packets using scapy.
The application builds smoothly and runs on my device, until it gets to the point where it tries to send an ARP packet and then the following exception is thrown:
Operation not permitted
Notes:
- I tried giving the app root permissions (via MAGISK)
- Running the script locally from the terminal on the device works (
sudo python3 script.py
) - I have Nethunter installed so it's possible to do so
buildozer.spec
Command:
buildozer android debug deploy run logcat
Spec file (only the part that's not commented out):
[app]
title = DeadNet
package.name = com.deadnet
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
requirements = python3,kivy,scapy,netifaces
orientation = portrait
osx.python_version = 3
osx.kivy_version = 1.9.1
fullscreen = 0
# (list) Permissions
android.permissions = INTERNET,ACCESS_NETWORK_STATE,ACCESS_WIFI_STATE,
[buildozer]
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2
Logs
The build succeeds, I get the following Python exception during runtime though:
[OSError: [Error 1] Operation not permitted]
I am not sure if this is an issue with kivy-ios or buildozer, seems more like an issue with permissions on iOS. You may try getting network permissions on iOS at runtime. Altering packets may just be restricted altogether by apple.
@akshayaurora thanks for the reply! I'm trying to get permissions during runtime as well, by running the following command:
subprocess.run(["su"])
Here's the popup message that appears on my screen after running the aforementioned command, in which I choose to grant root access:
however, even after granting root access, this is the output I get when I run "id":
subprocess.run(["id"])
output:
uid=10281(u0_a281) gid=10281(u0_a281) groups=10281(u0_a281),3003(inet),9997(everybody),20281(u0_a281_cache),50281(all_a281),99909997(u999_everybody) context=u:r:untrusted_app_27:s0:c512,c768
which means I'm still not root.
Perhaps this has something to do with group permissions as well? is there any way to modify that in the buildozer.spec
file?
EDIT:
I've read somewhere that NET_ADMIN / NET_RAW
permissions are required for this...
I tried to set them in buildozer.spec and grant them during runtime using the following code:
import android
from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE, Permission.INTERNET, Permission.NET_ADMIN])
But unfortunately that gives me the following error:
AttributeError: type object 'Permission' has no attribute 'NET_ADMIN'