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

Encoding error in Shodan results #322

Closed
amr-cossi opened this issue Aug 1, 2018 · 5 comments
Closed

Encoding error in Shodan results #322

amr-cossi opened this issue Aug 1, 2018 · 5 comments
Labels
category:bug Issue is related to a bug
Milestone

Comments

@amr-cossi
Copy link
Contributor

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu
OS version (client) 16.04
Cortex Analyzer Name Shodan_Host
Cortex Analyzer Version 1.0
Cortex Version 2.0.4-1
Browser type & version N/A

Description

If a scan result contains foreign characters, the job fails with an Invalid output error.

Steps to Reproduce

  1. Launch job on Analyzer Shodan_Host and IP 211.104.160.152

Possible Solutions

A dirty workaround is to re-encode the result before sending it to report() but a better solution would probably be to handle this case in Cortex back-end.

        self.report(self.encode(results))
[...]
    def encode(self, x):
        if isinstance(x, str):
            return x.encode('utf-8', 'ignore').decode('utf-8', 'ignore')
        elif isinstance(x, dict):
            return {k: self.encode(v) for k, v in x.items()}
        elif isinstance(x, list):
            return [self.encode(k) for k in x]
        else:
            return x
@3c7 3c7 added category:bug Issue is related to a bug scope:analyzer Issue is analyzer related and removed scope:analyzer Issue is analyzer related labels Aug 2, 2018
@3c7
Copy link
Contributor

3c7 commented Jan 22, 2019

Hey @amr-cossi, is this still an issue? Cannot reproduce it with the IP and Shodan_Host Analyzer.

@nadouani
Copy link
Contributor

Up

@amr-cossi
Copy link
Contributor Author

Hey,
I can confirm the bug still exists, but as it depends on the output of the query, my example is outdated.
I can reproduce it right now on Cortex 2.1.3 with a call to Shodan_Host_History_1_0 on IP 162[.]220[.]15[.]90.
Invalid output error with the official analyzer, works fine with my encoding hack.

@jeromeleonard
Copy link
Contributor

tried to debug it with @To-om and got this error message :

"errorMessage": "Unexpected Error: 'utf-8' codec can't encode character '\\ud8ec' in position 2952: surrogates not allowed"

Still looking a way to solve it.

@jeromeleonard jeromeleonard added this to the 2.2.0 milestone Jun 29, 2019
@jeromeleonard
Copy link
Contributor

using the workaround waiting for another solution

jeromeleonard added a commit that referenced this issue Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug Issue is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants