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):
|
||||
self.logs = []
|
||||
self.idx = 0
|
||||
self.active = True
|
||||
|
||||
def add_text(self, name, data):
|
||||
self.write_to_file(name + ".txt", data)
|
||||
@@ -28,6 +29,8 @@ class Observer():
|
||||
self.idx += 1
|
||||
|
||||
def write_to_file(self, filename, data):
|
||||
if not self.active:
|
||||
return
|
||||
with open("logs/{}-{}".format(self.idx, filename), "w") as f:
|
||||
f.write(data)
|
||||
|
||||
|
||||
@@ -6,9 +6,14 @@ import logging
|
||||
from phases.compiler import fixup_asm_file, fixup_iat_reuse
|
||||
from model import ExeInfo
|
||||
from defs import *
|
||||
from observer import observer
|
||||
|
||||
|
||||
class AsmTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
observer.active = False
|
||||
|
||||
def test_asm_fixup(self):
|
||||
path_in: FilePath = "tests/data/peb_walk_pre_fixup.asm"
|
||||
path_working: FilePath = "tests/data/peb_walk_pre_fixup.asm.test"
|
||||
|
||||
@@ -7,6 +7,7 @@ from model import ExeInfo
|
||||
from defs import *
|
||||
from pehelper import extract_code_from_exe
|
||||
from helper import hexdump
|
||||
from observer import observer
|
||||
|
||||
from derbackdoorer.derbackdoorer import PeBackdoor
|
||||
|
||||
@@ -21,6 +22,10 @@ from derbackdoorer.derbackdoorer import PeBackdoor
|
||||
# * The call has been patched
|
||||
|
||||
class DerBackdoorerTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
observer.active = False
|
||||
|
||||
def test_backdoor_ep(self):
|
||||
# Write example shellcode
|
||||
shellcode_path = "exes/shellcode.test"
|
||||
|
||||
Reference in New Issue
Block a user