Code Monkey home page Code Monkey logo

Comments (6)

ClaudiuGeorgiu avatar ClaudiuGeorgiu commented on May 27, 2024

Hi, can you provide more details? What version of the tool are you using (docker, directly on your pc - windows/ubuntu/other)? Does it work if you use the online version of the tool? If the error is for a specific apk, please provide it so I can do some debugging.

From a quick search it looks like the error may be caused by using a pc with a different architecture (scikit-learn/scikit-learn#7891, https://stackoverflow.com/questions/21033038/scikits-learn-randomforrest-trained-on-64bit-python-wont-open-on-32bit-python), but I don't know if that's your case.

from riskindroid.

trickerkaim avatar trickerkaim commented on May 27, 2024

I am using it directly on my pc-windows 64-bit and Python version 3.6.0

`* Serving Flask app "app" (lazy loading)

  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [19/Jun/2018 19:56:37] "GET / HTTP/1.1" 200 -
    127.0.0.1 - - [19/Jun/2018 19:56:37] "GET /static/site.css HTTP/1.1" 200 -
    127.0.0.1 - - [19/Jun/2018 19:56:37] "GET /static/filestyle.min.js HTTP/1.1" 200 -
    127.0.0.1 - - [19/Jun/2018 19:56:38] "GET /favicon.ico HTTP/1.1" 404 -
    127.0.0.1 - - [19/Jun/2018 19:56:38] "GET /favicon.ico HTTP/1.1" 404 -
    C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\base.py:311: UserWarning: Trying to unpickle estimator SVC from version 0.18.1 when using version 0.19.1. This might lead to breaking code or invalid results. Use at your own risk.
    UserWarning)
    C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\base.py:311: UserWarning: Trying to unpickle estimator MultinomialNB from version 0.18.1 when using version 0.19.1. This might lead to breaking code or invalid results. Use at your own risk.
    UserWarning)
    [2018-06-19 19:56:44,566] ERROR in app: Exception on /upload [POST]
    Traceback (most recent call last):
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask\app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask_compat.py", line 35, in reraise
    raise value
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functionsrule.endpoint
    File "app/app.py", line 92, in upload_apk
    rid = RiskInDroid()
    File "C:\Users\Anyone\Documents\MNIT Project\riskdroid\RiskInDroid\app\RiskInDroid.py", line 220, in init
    self.trained_models.append(joblib.load(os.path.join(self.saved_models_dir, _model_name)))
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py", line 578, in load
    obj = _unpickle(fobj, filename, mmap_mode)
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py", line 508, in _unpickle
    obj = unpickler.load()
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\pickle.py", line 1050, in load
    dispatchkey[0]
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py", line 341, in load_build
    self.stack.append(array_wrapper.read(self))
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py", line 184, in read
    array = self.read_array(unpickler)
    File "C:\Users\TrickerKaim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\externals\joblib\numpy_pickle.py", line 108, in read_array
    array = pickle.load(unpickler.file_handle)
    File "sklearn\tree_tree.pyx", line 601, in sklearn.tree._tree.Tree.cinit
    ValueError: Buffer dtype mismatch, expected 'SIZE_t' but got 'long long'
    127.0.0.1 - - [19/Jun/2018 19:56:44] "POST /upload HTTP/1.1" 500 -`

Requirements Installed

Flask-SQLAlchemy==2.3.2
Flask==1.0.2
numpy==1.14.1
scikit-learn==0.19.1
scipy==1.1.0
tqdm==4.23.4
uWSGI==2.0.14

And yes online version is working fine on same apk file.
Any suggestion

from riskindroid.

ClaudiuGeorgiu avatar ClaudiuGeorgiu commented on May 27, 2024

You are using a different version of the scikit-learn library, 0.19.1, while the tool uses an older version, 0.18.1. You have 2 options:

  • install the same versions of the libraries used by RiskInDroid (see requirements.txt file in this reporsitory)
  • delete the models saved in the app/models/ directory, so that the next time you run the tool you will force the training of the models using your version of the library (this might take some minutes)

from riskindroid.

trickerkaim avatar trickerkaim commented on May 27, 2024

Thanks a lot now its working.
I just changed the version of scikit-learn to 0.18.1.

from riskindroid.

trickerkaim avatar trickerkaim commented on May 27, 2024

Can you please explain me how you have calculated Risk for the data set in RiskinDroid.py
i.e Using static impact i got it, using dynamic impact got it but how you have calculated based on classifier
RIV value of each classifier?
Is it
Risk(i) = likelihood(i) * dynamic impact(i)
or something more is added

from riskindroid.

ClaudiuGeorgiu avatar ClaudiuGeorgiu commented on May 27, 2024

From the classifiers contained in the scikit-learn Python library we evaluated only those which provide probability estimation. We then created a training set, composed by both malware and applications downloaded from the official Play Store. We used this training set to analyze the accuracy of the classifiers and then we chose to use only the 4 best performing ones (in terms of accuracy). Since each classifier outputs a probability, the final risk score (for each app) is obtained by averaging the results given by the 4 classifiers. We used only the classifiers that provide a predict_proba method (e.g., Support Vector Machines - http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.predict_proba). To calculate the accuracy, we considered classification output above 50% as malware and below 50% as not malware, then we used the formula (correct predictions / total predictions) to find the accuracy for each classifier over the training set (using 10 fold cross validation). After choosing the 4 classifiers with the highest accuracy, we still used the predict_proba method to obtain a risk value for the applications not belonging to the training set (the risk value is the % of belonging to the malware class, taken from the output of predict_proba method), so the final risk result for each app is the average output of the predict_proba method of the 4 chosen classifiers.

from riskindroid.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.