Skip to content

osquery can't close win pipe #57

Closed

Description

@blessedvictim

After any query on del of SpawnInstance I get an ignored exception
Exception ignored in <bound method SpawnInstance.__del__ of <osquery.management.SpawnInstance object at 0x021854F0>> pywintypes.error: (1, 'DicsonnectNamedPipe', 'Incorrect function.')
my script:
import osquery instance = osquery.SpawnInstance() instance.open() instance.client.query("<some query>")
Now i use some dirty "hack" as after
instance.client.query("<some query>")
i do:
instance.connection=None
My machine os:
Windows 7x64

Activity

  1. JarryShaw commented on Aug 10, 2019

    @JarryShaw
    Contributor

    This issue remains on version 3.0.6. I used del (calling __del__ internally) to make a more reasonable pipe closing, since there's no close function.

    >>> import osquery
    >>> instance = osquery.SpawnInstance()
    >>> instance.open()
    >>> del instance
    Exception ignored in: <function SpawnInstance.__del__ at 0x000000D3ABF62678>
    Traceback (most recent call last):
      File "C:\Users\fakepath\AppData\Local\Programs\Python\Python37\lib\site-packages\osquery\management.py", line 89, in __del__
        self.connection.close()
      File "C:\Users\fakepath\AppData\Local\Programs\Python\Python37\lib\site-packages\osquery\extension_client.py", line 55, in close
        self._transport.close()
      File "C:\Users\fakepath\AppData\Local\Programs\Python\Python37\lib\site-packages\thrift\transport\TTransport.py", line 156, in close
        return self.__trans.close()
      File "C:\Users\fakepath\AppData\Local\Programs\Python\Python37\lib\site-packages\osquery\TPipe.py", line 35, in close
        win32pipe.DisconnectNamedPipe(self._handle)
    pywintypes.error: (1, 'DisconnectNamedPipe', 'Incorrect function.')
    

    Environment:

    • Windows 10 Pro
    • osquery-python: 3.0.6
    • ossuary: 3.3.0
    • pywin32: 224
  2. hotab commented on Dec 23, 2022

    @hotab

    This still happens in 3.0.7 (latest version from pip) on win 10

    Problem disappears when using outhex@19691b9 - this fix

  3. added a commit that references this issue on Dec 23, 2022
  4. filiagees commented on Apr 10, 2024

    @filiagees

    This still happens in 3.0.7 (latest version from pip) on win 10

    Problem disappears when using outhex@19691b9 - this fix

    @hotab This fix worked for me, too.
    Thanks for pointing out.

    I'm using win10, with:

    • osquery==3.0.7
    • pywin32==306
    • pywin32-ctypes==0.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions