QQuick / Opy

Obfuscator for Python
Other
362 stars 61 forks source link

Bug: syntax error in obfuscated code when using multi-line string literals #23

Open janluke opened 6 years ago

janluke commented 6 years ago

Code to replicate the issue:

print("This is a very very very long string argument "
      "splitted in two lines to demonstrate a bug")

or even:

s = ("This is a very very very long string argument "
     "splitted in two lines to demonstrate a bug")
print(s)

This is valid Python code. After obfuscation, the code contains a syntax error:

File "../code_opy/test.py", line 18
    l1l1lll1_opy_ (u"ࠨࡳࡱ࡮࡬ࡸࡹ࡫ࡤࠡ࡫ࡱࠤࡲࡵࡲࡦࠢ࡯࡭ࡳ࡫ࡳࠣࡤ"))
                ^
SyntaxError: invalid syntax

The same happens putting "\" at the end of every line.

JdeH commented 6 years ago

I am not sure I can make Opy's simplistic parser understand this. But I'll look into it. Thanks for the feedback!

JdeH commented 6 years ago

Still no good solution to this. Haven't completely given up, though.

hiccuplp commented 12 months ago

I found a similar question:

name = 'Eric' print(f'Hello, my name is {name}')

This is valid Python code. After obfuscation, the code contains a syntax error:

name = l11l1opy (u"ࠫࡊࡸࡩࡤࠩࠀ") print(l11llopy (u"ࠬࡎࡥ࡭࡮ࡲ࠰ࠥࡳࡹࠡࡰࡤࡱࡪࠦࡩࡴࠢࡾࡲࡦࡳࡥࡾࠩࠁ"))

cause a error:

print(l11llopy (u"ࠬࡎࡥ࡭࡮ࡲ࠰ࠥࡳࡹࠡࡰࡤࡱࡪࠦࡩࡴࠢࡾࡲࡦࡳࡥࡾࠩࠁ")) NameError: name 'l11llopy' is not defined