Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/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>
#!/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):
#!/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)
#!/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)
#!/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
# -*- 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
#!/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):
#!/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