forked from Bashfuscator/Bashfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_mutator_test.py
More file actions
executable file
·37 lines (28 loc) · 1.19 KB
/
single_mutator_test.py
File metadata and controls
executable file
·37 lines (28 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
"""
Stress tests a single Mutator
"""
from datetime import datetime
import os
import pytest
from subprocess import STDOUT, PIPE, Popen
from bashfuscator.core.obfuscation_handler import ObfuscationHandler
if __name__ == "__main__":
mutatorName = "string/xor_non_null"
inputCommand = "echo 'It works!'"
expectedOutput = "It works!\n"
obHandler = ObfuscationHandler()
try:
for i in range(1000):
payload = obHandler.genObfuscationLayer(inputCommand, userMutator=mutatorName)
proc = Popen(payload, executable="bash", stdout=PIPE, stderr=STDOUT, shell=True, universal_newlines=True)
payloadOutput, __ = proc.communicate()
assert(expectedOutput == payloadOutput)
except AssertionError:
if not os.path.exists("failing"):
os.mkdir("failing")
date = datetime.now()
timestamp = str(date.month) + "." + str(date.day) + "." + str(date.year) + "-" + str(date.hour) + "." + str(date.minute) + "." + str(date.second)
with open("failing/" + mutatorName.replace("/", ".") + "-" + timestamp + ".sh", "w") as errorFile:
errorFile.write(payload)
raise