How to use the lief.Logger.set_level function in lief

To help you get started, we’ve selected a few lief examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lief-project / LIEF / tests / elf / test_static.py View on Github external
#!/usr/bin/env python
import unittest
import logging
import os
import sys
import subprocess
import tempfile
import shutil
import lief
from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.INFO)

from subprocess import Popen
from unittest import TestCase

from utils import get_compiler

BINADD_C = """\
#include 
#include 

int add(int a, int b);

int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: %s <a> <b>\\n", argv[0]);
    exit(-1);</b></a>
github lief-project / LIEF / tests / elf / test_notes.py View on Github external
#!/usr/bin/env python
import unittest
import lief
import tempfile
import sys
import subprocess
import stat
import os
import logging
import random
import itertools

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.WARNING)
#Logger.set_level(lief.LOGGING_LEVEL.DEBUG)

from unittest import TestCase
from utils import get_sample

from contextlib import redirect_stdout
from io import StringIO

class TestNotes(TestCase):
    LOGGER = logging.getLogger(__name__)

    def setUp(self):
        self.logger = logging.getLogger(__name__)

    @staticmethod
    def safe_delete(output):
github lief-project / LIEF / tests / pe / test_loadconfig.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import lief
import unittest
import logging
import os
import sys
import random

from unittest import TestCase
from utils import get_sample

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.INFO)

class TestLoadConfig(TestCase):
    def setUp(self):
        self.logger = logging.getLogger(__name__)


    def test_winapp(self):
        winapp = lief.parse(get_sample('PE/PE64_x86-64_binary_WinApp.exe'))
        self.assertTrue(winapp.has_configuration)

        lconf = winapp.load_configuration

        self.assertEqual(lconf.version, lief.PE.WIN_VERSION.WIN10_0_15002)
        self.assertEqual(lconf.characteristics, 0xF8)
        self.assertEqual(lconf.timedatestamp, 0)
        self.assertEqual(lconf.major_version, 0)
github lief-project / LIEF / tests / api / test_python.py View on Github external
#!/usr/bin/env python
import unittest
import lief
import logging
import io
from io import open as io_open
from unittest import TestCase
from utils import get_sample

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.WARNING)

class TestPythonApi(TestCase):

    def setUp(self):
        self.logger = logging.getLogger(__name__)

    def test_io(self):
        lspath = get_sample('ELF/ELF64_x86-64_binary_ls.bin')

        ls = lief.parse(lspath)
        self.assertIsNotNone(ls.abstract.header)

        with io_open(lspath, 'r') as f:
            ls = lief.parse(f)
            self.assertIsNotNone(ls.abstract.header)
github lief-project / LIEF / examples / python / macho_reader.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Description
# -----------
# Print information about a Mach-O binary

import sys
import os
import argparse
import traceback
import lief
from lief import MachO

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.FATAL)

terminal_rows, terminal_columns = 100, 100
try:
    terminal_rows, terminal_columns = os.popen('stty size', 'r').read().split()
except ValueError:
    pass

terminal_columns = int(terminal_columns)
terminal_rows    = int(terminal_rows)
EXIT_STATUS = 0

class exceptions_handler(object):
    func = None

    def __init__(self, exceptions, on_except_callback=None):
        self.exceptions         = exceptions
github lief-project / LIEF / examples / python / elf_reader.py View on Github external
# -*- coding: utf-8 -*-

# Description
# -----------
# Print information about an ELF binary

import lief
from lief import ELF

import sys
import os
import traceback
import textwrap

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.ERROR)

from optparse import OptionParser
terminal_rows, terminal_columns = 100, 110
try:
    terminal_rows, terminal_columns = os.popen('stty size', 'r').read().split()
except ValueError:
    pass

terminal_columns = int(terminal_columns) - 10
terminal_rows    = int(terminal_rows)

class exceptions_handler(object):
    func = None

    def __init__(self, exceptions, on_except_callback=None):
        self.exceptions         = exceptions
github lief-project / LIEF / examples / python / oat_reader.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Description
# -----------
# Print information about a Android OAT files
import sys
import os
import argparse
import traceback
import lief
from lief import OAT

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.INFO)
EXIT_STATUS = 0
terminal_rows, terminal_columns = 100, 100
try:
    terminal_rows, terminal_columns = os.popen('stty size', 'r').read().split()
except ValueError:
    pass


class exceptions_handler(object):
    func = None

    def __init__(self, exceptions, on_except_callback=None):
        self.exceptions         = exceptions
        self.on_except_callback = on_except_callback

    def __call__(self, *args, **kwargs):
github lief-project / LIEF / examples / python / vdex_reader.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Description
# -----------
# Print information about Android VDEX files
import sys
import os
import argparse
import traceback
import lief
from lief import VDEX, DEX

from lief import Logger
Logger.set_level(lief.LOGGING_LEVEL.INFO)


EXIT_STATUS = 0
terminal_rows, terminal_columns = 100, 100
try:
    terminal_rows, terminal_columns = os.popen('stty size', 'r').read().split()
except ValueError:
    pass


class exceptions_handler(object):
    func = None

    def __init__(self, exceptions, on_except_callback=None):
        self.exceptions         = exceptions
        self.on_except_callback = on_except_callback