Browse Source

Push obfuscator code

Signed-off-by: Martmists <martmists@gmail.com>
master
Martmists 1 year ago
parent
commit
56c0e94f27
Signed by: Martmists
GPG Key ID: 7D2B8D61D42E41E4
  1. 2
      obfuscator/deobf/hello_world.py
  2. 2
      obfuscator/deobf/inner_func.py
  3. 3
      obfuscator/deobf/sort.py
  4. 32
      obfuscator/deobf/tictactoe.py
  5. 2
      obfuscator/obf/fibonacci.py
  6. 2
      obfuscator/obf/hello_world.py
  7. 2
      obfuscator/obf/inner_func.py
  8. 8
      obfuscator/obf/sort.py
  9. 17
      obfuscator/obf/tictactoe.py
  10. 1
      obfuscator/obfuscator.py
  11. 13
      obfuscator/visitors/name_minifier.py
  12. 10
      obfuscator/visitors/string_obfuscator.py

2
obfuscator/deobf/hello_world.py

@ -1 +1 @@ @@ -1 +1 @@
print(r"Hello world!")
print("Hello world!")

2
obfuscator/deobf/inner_func.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
def hello(x):
def print_():
print(f"Hello, {x}")
print("Hello, " + x)
return print_

3
obfuscator/deobf/sort.py

@ -14,7 +14,8 @@ def selection_sort(items): @@ -14,7 +14,8 @@ def selection_sort(items):
@no_minify
def quick_sort(array, start, end):
def quick_sort(array, start=0, end=0):
end = end or len(array) - 1
if start >= end:
return
else:

32
obfuscator/deobf/tictactoe.py

@ -26,15 +26,15 @@ def check(pos): @@ -26,15 +26,15 @@ def check(pos):
return board[col]
# horizontal
elif board[row] == board[row + 1] == board[row + 1]:
elif board[row] == board[row + 1] == board[row + 2]:
return board[row]
# diagonal
elif pos & 1:
if board[1] == board[5] == board[9]:
return board[5]
elif board[3] == board[5] == board[7]:
return board[5]
elif not (pos & 1):
if board[0] == board[4] == board[8]:
return board[4]
elif board[2] == board[4] == board[6]:
return board[4]
else:
return 0
@ -50,11 +50,11 @@ def print_board(): @@ -50,11 +50,11 @@ def print_board():
return [index, "X", "O"][board[index]]
for x in range(3):
print(b) or 1
print("".join([f"{f(x * 3):^3}", f"{f(x * 3 + 1):^3}", f"{f(x * 3 + 2):^3}"])) or 1
print(b) or 1
print(b)
print("".join([f"{f(x * 3):^3}", f"{f(x * 3 + 1):^3}", f"{f(x * 3 + 2):^3}"]))
print(b)
if x < 2:
print(hdiv) or 1
(print(hdiv),)
def main():
@ -69,24 +69,24 @@ def main(): @@ -69,24 +69,24 @@ def main():
choice = int(inp)
if 0 <= choice <= 8:
if board[choice]:
print("Spot already taken!")
(print("Spot already taken!"),)
else:
board[choice] = p
winner = check(choice)
c += 1
p = 3 - p
else:
print("Invalid answer!") or 1
(print("Invalid answer!"),)
try_(test, d=lambda: print("Invalid answer!") or 1, e=ValueError)
try_(test, f=lambda: (print("Invalid answer!"),), e=ValueError)
print_board()
if winner == 0:
print("Draw!") or 1
(print("Draw!"),)
else:
print(f"Winner: Player {winner}") or 1
(print(f"Winner: Player {int(winner)}"),)
if __name__ == '__main__':
print("Tic Tac Toe by Martmists") or 1
print("Tic Tac Toe by Martmists")
main()

2
obfuscator/obf/fibonacci.py

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
# Generated by Mart Obfuscator
a=lambda b:b<([]==[])<<(()>=())and()==()or a(b-([]==[]))+a(b-((()>=())<<(()==())))
a=lambda b:b<(()<=())<<([]==[])and()==()or a(b-(()==()))+a(b-((()==())<<([]==[])))

