Exemple #1
0
    def write_console(self, charseq):
        """Writes a string to a console frame buffer
        beginning at the current cursor location.

        charseq: str
            the string to be written on the frame buffer
        """
        write_console_unicode(self._framebuffer, charseq, len(charseq), byref(c_ulong()), None)
Exemple #2
0
    def emit(self, kevent, **kwargs):
        """Renders the kevent to the standard output stream.

        Uses the default output format or JSON to render the
        kernel event to standard output stream.

        The default output format is as follows:

        id  timestamp  cpu  process  (process id) - kevent (parameters)
        --  ---------  ---  -------  -----------   ------- ------------

        Example:

        160 13:27:27.554 0 wmiprvse.exe (1012) - CloseFile (file=C:\\WINDOWS\\SYSTEM32\\RSAENH.DLL, tid=2668)

        Parameters
        ----------

        kevent: KEvent
            the information regarding the kernel event

        kwargs: dict
            console adapter configuration

        """
        if isinstance(kevent, dict):
            kevt = json.dumps(kevent)
        else:
            pid, proc = kevent.get_thread()
            if 'pretty' in self._fmt:
                kevt = RENDER_FORMAT % (kevent.kid,
                                        kevent.ts.time(),
                                        kevent.cpuid,
                                        proc,
                                        pid,
                                        kevent.name,
                                        self._format_params(kevent.params))
            else:
                kevt = json.dumps(dict(id=kevent.kid,
                                       timestamp=kevent.ts.strftime(self._timestamp_pattern),
                                       cpuid=kevent.cpuid,
                                       proc=proc,
                                       pid=pid,
                                       name=kevent.name,
                                       params=kevent.params))

        kevt += '\n'
        # write the output on the standard output stream
        write_console_unicode(self._stdout_handle, kevt,
                              len(kevt),
                              byref(c_ulong()),
                              None)
Exemple #3
0
    def emit(self, kevent, **kwargs):
        """Renders the kevent to the standard output stream.

        Uses the default output format or JSON to render the
        kernel event to standard output stream.

        The default output format is as follows:

        id  timestamp  cpu  process  (process id) - kevent (parameters)
        --  ---------  ---  -------  -----------   ------- ------------

        Example:

        160 13:27:27.554 0 wmiprvse.exe (1012) - CloseFile (file=C:\\WINDOWS\\SYSTEM32\\RSAENH.DLL, tid=2668)

        Parameters
        ----------

        kevent: KEvent
            the information regarding the kernel event

        kwargs: dict
            console adapter configuration

        """
        pid, proc = kevent.get_thread()
        if 'pretty' in self._fmt:
            kevt = RENDER_FORMAT % (kevent.kid,
                                    kevent.ts.time(),
                                    kevent.cpuid,
                                    proc,
                                    pid,
                                    kevent.name,
                                    self._format_params(kevent.params))
        else:
            kevt = json.dumps(dict(id=kevent.kid,
                                   timestamp=kevent.ts.strftime(self._timestamp_pattern),
                                   cpuid=kevent.cpuid,
                                   proc=proc,
                                   pid=pid,
                                   name=kevent.name,
                                   params=kevent.params))

        kevt += '\n'
        # write the output on the standard output stream
        write_console_unicode(self._stdout_handle, kevt,
                              len(kevt),
                              byref(c_ulong()),
                              None)
Exemple #4
0
    def write_console(cls, charseq, new_line=True):
        """Outputs to a Windows console using UNICODE charset.

        Parameters
        ----------

        charseq: str
            the sequence of characters to be written

        new_line: bool
            indicates if the output should be written on the new line
        """
        if new_line:
            charseq += '\n'
        else:
            charseq += '\r'
        write_console_unicode(cls._stdout_handle, charseq, len(charseq), byref(c_ulong()), None)
Exemple #5
0
    def write_console(cls, charseq, new_line=True):
        """Outputs to a Windows console using UNICODE charset.

        Parameters
        ----------

        charseq: str
            the sequence of characters to be written

        new_line: bool
            indicates if the output should be written on the new line
        """
        if new_line:
            charseq += '\n'
        else:
            charseq += '\r'
        write_console_unicode(cls._stdout_handle, charseq, len(charseq),
                              byref(c_ulong()), None)