If this a proper ndk application - ie, a native library attached to a
java program - you can't really run it as root.

If you've abused the ndk's gcc to make a standalone executable, then
launching it from a root context such as the adb shell on an unsecured
device or whatever "su" type capability is found on a rooted community
rom on a phone should do the trick.

Note that this probably isn't going to get you traffic not already
going to/from the device.  Putting the wifi chip in promiscuous mode
is something yet else.

If you interest stops with the emulator, it's probably easier to do
your sniffing on the host machine.  Certainly more convenient to log
and display output there!  It might even be easier to use a linux box
or linux-based router (DDWRT, etc) to do wifi logging than shoehorn it
into the phone.

On Oct 29, 10:49 am, Samy <mails.s...@gmail.com> wrote:
> I am creating a raw socket to sniff packets on android as below.
>
>         sock_raw = socket(AF_INET , SOCK_RAW , IPPROTO_TCP);
>         if(sock_raw < 0)
>         {
>                 fprintf(fs,"Socket Error : %d %d\n",errno, EACCES);
>                 if( errno == EACCES )
>                     fprintf(fs,"PERMISSIN DENIED\n");
>                 return 1;
>         }
>
> When I run the code on emulator, socket functions returns -1 and errno
> has value 1 which means "Operation not permitted". But the same code
> runs fine on Ubuntu 10 under sudo.
>
> By default, I have root access in emulator using adb shell. Also, My
> App has below permissions
>     <uses-permission android:name="android.permission.INTERNET" /
>
>     <uses-permission
> android:name="android.permission.ACCESS_NETWORK_STATE" />
>     <uses-permission
> android:name="android.permission.ACCESS_WIFI_STATE"/>
>
> Can anyone help me to rectify this problem?
> By the way, how to run an application in emulator under root?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to