2
obfuscator/obf/hello_world.py

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
# Generated by Mart Obfuscator
print('%c'*(([]>=[])<<((()>=())<<([]==[]))+(()>=())|([]>=[])<<(([]==[])<<([]==[])))%((()==())<<(([]<=[])<<((()==())<<(()==()))|([]<=[])<<(()>=()))|(()==())<<((()>=())<<(()==()))+(()>=()),(([]<=[])<<(([]==[])<<(([]==[])<<(()<=())))+(([]==[])<<(()<=()))|([]<=[])<<(([]==[])<<((()==())<<([]<=[])))+([]==[]))+(([]<=[])<<(([]<=[])<<(()==())))|([]<=[]),((([]==[])<<((()<=())<<((()==())<<(()>=())))+((()<=())<<([]>=[])))+(([]==[])<<(([]>=[])<<(([]<=[])<<(()<=())))+([]>=[]))|([]==[])<<(([]<=[])<<(()==()))+([]<=[]))+(([]==[])<<(([]<=[])<<([]==[]))),(([]==[])<<(([]<=[])<<((()==())<<([]==[]))|([]<=[])<<([]==[]))|([]==[])<<(([]==[])<<((()<=())<<(()==())))+([]==[]))+(([]==[])<<(([]<=[])<<([]<=[]))+([]<=[]))+(([]==[])<<(([]>=[])<<(()<=()))),((()>=())<<((()>=())<<(([]<=[])<<(()==())))+((()>=())<<([]==[])))+((()>=())<<((()>=())<<(([]<=[])<<(()<=()))|(()>=())))+((()>=())<<((()==())<<([]<=[])|(()==())))+((()>=())<<(([]==[])<<(()<=())))+((()>=())<<([]==[]))|(()>=()),([]<=[])<<(([]==[])<<((()>=())<<([]==[])))+([]==[]),(((()<=())<<((()<=())<<(([]==[])<<([]==[])))+((()<=())<<(()<=()))|(()<=())<<((()==())<<((()<=())<<(()==())))+(()==()))+((()<=())<<(([]>=[])<<(([]>=[])<<(()<=()))))+((()<=())<<((()<=())<<(()>=())))|(()<=())<<([]<=[]))+(()<=()),((()<=())<<(([]<=[])<<((()==())<<([]>=[]))|([]<=[])<<(()>=()))|(()<=())<<((()<=())<<(([]<=[])<<(()>=()))|(()<=()))|(()<=())<<((()==())<<(()>=()))+(()==())|(()<=())<<(([]>=[])<<([]<=[])))+((()<=())<<([]==[]))+(()<=()),((()==())<<(([]<=[])<<(([]==[])<<([]>=[])))+(([]<=[])<<([]>=[]))|(()==())<<((()>=())<<(([]==[])<<([]>=[]))|(()>=())))+((()==())<<((()>=())<<(([]>=[])<<([]>=[]))))+((()==())<<([]==[])),((()<=())<<(([]==[])<<(([]>=[])<<([]>=[])))+(([]==[])<<(()>=()))|(()<=())<<(([]==[])<<(([]==[])<<(()==())))+([]==[]))+((()<=())<<((()>=())<<([]>=[]))+(()>=()))|(()<=())<<((()>=())<<(()<=())),((()==())<<(([]<=[])<<(([]>=[])<<([]==[])))+(([]<=[])<<([]<=[])))+((()==())<<(([]<=[])<<(([]==[])<<(()==()))|([]<=[])))+((()==())<<((()==())<<([]>=[]))),(([]<=[])<<(([]<=[])<<(([]>=[])<<([]>=[]))|([]<=[])))+([]<=[])))
print('%c'*(([]<=[])<<((()==())<<([]>=[]))+(()==())|([]<=[])<<(([]<=[])<<(()>=())))%((([]==[])<<(([]==[])<<((()>=())<<([]>=[])))+(([]==[])<<(()==())))+(([]==[])<<((()>=())<<([]==[]))+(()>=())),((()>=())<<(([]>=[])<<((()==())<<([]>=[])))+(([]>=[])<<([]<=[])))+((()>=())<<((()<=())<<(([]<=[])<<(()>=())))+(()<=()))+((()>=())<<(([]==[])<<([]>=[])))|(()>=()),((()>=())<<(([]>=[])<<(([]<=[])<<(()==()))|([]>=[])<<(()==()))|(()>=())<<((()<=())<<(([]>=[])<<([]>=[]))|(()<=()))|(()>=())<<(([]>=[])<<([]>=[]))+([]>=[]))+((()>=())<<(([]<=[])<<([]>=[]))),(([]==[])<<((()<=())<<((()<=())<<(()==()))|(()<=())<<(()==()))|([]==[])<<((()<=())<<((()>=())<<([]==[])))+(()<=()))+(([]==[])<<((()>=())<<(()==())|(()>=())))|([]==[])<<(([]<=[])<<([]<=[])),(([]>=[])<<((()>=())<<(([]>=[])<<(()==()))|(()>=())<<(()>=()))|([]>=[])<<(([]<=[])<<(([]==[])<<([]<=[])))+([]<=[])|([]>=[])<<(([]==[])<<(()<=()))+([]==[])|([]>=[])<<((()<=())<<([]==[]))|([]>=[])<<(()<=()))+([]>=[]),(()==())<<((()>=())<<((()>=())<<(()>=()))|(()>=())),((()<=())<<(([]<=[])<<((()>=())<<([]<=[])))+(([]<=[])<<([]<=[]))|(()<=())<<(([]<=[])<<(([]==[])<<([]>=[])))+([]<=[]))+((()<=())<<(([]==[])<<(([]>=[])<<(()==()))))|(()<=())<<((()<=())<<([]==[]))|(()<=())<<([]>=[])|(()<=()),((([]==[])<<((()>=())<<(([]<=[])<<([]==[])))+((()>=())<<(()==())))+(([]==[])<<(([]<=[])<<(([]<=[])<<(()==())))+([]<=[]))+(([]==[])<<((()<=())<<(()>=())|(()<=())))|([]==[])<<((()>=())<<([]>=[])))+(([]==[])<<(()==()))|([]==[]),((()<=())<<((()>=())<<(([]<=[])<<([]<=[]))|(()>=())<<(()<=())))+((()<=())<<((()>=())<<((()>=())<<(()>=()))|(()>=())))+((()<=())<<((()<=())<<(([]>=[])<<(()==()))))|(()<=())<<(()>=()),(([]<=[])<<((()==())<<((()>=())<<([]==[])))+((()==())<<([]>=[])))+(([]<=[])<<(([]<=[])<<(([]>=[])<<([]>=[])))+([]<=[]))+(([]<=[])<<(([]==[])<<(()<=())|([]==[])))+(([]<=[])<<(([]>=[])<<([]==[]))),(([]==[])<<((()>=())<<(([]>=[])<<(()==())))+((()>=())<<(()<=()))|([]==[])<<((()==())<<((()>=())<<(()<=())))+(()==()))+(([]==[])<<((()>=())<<(()<=()))),(([]<=[])<<(([]==[])<<((()<=())<<([]<=[])))+([]==[]))+([]<=[])))

