Skip to content

Commit

Permalink
Update whois_wrapper.py to define folder path
Browse files Browse the repository at this point in the history
The implementation of `./whois.sh` was causing issues while executing through Cortex's web GUI. Updated code to reflect absolute file path of the Python code being executed which sits next to `whois.sh`
  • Loading branch information
scrublullz authored Oct 1, 2018
1 parent e3b618c commit 1f6f1dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion analyzers/CERTatPassiveDNS/whois_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
import os
from subprocess import check_output


Expand All @@ -13,7 +14,7 @@ def __query(domain, limit=100):
:returns: str -- Console output from whois call.
:rtype: str
"""
s = check_output(['./whois.sh', '--limit {} {}'.format(limit, domain)], universal_newlines=True)
s = check_output([os.path.dirname(os.path.realpath(__file__)) + '/whois.sh', '--limit {} {}'.format(limit, domain)], universal_newlines=True)
return s


Expand Down

1 comment on commit 1f6f1dd

@scrublullz
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modules now executes properly, although it is responding with an execution timeout currently.

Original error:

Invalid output
Traceback (most recent call last):
  File "CERTatPassiveDNS/certat_passivedns.py", line 38, in <module>
    CERTatPassiveDNSAnalyzer().run()
  File "CERTatPassiveDNS/certat_passivedns.py", line 18, in run
    self.report({'results': query(self.get_data(), int(self.limit))})
  File "/opt/Cortex-Analyzers/analyzers/CERTatPassiveDNS/whois_wrapper.py", line 54, in query
    return __process_results(__query(domain, limit))
  File "/opt/Cortex-Analyzers/analyzers/CERTatPassiveDNS/whois_wrapper.py", line 16, in __query
    s = check_output(['./whois.sh', '--limit {} {}'.format(limit, domain)], universal_newlines=True)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: './whois.sh': './whois.sh'

New Error:

Invalid output
Timeout.
Traceback (most recent call last):
  File "CERTatPassiveDNS/certat_passivedns.py", line 38, in <module>
    CERTatPassiveDNSAnalyzer().run()
  File "CERTatPassiveDNS/certat_passivedns.py", line 18, in run
    self.report({'results': query(self.get_data(), int(self.limit))})
  File "/opt/Cortex-Analyzers/analyzers/CERTatPassiveDNS/whois_wrapper.py", line 55, in query
    return __process_results(__query(domain, limit))
  File "/opt/Cortex-Analyzers/analyzers/CERTatPassiveDNS/whois_wrapper.py", line 17, in __query
    s = check_output([os.path.dirname(os.path.realpath(__file__)) + '/whois.sh', '--limit {} {}'.format(limit, domain)], universal_newlines=True)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/opt/Cortex-Analyzers/analyzers/CERTatPassiveDNS/whois.sh', '--limit 100 google.com']' returned non-zero exit status 2.

Please sign in to comment.