Root access permission on apk

443 views
Skip to first unread message

Leon A

unread,
Oct 16, 2013, 5:46:02 AM10/16/13
to kivy-...@googlegroups.com
Im developing a tool but it uses Scapy and requires to be run as root.
I cant find any docs that tell me what the permission must be set to when building the APK.

Obviously the device the APK is installed on must be rooted first of all, which my test device is but what is the permission i must add?

If it even exists.

ZenCODE

unread,
Oct 16, 2013, 9:46:38 AM10/16/13
to kivy-...@googlegroups.com
Hi Leon

I doubt you can really do that from your app. It would pose quite a security risk which Android deliberately tries to avoid. 

That being said, it seems if you run as an Android service, you get root permissions? 


Good luck ;-)

Leon A

unread,
Oct 16, 2013, 12:56:41 PM10/16/13
to kivy-...@googlegroups.com
Thanks Zen will look into it.
I was also looking into maybe using an app like su root to launch my app, again don't know if that's possible yet.
Last ditch option would be to somehow recode my socket logic to not need root permissions.
.. Damn you restrictions and security!! :-)

Gabriel Pettier

unread,
Oct 16, 2013, 7:50:13 PM10/16/13
to kivy-...@googlegroups.com
http://stackoverflow.com/a/5436182

Apparently just call "su" to ask the user for permission to be root.
> --
> You received this message because you are subscribed to the Google Groups "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Leon A

unread,
Oct 17, 2013, 4:51:16 AM10/17/13
to kivy-...@googlegroups.com
Cool, so in code it would be something like?

from
subprocess import call call(["su"])
on start up
?

Once again sorry for the ignorance.
This is good news.

Gabriel Pettier

unread,
Oct 17, 2013, 6:04:41 AM10/17/13
to kivy-...@googlegroups.com
Yeah, i would try like this, :)

Leon A

unread,
Oct 17, 2013, 11:24:42 AM10/17/13
to kivy-...@googlegroups.com
Ok :) , let you know how it goes.

Leon A

unread,
Oct 17, 2013, 3:36:09 PM10/17/13
to kivy-...@googlegroups.com
call(['su'])     does indeed grant kivy launcher root! :) , alongside supersu app

unfortunately as soon as the scan button is pressed the program closes :( , maybe if i call su with the arp request it would work? ... watch this space.
Cant figure this out.
It sounds like the app itself has root access but the scan function still executes as a normal user.

ZenCODE

unread,
Oct 17, 2013, 4:55:54 PM10/17/13
to kivy-...@googlegroups.com
That's good progress! Try looking at your logs to see what the errors are. They are usually very complete and accurate....:-)

Leon A

unread,
Oct 17, 2013, 5:05:35 PM10/17/13
to kivy-...@googlegroups.com
Yep i would if i could find them on my Nexus, ive been trying for 30 minutes! :D

Leon A

unread,
Oct 17, 2013, 5:26:06 PM10/17/13
to kivy-...@googlegroups.com
My bad using adb logcat ;)

Leon A

unread,
Oct 18, 2013, 12:54:43 AM10/18/13
to kivy-...@googlegroups.com
Ive attached a log im hoping somebody can make sense of this, to me its like trying to read chinese.

What i'm doing is calling the send ARP packet with 'su' , the program runs as ive got a print statement telling me 'scanned host' which you can see in the log every so lines.


at the moment i'm just looping (i) through the range 0,15 and printing (i) to labels to not complicate things.
It works on ubuntu, but for some reason on the android device nothing gets printed to screen?
.... atleast the function no longer closes the program.
log.txt

Leon A

unread,
Oct 19, 2013, 7:20:35 AM10/19/13
to kivy-...@googlegroups.com
For anyone who has a similar problem in the future:
setcap CAP_NET_RAW=eip /usr/bin/python2.7 Works!!

the program runs on ubuntu without issuing sudo, but a security risk.

so just python main.py!

I have a feeling getting it to run on android will be harder since i cant even find the bin for the interpreter, to attempt to set the flag. Does setcap exist?, would it work?
But nearly there!

On Wednesday, October 16, 2013 12:46:02 PM UTC+3, Leon A wrote:

Leon A

unread,
Oct 19, 2013, 8:12:51 AM10/19/13
to kivy-...@googlegroups.com
Ok so i'm assuming Kivy Launcher uses /data/data/com.googlecode.pythonforandroid/files/python/bin to run?

can i even get setcap part of libcap2-bin on an android device
and then point it to the python binary and set CAP_NET_RAW? ..

obviously when i package into an APK i have a feeling its going to be a whole new spaghetti soup!

Any help?
Reply all
Reply to author
Forward
0 new messages