Skip to content

Commit

Permalink
Merge pull request libdebug#90 from libdebug/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
io-no authored Aug 1, 2024
2 parents a6b868b + 028468f commit e9e7b7a
Show file tree
Hide file tree
Showing 43 changed files with 3,262 additions and 73 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
prune media
prune test
prune docs
prune examples
prune .github
prune */__pycache__
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project = 'libdebug'
copyright = '2024, Gabriele Digregorio, Roberto Alessandro Bertolini, Francesco Panebianco'
author = 'JinBlack, Io_no, MrIndeciso, Frank01001'
release = '0.5.3'
release = '0.5.4'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
34 changes: 30 additions & 4 deletions docs/source/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,39 @@ The best of both worlds
-----------------------
The `dbg` option is the combination of the `pipe` and `debugger` options. It displays all logs related to the debugging operations performed on the process by libdebug, as well as interactions with the process pipe: bytes received and bytes sent.

Temporary Logging
-----------------
Change logger levels at runtime
-------------------------------
Logger levels can be changed at runtime using the `libcontext` module. The following example shows how to change the logger levels at runtime.

.. code-block:: python
from libdebug import libcontext
libcontext.pipe_logger = 'DEBUG'
libcontext.debugger_logger = 'DEBUG'
libcontext.general_logger = 'DEBUG'
The `general_logger` refers to the logger used for the general logs, different from the `pipe` and `debugger` logs.

Logger levels can be temporarily enabled at runtime using a `with` statement, as shown in the following example.

.. code-block:: python
from libdebug import libcontext
with libcontext.tmp(pipe_logger='INFO', debugger_logger='DEBUG'):
r.sendline(b'gimme the flag')
with libcontext.tmp(pipe_logger='SILENT', debugger_logger='DEBUG'):
r.sendline(b'gimme the flag')
In this example, the `pipe_logger` is set to `SILENT`, and the `debugger_logger` is set to `DEBUG`. The logger levels are restored to their previous values when the `with` block is exited.

The supported logger levels are the following:

- ``pipe_logger``: ``DEBUG``, ``SILENT``
- ``debugger_logger``: ``DEBUG``, ``SILENT``
- ``general_logger``: ``DEBUG``, ``INFO``, ``WARNING``, ``SILENT``

The default logger levels are:

- ``pipe_logger``: ``SILENT``
- ``debugger_logger``: ``SILENT``
- ``general_logger``: ``DEBUG``

The `DEBUG` level is the most verbose, including all logs. The `INFO` level includes all logs except for the `DEBUG` logs. The `WARNING` level includes only the `WARNING` logs. The `SILENT` level disables all logs.
Binary file added examples/bof_detection/bof
Binary file not shown.
25 changes: 25 additions & 0 deletions examples/bof_detection/bof.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// This file is part of libdebug Python library (https://github.com/libdebug/libdebug).
// Copyright (c) 2024 Francesco Panebianco. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
//
// Compile with:
// gcc bof.c -o bof -fno-stack-protector -std=c99

#include <stdio.h>

int main(int argc, char** argv) {
char buffer[32];

// Setvbuf is used to disable buffering
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);

printf("libdebug 4 exploitation testing bench\n");

printf("Enter a string: ");
// This is a vulnerable function, it does not check the size of the input
gets(buffer);

return 0;
}
Loading

0 comments on commit e9e7b7a

Please sign in to comment.