Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion __init__.py → pyreil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
http://www.zynamics.com/binnavi/manual/html/reil_language.htm
"""

from reil.definitions import *
from pyreil import x86
from pyreil import native
2 changes: 1 addition & 1 deletion definitions.py → pyreil/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.definitions
"""pyreil.definitions

This module contains the basic definitions for the REIL instructions
that are used by this library.
Expand Down
4 changes: 2 additions & 2 deletions error.py → pyreil/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

"""
reil.error
pyreil.error

This module contains exception definitions for various generic error
conditions that can occur during translation.
Expand All @@ -28,4 +28,4 @@ class TranslationError(Exception):


class IllegalInstruction(Exception):
pass
pass
4 changes: 2 additions & 2 deletions native.py → pyreil/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.native
"""pyreil.native

This module contains the basic definitions for the native instructions
produced by this library.
Expand All @@ -35,4 +35,4 @@ def __init__(self, address, mnemonic, il_instructions, ends_basic_block=False, s
self.size = size

def __str__(self):
return '{:08x} {:1} {}'.format(self.address, self.ends_basic_block, self.mnemonic)
return '{:08x} {:1} {}'.format(self.address, self.ends_basic_block, self.mnemonic)
6 changes: 3 additions & 3 deletions shorthand.py → pyreil/shorthand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.shorthand
"""pyreil.shorthand

This module contains shorthand functions for creating various REIL
instructions and operands.
"""


import reil.definitions as reil
import pyreil.definitions as reil


def imm(value, size):
Expand Down Expand Up @@ -319,4 +319,4 @@ def sys_(input0=None):
first input operand.
"""

return reil.Instruction(reil.SYS, input0, None, None)
return reil.Instruction(reil.SYS, input0, None, None)
6 changes: 4 additions & 2 deletions x86/__init__.py → pyreil/x86/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86 - x86 and x86_64 translators
"""pyreil.x86 - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -26,4 +26,6 @@
http://www.intel.com/content/dam/www/public/us/en/documents/manuals
/64-ia-32-architectures-software-developer-instruction-set-reference
-manual-325383.pdf
"""
"""

from pyreil.x86.translator import translate
12 changes: 5 additions & 7 deletions x86/arithmetic.py → pyreil/x86/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.arithmetic - x86 and x86_64 translators
"""pyreil.x86.arithmetic - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,13 +23,11 @@
such as add, mul, div
"""

import reil.error
from reil.shorthand import *

import reil.x86.conditional as conditional
import reil.x86.operand as operand
from reil.x86.utilities import *
from pyreil.shorthand import *

from pyreil.x86 import operand
from pyreil.x86 import conditional
from pyreil.x86.utilities import *

# Helpers

Expand Down
15 changes: 7 additions & 8 deletions x86/bitwise.py → pyreil/x86/bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.bitwise - x86 and x86_64 translators
"""pyreil.x86.bitwise - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,16 +23,15 @@
all about twiddling bits and bytes
"""


import capstone
import capstone.x86

import reil
import reil.error
from reil.shorthand import *
from pyreil.shorthand import *

import reil.x86.conditional as conditional
import reil.x86.operand as operand
from reil.x86.utilities import *
from pyreil.x86 import operand
from pyreil.x86 import conditional
from pyreil.x86.utilities import *


def _shift_set_flags(ctx, result):
Expand Down Expand Up @@ -416,4 +415,4 @@ def x86_shrd(ctx, i):

_shift_set_flags(ctx, result)

operand.set(ctx, i, 0, result)
operand.set(ctx, i, 0, result)
4 changes: 2 additions & 2 deletions x86/conditional.py → pyreil/x86/conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
This file contains helpers for x86 conditional instructions
"""

from reil.shorthand import *
from pyreil.shorthand import *

A = 0
AE = 1
Expand Down Expand Up @@ -142,4 +142,4 @@ def condition(ctx, cc):
# sign (SF == 1)
ctx.emit( bisnz_ (r('sf', 8), cond))

return cond
return cond
12 changes: 7 additions & 5 deletions x86/control_flow.py → pyreil/x86/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.control_flow - x86 and x86_64 translators
"""pyreil.x86.control_flow - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,10 +23,12 @@
such as call, jmp and ret.
"""

import reil.x86.conditional as conditional
import reil.x86.operand as operand

from reil.shorthand import *
from pyreil.shorthand import *

from pyreil.x86 import operand
from pyreil.x86 import conditional


# Helpers

Expand Down Expand Up @@ -170,4 +172,4 @@ def x86_ret(ctx, i):
imm(ctx.word_size // 8, ctx.word_size),
ctx.stack_ptr))

ctx.emit( jcc_ (imm(1, 8), return_address))
ctx.emit( jcc_ (imm(1, 8), return_address))
15 changes: 7 additions & 8 deletions x86/logic.py → pyreil/x86/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.logic - x86 and x86_64 translators
"""pyreil.x86.logic - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,13 +23,12 @@
such as and, or, xor
"""

import reil.error
from reil.shorthand import *

import reil.x86.conditional as conditional
import reil.x86.operand as operand
from reil.x86.utilities import *
from pyreil.x86 import operand
from pyreil.x86 import conditional
from pyreil.x86.utilities import *

import pyreil.error
from pyreil.shorthand import *

# Helpers

Expand Down Expand Up @@ -122,4 +121,4 @@ def x86_xor(ctx, i):

_logic_set_flags(ctx, result)

operand.set(ctx, i, 0, result, clear=True)
operand.set(ctx, i, 0, result, clear=True)
17 changes: 7 additions & 10 deletions x86/memory.py → pyreil/x86/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.memory - x86 and x86_64 translators
"""pyreil.x86.memory - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -25,15 +25,12 @@

import capstone

import reil.error
from reil import *
from reil.shorthand import *

import reil.x86.arithmetic as arithmetic
import reil.x86.conditional as conditional
import reil.x86.operand as operand
from reil.x86.utilities import *
from pyreil.shorthand import *

from pyreil.x86 import operand
from pyreil.x86 import arithmetic
from pyreil.x86 import conditional
from pyreil.x86.utilities import *

def conditional_mov(ctx, i, condition):
c = conditional.condition(ctx, condition)
Expand Down Expand Up @@ -456,4 +453,4 @@ def x86_stosq(ctx, i):


def x86_stosw(ctx, i):
x86_stos(ctx, i, 16)
x86_stos(ctx, i, 16)
15 changes: 7 additions & 8 deletions x86/misc.py → pyreil/x86/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.misc - x86 and x86_64 translators
"""pyreil.x86.misc - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,13 +23,12 @@
haven't categorised as anything yet
"""

import reil.error
from reil.shorthand import *

import reil.x86.conditional as conditional
import reil.x86.operand as operand
from reil.x86.utilities import *
import pyreil.error
from pyreil.shorthand import *

from pyreil.x86 import operand
from pyreil.x86 import conditional
from pyreil.x86.utilities import *

def conditional_set(ctx, i, condition):
c = conditional.condition(ctx, condition)
Expand Down Expand Up @@ -399,4 +398,4 @@ def x86_xchg(ctx, i):


def x86_rdtsc(ctx, i):
ctx.emit( nop_ ())
ctx.emit( nop_ ())
11 changes: 5 additions & 6 deletions x86/operand.py → pyreil/x86/operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.operands - x86 and x86_64 translators
"""pyreil.x86.operands - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -25,11 +25,10 @@

import capstone

from reil.error import *
from reil.shorthand import *

from reil.x86.utilities import *
from pyreil.error import *
from pyreil.shorthand import *

from pyreil.x86.utilities import *

def _memory_address(ctx, i, opnd):

Expand Down Expand Up @@ -565,4 +564,4 @@ def set(ctx, i, index, value, clear=False, sign_extend=False):

else:
raise TranslationError(
'Unsupported operand type!')
'Unsupported operand type!')
19 changes: 6 additions & 13 deletions x86/sse.py → pyreil/x86/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""reil.x86.sse - x86 and x86_64 translators
"""pyreil.x86.sse - x86 and x86_64 translators

This module generates REIL (reverse engineering intermediate language)
IL from x86 and x86_64 machine code.
Expand All @@ -23,18 +23,11 @@
the streaming-simd extensions
"""

import itertools
from pyreil.shorthand import *

import capstone
import capstone.x86

import reil.error
from reil.shorthand import *

import reil.x86.conditional as conditional
import reil.x86.memory as memory
import reil.x86.operand as operand
from reil.x86.utilities import *
from pyreil.x86 import memory
from pyreil.x86 import operand
from pyreil.x86.utilities import *

def unpack(ctx, value, size):
parts = []
Expand Down Expand Up @@ -331,4 +324,4 @@ def x86_pxor(ctx, i):

ctx.emit( xor_ (a, b, value))

operand.set(ctx, i, 0, value)
operand.set(ctx, i, 0, value)
Loading