qilingframework / qiling

A True Instrumentable Binary Emulation Framework
https://qiling.io
GNU General Public License v2.0
5.06k stars 737 forks source link

Enable more flexible logging redirection #1456

Closed elicn closed 5 months ago

elicn commented 6 months ago

Modified logger setup to allow more flexible logging redirection and multiplexing.

Interface changes

The current interface in which log_file is used to optionally specify a filename to log into:

ql = Qiling(argv, rootfs, log_file=r'/tmp/myprog.log')

Was changed into an optional variable that accepts a Collection of either filenames or open streams:

ql = Qiling(argv, rootfs, log_devices=[sys.stderr, r'/tmp/myprog.log'])

Notes

Advantages

It is now way easier to open multiple loggers and redirect them to any file, stream or socket. This is very useful when trying to separate the emulated program output from logging output, or enable logging while fuzzing (which is currently hidden "behind" AFL box).

In the following example the logging output is redirected to another terminal pane to separate program output from logging output:

ql = Qiling(argv, rootfs, log_devices=['/dev/pts/6'])

image

xwings commented 5 months ago

Cool idea!