Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cannot read property 'apply' of undefined #181

Open
arya6000 opened this issue Apr 9, 2018 · 0 comments
Open

TypeError: cannot read property 'apply' of undefined #181

arya6000 opened this issue Apr 9, 2018 · 0 comments

Comments

@arya6000
Copy link

arya6000 commented Apr 9, 2018

Below is a very simple code that uses rpc.exports

import urllib.request
import os
import time
import frida
import sys
import threading
import traceback


jscode = """

'use strict';

rpc.exports = {
    begin: function (username, password) {
        setImmediate(main(username, password));
        console.log("inside")
    }
};


function main(username, password) {
    console.log("inside main")
}


"""


device = frida.get_usb_device()

package_name = 'com.myapp'
script = None

try:
    device.kill(package_name)
except:
    pass
try:
    os.system("adb shell pm clear " + package_name)
    app = [package_name]
    pid = device.spawn(app)
    time.sleep(5)
    session = device.attach(pid)
    device.resume(pid)


    def on_message(message, data):
        if message['type'] == 'send':
            print(message['payload'])
        elif message['type'] == 'error':
            print(message['stack'])


    script = session.create_script(jscode)
    
    script.on('message', on_message)
    script.load()
    print(script.exports.begin("myusername", "mypassword"))
    #print(script.exports.sub(5, 3))
    print("Done with that begin function")
    time.sleep(45)
    session.detach()
except BaseException as e:
    traceback.print_exc()
    pass


print("DONE")
print("---------------------------------------------")

I get the following error when I run the above script

TypeError: cannot read property 'apply' of undefined
    at [anon] (duk_hobject_props.c:2385)
    at frida/runtime/core.js:57

Is this a bug? or something I am doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant