Skip to content

Commit

Permalink
Update miasm version
Browse files Browse the repository at this point in the history
  • Loading branch information
serpilliere committed Jun 9, 2020
1 parent 14866eb commit dbe9955
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 72 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ addons:
- python-virtualenv
- unzip
- gcc-multilib
- python-future
before_script:
- "cd .."
# make virtual env
- "python /usr/lib/python2.7/dist-packages/virtualenv.py virtualenv;"
- "cd virtualenv;"
- "source bin/activate;"
# install elfesteem
- "git clone https://github.com/serpilliere/elfesteem elfesteem && cd elfesteem && python setup.py install && cd ..;"
# install pyparsing
- "pip install pyparsing"
# install future
- "pip install future"
# install miasm
- "cd ..;git clone -b 'v0.1.1' https://github.com/cea-sec/miasm miasm && cd miasm;"
- "cd ..;git clone -b 'v0.1.3' https://github.com/cea-sec/miasm miasm && cd miasm;"
- "python setup.py build build_ext -I$(pwd)/../virtualenv/include -L$(pwd)/../virtualenv/tinycc"
- "python setup.py install"
- "cd ..;"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ RUN cd /opt &&\
tar xzvf Sibyl.tar.gz &&\
rm Sibyl.tar.gz &&\
mv Sibyl-master Sibyl &&\
chown -Rh miasm2 Sibyl &&\
chown -Rh miasm Sibyl &&\
cd Sibyl &&\
python setup.py install

# Prepare the environment
WORKDIR /opt/Sibyl
USER miasm2
USER miasm

CMD ["/usr/local/bin/sibyl"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Copyright 2014 - 2019 [Camille MOUGEY](mailto:[email protected])
Sibyl
=====

A _Miasm2_ based function divination.
A _Miasm_ based function divination.

Idea
----
Expand All @@ -16,7 +16,7 @@ But it is a time consuming task. Moreover, this task is made more difficult due

Tools have been developed to automate this task. Some are based on CFG (Control Flow Graph) signature (_Bindiff_), others on magic constants (_FindCrypt_) or enhanced pattern matching (_FLIRT_).

_Sibyl_ is one of these tools, dynamic analysis oriented and **based on _Miasm2_** (https://github.com/cea-sec/miasm).
_Sibyl_ is one of these tools, dynamic analysis oriented and **based on _Miasm_** (https://github.com/cea-sec/miasm).
The idea is to identify functions from their side effects. That way, identification is independent of the used implementation.

Identifications are done thanks to these steps:
Expand Down Expand Up @@ -167,7 +167,7 @@ Installation

### Standard

_Sibyl_ requires at least _Miasm2_ version `v0.1.1` and the corresponding version of _Elfesteem_.
_Sibyl_ requires at least _Miasm_ version `v0.1.3`.
For the `qemu` engine, the `unicorn` python package must be installed (refer to the documentation of Unicorn for more detail).

_Sibyl_ comes as a Python module, and the installation follow the standard procedure:
Expand Down Expand Up @@ -253,7 +253,7 @@ To avoid these behaviors, there is a timeout on each sub-test. The _-i/--timeout

### How to run the tool on a custom architecture?

Once the architecture and corresponding semantic is implemented in Miasm2, one just needs to implement the wanted ABI in _sibyl/abi/_.
Once the architecture and corresponding semantic is implemented in Miasm, one just needs to implement the wanted ABI in _sibyl/abi/_.
If writing the jitter engine part is an issue, one can directly use the _python_ jitter option with _-j/--jitter_ argument.
If the semantic is not complete enough, one can add the corresponding bridge with _qemu_ in `sibyl/engine/qemu.py`, if available.

Expand Down
2 changes: 1 addition & 1 deletion doc/LEARNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ restrictive implementation, or a useless argument.
The resulting test looks like:
```Python
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
from sibyl.test.test import TestHeader, TestSetTest
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
url='https://github.com/cea-sec/sibyl',
download_url='https://github.com/cea-sec/sibyl/tarball/master',
license='GPLv3+',
description='A Miasm2 based function divination',
description='A Miasm based function divination',
long_description="""
Sibyl is a tool aiming at recognizing functions in binaries based on their side
effects, by running them in a sandboxed environment.""",
keywords=["reverse engineering", "emulation"],
install_requires=[
'miasm2',
'miasm',
],
packages=['sibyl', 'sibyl/abi', 'sibyl/engine', 'sibyl/learn',
'sibyl/learn/tracer', 'sibyl/learn/generator',
Expand Down
4 changes: 2 additions & 2 deletions sibyl/actions/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import sys
from collections import namedtuple

from miasm2.analysis.machine import Machine
from miasm2.analysis.binary import Container
from miasm.analysis.machine import Machine
from miasm.analysis.binary import Container

from sibyl.config import config
from sibyl.testlauncher import TestLauncher
Expand Down
4 changes: 2 additions & 2 deletions sibyl/actions/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import os

from miasm2.analysis.machine import Machine
from miasm2.analysis.binary import Container
from miasm.analysis.machine import Machine
from miasm.analysis.binary import Container

from sibyl.config import config, config_paths
from sibyl.actions.action import Action
Expand Down
2 changes: 1 addition & 1 deletion sibyl/actions/learn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import logging

from miasm2.analysis.binary import Container
from miasm.analysis.binary import Container

from sibyl.actions.action import Action
from sibyl.learn.tracer import AVAILABLE_TRACER
Expand Down
6 changes: 3 additions & 3 deletions sibyl/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
except ImportError:
pycparser = None
else:
from miasm2.core.ctypesmngr import c_to_ast, CTypeFunc
from miasm2.core.objc import ObjCPtr, ObjCArray
from miasm.core.ctypesmngr import c_to_ast, CTypeFunc
from miasm.core.objc import ObjCPtr, ObjCArray

def init_logger(name):
logger = logging.getLogger(name)
Expand Down Expand Up @@ -51,7 +51,7 @@ class HeaderFile(object):
def __init__(self, header_data, ctype_manager):
"""Parse @header_data to fill @ctype_manager
@header_data: str of a C-like header file
@ctype_manager: miasm2.core.objc.CTypesManager instance"""
@ctype_manager: miasm.core.objc.CTypesManager instance"""
self.data = header_data
self.ctype_manager = ctype_manager

Expand Down
8 changes: 4 additions & 4 deletions sibyl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, default_config, files):
def expandpath(path):
"""Expand @path with following rules:
- $SIBYL is replaced by the installation path of Sibyl
- $MIASM is replaced by the installation path of miasm2
- $MIASM is replaced by the installation path of miasm
- path are expanded ('~' -> '/home/user', ...)
"""
if "$SIBYL" in path:
Expand All @@ -76,9 +76,9 @@ def expandpath(path):
path = path.replace("$SIBYL", sibyl_base)

if "$MIASM" in path:
import miasm2
miasm2_base = miasm2.__path__[0]
path = path.replace("$MIASM", miasm2_base)
import miasm
miasm_base = miasm.__path__[0]
path = path.replace("$MIASM", miasm_base)

path = os.path.expandvars(path)
path = os.path.expanduser(path)
Expand Down
2 changes: 1 addition & 1 deletion sibyl/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module abstracts running engine"""

from sibyl.engine.qemu import QEMUEngine
from sibyl.engine.miasm import MiasmEngine
from sibyl.engine.miasm_engine import MiasmEngine
2 changes: 1 addition & 1 deletion sibyl/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Engine(object):

def __init__(self, machine):
"""Instanciate an Engine
@machine: miasm2.analysis.machine:Machine instance"""
@machine: miasm.analysis.machine:Machine instance"""
self.logger = init_logger(self.__class__.__name__)

def take_snapshot(self):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions sibyl/engine/qemu.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from miasm2.core.utils import pck32, pck64
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.core.utils import pck32, pck64
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
try:
import unicorn
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion sibyl/heuristics/arch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Module for architecture guessing"

from miasm2.analysis.binary import Container, ContainerUnknown
from miasm.analysis.binary import Container, ContainerUnknown

from sibyl.heuristics.heuristic import Heuristic

Expand Down
6 changes: 3 additions & 3 deletions sibyl/heuristics/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import os

from miasm2.core.asmblock import AsmBlockBad, log_asmblock
from miasm.core.asmblock import AsmBlockBad, log_asmblock

from sibyl.heuristics.heuristic import Heuristic
import sibyl.heuristics.csts as csts
Expand Down Expand Up @@ -225,8 +225,8 @@ class FuncHeuristic(Heuristic):

def __init__(self, cont, machine, filename):
"""
@cont: miasm2's Container instance
@machine: miasm2's Machine instance
@cont: miasm's Container instance
@machine: miasm's Machine instance
@filename: target's filename
"""
super(FuncHeuristic, self).__init__()
Expand Down
16 changes: 8 additions & 8 deletions sibyl/learn/findref.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import struct
import logging

from miasm2.jitter.loader.elf import vm_load_elf
from miasm2.analysis.machine import Machine
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN
from miasm2.core.bin_stream import bin_stream_vm
from miasm2.analysis.dse import ESETrackModif
import miasm2.expression.expression as m2_expr
from miasm2.ir.ir import AssignBlock
from miasm2.core.objc import CHandler
from miasm.jitter.loader.elf import vm_load_elf
from miasm.analysis.machine import Machine
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN
from miasm.core.bin_stream import bin_stream_vm
from miasm.analysis.dse import ESETrackModif
import miasm.expression.expression as m2_expr
from miasm.ir.ir import AssignBlock
from miasm.core.objc import CHandler

from sibyl.commons import objc_is_dereferenceable
from sibyl.config import config
Expand Down
2 changes: 1 addition & 1 deletion sibyl/learn/generator/generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from miasm2.analysis.machine import Machine
from miasm.analysis.machine import Machine


class Generator(object):
Expand Down
8 changes: 4 additions & 4 deletions sibyl/learn/generator/pythongenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from sibyl.learn.generator.generator import Generator
from sibyl.learn.generator import templates as TPL
from sibyl.learn.trace import MemoryAccess
from miasm2.ir.ir import AssignBlock
from miasm.ir.ir import AssignBlock

from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm2.expression.expression import *
from miasm2.expression.simplifications import expr_simp
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.expression.expression import *
from miasm.expression.simplifications import expr_simp

from sibyl.commons import objc_is_dereferenceable

Expand Down
2 changes: 1 addition & 1 deletion sibyl/learn/generator/templates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python
imports = """
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
from sibyl.test.test import TestHeader, TestSetTest
""".strip()
Expand Down
6 changes: 3 additions & 3 deletions sibyl/learn/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import pycparser
except ImportError:
raise ImportError("pycparser module is needed to learn and generate")
from miasm2.core.objc import CTypesManagerNotPacked
from miasm2.core.ctypesmngr import CAstTypes
from miasm2.arch.x86.ctype import CTypeAMD64_unk
from miasm.core.objc import CTypesManagerNotPacked
from miasm.core.ctypesmngr import CAstTypes
from miasm.arch.x86.ctype import CTypeAMD64_unk

from sibyl.learn.replay import Replay
from sibyl.learn.findref import ExtractRef
Expand Down
6 changes: 3 additions & 3 deletions sibyl/learn/replay.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import struct

from miasm2.jitter.loader.elf import vm_load_elf
from miasm2.analysis.machine import Machine
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN
from miasm.jitter.loader.elf import vm_load_elf
from miasm.analysis.machine import Machine
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL, EXCEPT_DIV_BY_ZERO, EXCEPT_PRIV_INSN

from sibyl.config import config

Expand Down
6 changes: 3 additions & 3 deletions sibyl/learn/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import struct

from sibyl.learn.replay import Replay
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm2.core.graph import DiGraph
from miasm2.analysis.machine import Machine
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.core.graph import DiGraph
from miasm.analysis.machine import Machine


class Trace(list):
Expand Down
2 changes: 1 addition & 1 deletion sibyl/learn/tracer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from sibyl.learn.tracer.pin import TracerPin
from sibyl.learn.tracer.miasm import TracerMiasm
from sibyl.learn.tracer.miasm_tracer import TracerMiasm

AVAILABLE_TRACER = {
"pin": TracerPin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from sibyl.learn.tracer.tracer import Tracer
from sibyl.learn.trace import Trace, Snapshot

from miasm2.jitter.emulatedsymbexec import EmulatedSymbExec
from miasm2.jitter.csts import PAGE_READ
from miasm2.analysis.machine import Machine
from miasm2.jitter.loader.elf import vm_load_elf
from miasm.jitter.emulatedsymbexec import EmulatedSymbExec
from miasm.jitter.csts import PAGE_READ
from miasm.analysis.machine import Machine
from miasm.jitter.loader.elf import vm_load_elf

class CustomEmulatedSymbExec(EmulatedSymbExec):
'''New emulator that trap all memory read and write which is needed by the miasm tracer'''
Expand Down
12 changes: 6 additions & 6 deletions sibyl/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@


import random
from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm2.expression.modint import mod_size2int
from miasm2.expression.simplifications import expr_simp
from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
from miasm.expression.modint import mod_size2int
from miasm.expression.simplifications import expr_simp
try:
import pycparser
except ImportError:
pycparser = None
else:
from miasm2.core.objc import CTypesManagerNotPacked, CHandler
from miasm2.core.ctypesmngr import CAstTypes
from miasm2.arch.x86.ctype import CTypeAMD64_unk
from miasm.core.objc import CTypesManagerNotPacked, CHandler
from miasm.core.ctypesmngr import CAstTypes
from miasm.arch.x86.ctype import CTypeAMD64_unk

from sibyl.commons import HeaderFile

Expand Down
6 changes: 3 additions & 3 deletions sibyl/testlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import time
import signal
import logging
from miasm2.analysis.binary import Container, ContainerPE, ContainerELF
from miasm.analysis.binary import Container, ContainerPE, ContainerELF

from sibyl.commons import init_logger, TimeoutException, END_ADDR
from sibyl.engine import QEMUEngine, MiasmEngine
Expand Down Expand Up @@ -63,12 +63,12 @@ def init_stub(self):

libs = None
if isinstance(self.ctr, ContainerPE):
from miasm2.jitter.loader.pe import preload_pe, libimp_pe
from miasm.jitter.loader.pe import preload_pe, libimp_pe
libs = libimp_pe()
preload_pe(self.jitter.vm, self.ctr.executable, libs)

elif isinstance(self.ctr, ContainerELF):
from miasm2.jitter.loader.elf import preload_elf, libimp_elf
from miasm.jitter.loader.elf import preload_elf, libimp_elf
libs = libimp_elf()
preload_elf(self.jitter.vm, self.ctr.executable, libs)

Expand Down
2 changes: 1 addition & 1 deletion test/find/run_ctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from argparse import ArgumentParser
from utils.log import log_error, log_success, log_info

from elfesteem.elf_init import ELF
from miasm.loader.elf_init import ELF
from sibyl.heuristics.func import FuncHeuristic

match_C = re.compile("\w+[ \*]+(\w+)\(.*\)")
Expand Down
Loading

0 comments on commit dbe9955

Please sign in to comment.