2
obfuscator/obf/inner_func.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
# Generated by Mart Obfuscator
a=[0]
b=lambda c:(a.__setitem__([]is(),lambda:print(f'Hello, {c}')),a[()is()])[-([]<=[])]
b=lambda c:(getattr(a,'%c'*((([]>=[])<<((()==())<<(()<=())|(()==())))+(([]>=[])<<([]<=[]))|([]>=[]))%(((()==())<<((()<=())<<(([]==[])<<([]>=[])))+((()<=())<<(()==()))|(()==())<<((()>=())<<((()==())<<(()>=())))|(()==())<<(([]==[])<<(()<=())|([]==[])))+((()==())<<(([]<=[])<<(()>=())))+((()==())<<(()==()))|(()==()),((()==())<<((()<=())<<(([]>=[])<<(()>=())))+((()<=())<<(()==()))|(()==())<<(([]>=[])<<(([]==[])<<(()<=()))))+((()==())<<((()==())<<(()>=())|(()==())))+((()==())<<(([]<=[])<<(()==())))|(()==())<<(()<=())|(()==()),((()>=())<<((()>=())<<((()<=())<<([]<=[]))|(()>=())<<([]<=[]))|(()>=())<<(([]<=[])<<(([]<=[])<<(()==())))+([]<=[]))+((()>=())<<((()<=())<<(([]<=[])<<([]<=[]))))|(()>=())<<(()>=())|(()>=()),(([]>=[])<<((()>=())<<(([]<=[])<<(()>=()))|(()>=())<<(()<=())))+(([]>=[])<<(([]<=[])<<(([]==[])<<(()==())))+([]<=[]))+(([]>=[])<<(([]<=[])<<(()<=())))|([]>=[]),(([]<=[])<<((()<=())<<(([]>=[])<<(()<=())))+((()<=())<<([]==[])))+(([]<=[])<<(([]<=[])<<((()<=())<<([]>=[])))+([]<=[]))+(([]<=[])<<(([]>=[])<<((()==())<<(()<=()))))+(([]<=[])<<((()<=())<<([]<=[]))),(((()<=())<<((()==())<<(([]>=[])<<(()==()))|(()==())<<([]==[])))+((()<=())<<((()==())<<(([]>=[])<<([]==[]))|(()==())))|(()<=())<<((()<=())<<(()==())|(()<=())))+(()<=()),(([]==[])<<((()==())<<((()>=())<<(()<=())))+((()==())<<([]<=[])))+(([]==[])<<((()<=())<<(([]==[])<<(()>=())))+(()<=()))+(([]==[])<<(([]==[])<<(([]>=[])<<([]<=[]))))|([]==[])<<(([]>=[])<<(()<=())),((()<=())<<((()>=())<<((()==())<<([]<=[]))|(()>=())<<([]==[])))+((()<=())<<((()>=())<<(([]<=[])<<(()>=())))+(()>=()))+((()<=())<<(([]>=[])<<(()>=())))+(()<=()),((()==())<<((()>=())<<((()==())<<(()==())))+((()>=())<<([]==[]))|(()==())<<(([]>=[])<<(([]>=[])<<([]==[])))+([]>=[])|(()==())<<((()<=())<<([]==[])|(()<=()))|(()==())<<((()<=())<<(()<=())))+(()==()),(((()<=())<<(([]<=[])<<((()>=())<<(()<=()))|([]<=[])<<(()==())))+((()<=())<<((()<=())<<((()==())<<(()>=()))))+((()<=())<<((()==())<<([]==[]))+(()==()))|(()<=())<<(([]==[])<<([]<=[])))+((()<=())<<(()<=()))+(()<=()),((()==())<<(([]<=[])<<(([]==[])<<(()<=())))+(([]<=[])<<(()==())))+((()==())<<((()>=())<<((()==())<<(()<=()))))+((()==())<<(([]<=[])<<([]<=[]))+([]<=[]))+((()==())<<((()==())<<([]==[])))+((()==())<<([]==[]))+(()==())))(()<(),lambda:print('%c'*(((()==())<<(([]==[])<<([]>=[]))|(()==())<<(()==()))+(()==()))%((([]==[])<<(([]>=[])<<((()==())<<(()==())))+(([]>=[])<<([]==[])))+(([]==[])<<(([]>=[])<<(()>=())|([]>=[]))),(([]<=[])<<(([]>=[])<<(([]==[])<<(()==()))|([]>=[])<<(()<=()))|([]<=[])<<(([]==[])<<((()>=())<<([]==[])))+([]==[]))+(([]<=[])<<((()==())<<(()==())))|([]<=[]),(([]==[])<<(([]>=[])<<(([]>=[])<<([]==[])))+(([]>=[])<<(()>=())))+(([]==[])<<((()<=())<<(([]==[])<<(()<=()))|(()<=())))+(([]==[])<<(([]<=[])<<([]==[])|([]<=[])))|([]==[])<<(([]==[])<<([]==[])),((()==())<<((()<=())<<((()==())<<(()<=())))+((()<=())<<([]>=[]))|(()==())<<((()>=())<<((()>=())<<([]<=[]))|(()>=()))|(()==())<<(([]<=[])<<(()>=()))+([]<=[]))+((()==())<<(([]<=[])<<([]==[]))),(([]==[])<<((()==())<<(([]>=[])<<(()>=())))+((()==())<<([]<=[]))|([]==[])<<(([]==[])<<((()>=())<<(()>=()))|([]==[])))+(([]==[])<<(([]==[])<<([]<=[]))+([]==[]))|([]==[])<<(([]==[])<<([]>=[]))|([]==[])<<([]==[])|([]==[]),((()==())<<(([]<=[])<<((()>=())<<([]==[])))+([]<=[]))+((()==())<<((()==())<<(()>=()))+(()==()))|(()==())<<(([]<=[])<<([]==[])),([]==[])<<(([]<=[])<<(([]==[])<<([]<=[])))+([]<=[]))+c)),a[()<()])[-([]>=[])]

