mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: disable observer in tests
This commit is contained in:
@@ -11,6 +11,7 @@ class Observer():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.logs = []
|
self.logs = []
|
||||||
self.idx = 0
|
self.idx = 0
|
||||||
|
self.active = True
|
||||||
|
|
||||||
def add_text(self, name, data):
|
def add_text(self, name, data):
|
||||||
self.write_to_file(name + ".txt", data)
|
self.write_to_file(name + ".txt", data)
|
||||||
@@ -28,6 +29,8 @@ class Observer():
|
|||||||
self.idx += 1
|
self.idx += 1
|
||||||
|
|
||||||
def write_to_file(self, filename, data):
|
def write_to_file(self, filename, data):
|
||||||
|
if not self.active:
|
||||||
|
return
|
||||||
with open("logs/{}-{}".format(self.idx, filename), "w") as f:
|
with open("logs/{}-{}".format(self.idx, filename), "w") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ import logging
|
|||||||
from phases.compiler import fixup_asm_file, fixup_iat_reuse
|
from phases.compiler import fixup_asm_file, fixup_iat_reuse
|
||||||
from model import ExeInfo
|
from model import ExeInfo
|
||||||
from defs import *
|
from defs import *
|
||||||
|
from observer import observer
|
||||||
|
|
||||||
|
|
||||||
class AsmTest(unittest.TestCase):
|
class AsmTest(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
observer.active = False
|
||||||
|
|
||||||
def test_asm_fixup(self):
|
def test_asm_fixup(self):
|
||||||
path_in: FilePath = "tests/data/peb_walk_pre_fixup.asm"
|
path_in: FilePath = "tests/data/peb_walk_pre_fixup.asm"
|
||||||
path_working: FilePath = "tests/data/peb_walk_pre_fixup.asm.test"
|
path_working: FilePath = "tests/data/peb_walk_pre_fixup.asm.test"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from model import ExeInfo
|
|||||||
from defs import *
|
from defs import *
|
||||||
from pehelper import extract_code_from_exe
|
from pehelper import extract_code_from_exe
|
||||||
from helper import hexdump
|
from helper import hexdump
|
||||||
|
from observer import observer
|
||||||
|
|
||||||
from derbackdoorer.derbackdoorer import PeBackdoor
|
from derbackdoorer.derbackdoorer import PeBackdoor
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ from derbackdoorer.derbackdoorer import PeBackdoor
|
|||||||
# * The call has been patched
|
# * The call has been patched
|
||||||
|
|
||||||
class DerBackdoorerTest(unittest.TestCase):
|
class DerBackdoorerTest(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
observer.active = False
|
||||||
|
|
||||||
def test_backdoor_ep(self):
|
def test_backdoor_ep(self):
|
||||||
# Write example shellcode
|
# Write example shellcode
|
||||||
shellcode_path = "exes/shellcode.test"
|
shellcode_path = "exes/shellcode.test"
|
||||||
|
|||||||
Reference in New Issue
Block a user