summaryrefslogtreecommitdiff
path: root/tests/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-31 20:50:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-31 20:50:15 (GMT)
commitc6bfb7dd499f2aa1d4fb4f39dc3f49cb8801fed2 (patch)
tree748784ea34f532396bc5ff7a12bf792c6dd1e14c /tests/analysis
parent3d4d97da355c0dd90b1e623f452da22894f8cd71 (diff)
Improved loop detection.
Diffstat (limited to 'tests/analysis')
-rw-r--r--tests/analysis/disass/block.py61
-rw-r--r--tests/analysis/disass/jinit_color_converter.binbin0 -> 456 bytes
2 files changed, 60 insertions, 1 deletions
diff --git a/tests/analysis/disass/block.py b/tests/analysis/disass/block.py
index f8e6fe9..9b9d529 100644
--- a/tests/analysis/disass/block.py
+++ b/tests/analysis/disass/block.py
@@ -7,9 +7,12 @@
from chrysacase import ChrysalideTestCase
from pychrysalide.analysis.contents import FileContent
-from pychrysalide.analysis import LoadedBinary
+from pychrysalide.analysis import BinRoutine, LoadedBinary
from pychrysalide.arch import ArchInstruction
+from pychrysalide.arch import vmpa
from pychrysalide.format.elf import ElfFormat
+from pychrysalide.format import FlatFormat
+from pychrysalide.glibext import BinPortion
import os
import sys
@@ -184,3 +187,59 @@ class TestBasicBlocks(ChrysalideTestCase):
loop_count += 1
self.assertEqual(loop_count, 3)
+
+
+ def testOtherLoops(self):
+ """Check situation with some binary codes old troubles."""
+
+ # Malwre e8e1bc048ef123a9757a9b27d1bf53c092352a26bdbf9fbdc10109415b5cadac
+ # Fonction jinit_color_converter de lib/armeabi/libgame.so
+
+ fullname = sys.modules[self.__class__.__module__].__file__
+ filename = os.path.basename(fullname)
+
+ baselen = len(fullname) - len(filename)
+
+ cnt = FileContent(fullname[:baselen] + 'jinit_color_converter.bin')
+ self.assertIsNotNone(cnt)
+
+ fmt = FlatFormat(cnt)
+
+ fmt.set_machine('armv7')
+
+ base = vmpa(0, 0x12a524)
+
+ p = BinPortion(BinPortion.BPC_CODE, base, cnt.size)
+ p.rights = BinPortion.PAC_READ | BinPortion.PAC_EXEC
+
+ fmt.register_user_portion(p)
+
+ fmt.register_code_point(base.virt + 1, True)
+
+ sym = BinRoutine()
+ sym.range = p.range
+
+ fmt.add_symbol(sym)
+
+ binary = LoadedBinary(fmt)
+
+ status = binary.analyze_and_wait()
+ self.assertTrue(status)
+
+ loop_count = 0
+
+ for blk in sym.basic_blocks:
+ for _, dt in blk.destinations:
+ if dt == ArchInstruction.ILT_LOOP:
+ loop_count += 1
+
+ self.assertEqual(loop_count, 3)
+
+ loop_count = 0
+
+ for ins in binary.processor.instrs:
+ for _, dt in ins.destinations:
+ if dt == ArchInstruction.ILT_LOOP:
+ loop_count += 1
+
+ self.assertEqual(loop_count, 3)
diff --git a/tests/analysis/disass/jinit_color_converter.bin b/tests/analysis/disass/jinit_color_converter.bin
new file mode 100644
index 0000000..1eb2715
--- /dev/null
+++ b/tests/analysis/disass/jinit_color_converter.bin
Binary files differ