8
obfuscator/obf/sort.py

File diff suppressed because one or more lines are too long

17
obfuscator/obf/tictactoe.py

File diff suppressed because one or more lines are too long

1
obfuscator/obfuscator.py

@ -23,6 +23,7 @@ def trim_whitespace(source: str) -> str: @@ -23,6 +23,7 @@ def trim_whitespace(source: str) -> str:
source = sub_unquoted(r"(and|or|for|in|is|not) ([\[\]\(\)\{\}'\"-])", r"\1\2", source)
source = sub_unquoted(r"\s*(>=|!=|<=|>|<|=|-|\+|\*|:|,|%|/|\||@|\^|&)\s*", r"\1", source)
source = sub_unquoted(r"-1\*([^-])", r"-\1", source)
source = sub_unquoted(r"\(\n", r"(", source)
return source

13
obfuscator/visitors/name_minifier.py

@ -62,6 +62,19 @@ class NameMinifierTransformer(AstTransformer): @@ -62,6 +62,19 @@ class NameMinifierTransformer(AstTransformer):
lineno=node.lineno
)
def visit_Attribute(self, node: Attribute) -> Any:
return Call(
Name("getattr"),
[self.visit(node.value), Str(node.attr)],
[]
)
def visit_keyword(self, node: keyword) -> Any:
return keyword(
self.minify(node.arg) if node.arg else node.arg,
self.visit(node.value)
)
def visit_arg(self, node: arg) -> Any:
return arg(
self.minify(node.arg),

10
obfuscator/visitors/string_obfuscator.py

@ -18,10 +18,10 @@ class StringObfuscator(AstTransformer): @@ -18,10 +18,10 @@ class StringObfuscator(AstTransformer):
Compare(left=lst, ops=[Gt()], comparators=[lst]),
Compare(left=tup, ops=[Lt()], comparators=[tup]),
Compare(left=lst, ops=[Lt()], comparators=[lst]),
Compare(left=tup, ops=[Is()], comparators=[tup]),
Compare(left=lst, ops=[Is()], comparators=[lst]),
Compare(left=tup, ops=[Is()], comparators=[lst]),
Compare(left=lst, ops=[Is()], comparators=[tup]),
# Compare(left=tup, ops=[Is()], comparators=[tup]),
# Compare(left=lst, ops=[Is()], comparators=[lst]),
# Compare(left=tup, ops=[Is()], comparators=[lst]),
# Compare(left=lst, ops=[Is()], comparators=[tup]),
])
one = random.choice([
Compare(left=tup, ops=[Eq()], comparators=[tup]),
@ -57,8 +57,6 @@ class StringObfuscator(AstTransformer): @@ -57,8 +57,6 @@ class StringObfuscator(AstTransformer):
])
current = BinOp(left=current, op=op, right=next_)
print(dump(current))
return BinOp(left=Constant(value=-1), op=Mult(), right=current) if sign < 0 else current
def visit_JoinedStr(self, node: JoinedStr) -> Any:

Loading…
Cancel
Save