Obfuscate python code online

Python obfuscator online
(as a web form)
Seriously, this form is offline because python 2.4 is kind of old to support nowadays. Sorry!

This web form obfuscates your one-file Python program or module within seconds. It is based on a limited version of the larger-scale BitBoost Python obfuscator, which obfuscates much more complicated programs or packages.

It achieves NON-1:1 mapping of identifiers within your program to obfuscated identifiers. For example, not only is ‘self’ no longer ‘self’, but ‘self’ is generally replaced by a variety of different gibberish identifiers, without impairing program functionality.

Docstrings and comments are also removed.

  • Obfuscates single module/file of limited size.
  • Python 2.4 language features and libraries (Later versions of Python require the full version of the obfuscator.)
  • Most standard library modules, specifically, about all that are:
    • sufficiently cross-platform to be present in both Unix and Windows versions of typical builds of Python.

    Please paste your source code into the box below.

    12345678901234567890123456789012345678901234567890123456789012345678901234567890 1 2 3 4 5 6 7 8

    Names to specially spare from obfuscation (but obfuscator should automatically spare most names that are imported from non-obfuscated libraries etc.) :

    WARNING! Because a table of the main obfuscated identifiers is appended to the demo’s output, you should remove that table before you use the obfuscated code!

    I would appreciate your feedback about this online obfuscator. Perhaps you would even like to license a more complete version of my obfuscator toolkit?

    Technical Commentary


    Limits on handling of keyword arguments

    Correctly obfuscating python code that includes function or method calls with keyword arguments can have interesting complications.

    That full range of options is not included in this free web form demo version.

    You could read the explanation in the manual of the more full-featured python obfuscator, or you could read the shorter example below.

    Suppose the keyword arguments are going into a dictionary, as in this example code from Guido van Rossum’s Python Tutorial (Release 2.4.2) wherein the dictionary is named «keywords» .

    def cheeseshop(kind, *arguments, **keywords): print "-- Do you have any", kind, '?' print "-- I'm sorry, we're all out of", kind for arg in arguments: print arg print '-'*40 keys = keywords.keys() keys.sort() for kw in keys: print kw, ':', keywords[kw] cheeseshop('Limburger', "It's very runny, sir.", "It's really very, VERY runny, sir.", client='John Cleese', shopkeeper='Michael Palin', sketch='Cheese Shop Sketch')
    -- Do you have any Limburger ? -- I'm sorry, we're all out of Limburger It's very runny, sir. It's really very, VERY runny, sir. ---------------------------------------- client : John Cleese shopkeeper : Michael Palin sketch : Cheese Shop Sketch

    The latter part of the output would be totally ruined if we simply obfuscate the keyword argument names, which would change the words ‘client’, ‘shopkeeper’ and ‘sketch’.

    &copy Copyright 2002-2012 by Chris Niswander. All Rights Reserved.

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    Transform regular Python code into a human-averse, yet still-functional equivalent.

    License

    brandonasuncion/Python-Code-Obfuscator

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    I was browsing /r/dailyprogrammer on Reddit one day, and attempted one of the daily challenges. After doing the challenge, I read through the comments and found a very interesting submission.

    Seeing that baffled me at first sight, but after reading /u/ntxhhf’s breakdown of his code, I was inspired to make my own code obfuscator for Python using the ideas in his post.

    What exactly does this script do?
    It takes your regular-looking Python code, and obfuscates it! It takes any specified Python script, and will attempt to create an equivalent script that has the same exact functionality as the original, but is incredibly difficult for humans to read regularly.

    So. how is this useful?
    According to Wikipedia.

    Programmers may deliberately obfuscate code to conceal its purpose (security through obscurity) or its logic or implicit values embedded in it, primarily, in order to prevent tampering, deter reverse engineering, or even as a puzzle or recreational challenge for someone reading the source code.

    Input: Using Netwon’s Method to find the square root of 17

    n = 17; x = 1 for i in range(100): x = x - ((x**2 - n) / (2*x)) print(x)
    __=((()==[])+(()==[]));___=(__**__);____=((______));_____=((____(__**__)));______=((_____(__**__))); _________=((________));__________=((((________))(__**__)));_=((__**__)+(______(__**__)));_______=(__**__) for ________ in range((_____+(_________(__**__))+(__________(__**__)))): _______=_______-((_______**((______))-_)/(((______))*_______)) print(_______)

    There are two ways the parser can encrypt strings. The first way is with hex strings, and the other using the number encoding method above.

    Example Input: print(«Hello World!»)

    _=((()==[])+(()==[]));__=(_**_);___=((____));____=((___(_**_)));_____=((______));______=((_____(_**_))); _______=str(''.join(chr(__RSV) for __RSV in [((____(_**_))+(______(_**_))),((_**_)+____+______+(((_____(_**_)))(_**_))), (____+(((___(_**_)))(_**_))+______+(((_____(_**_)))(_**_))),(____+(((___(_**_)))(_**_))+______+(((_____(_**_)))(_**_))), ((_**_)+___+____+(((___(_**_)))(_**_))+______+(((_____(_**_)))(_**_))),((_____(_**_))),((_**_)+___+____+_____+(((_____(_**_)))(_**_))), ((_**_)+___+____+(((___(_**_)))(_**_))+______+(((_____(_**_)))(_**_))),(___+_____+______+(((_____(_**_)))(_**_))), (____+(((___(_**_)))(_**_))+______+(((_____(_**_)))(_**_))),(____+______+(((_____(_**_)))(_**_))),((_**_)+______)])) print(_______)

    Hiding Calls to Python’s Built-In Functions

    In Python, we can call a built-in function indirectly: getattr(__import__(‘builtins’), ‘abs’)(5)
    So to call a function, we just use the string-encoding method detailed above. It’s definitely not space-efficient, but it works!

    Input: print(chr(65))

    _=((()==[])+(()==[]));__=(_**_);___=((____));____=((___(_**_))); _____=((____(_**_)));______=((_____(_**_)));_______=((((_____(_**_)))(_**_))); ________=str(''.join(chr(__RSV) for __RSV in [((____)+(______(_**_))+(_______(_**_))), ((_**_)+____+______+_______+(((((_____(_**_)))(_**_)))(_**_))), ((_**_)+_____+_______+(((((_____(_**_)))(_**_)))(_**_))),(____+_____+_______+(((((_____(_**_)))(_**_)))(_**_))), (____+______+_______+(((((_____(_**_)))(_**_)))(_**_))),((_**_)+_____+_______+(((((_____(_**_)))(_**_)))(_**_))), (___+____+_____+_______+(((((_____(_**_)))(_**_)))(_**_))),((_**_)+___+______+_______+(((((_____(_**_)))(_**_)))(_**_)))])); _________=str(''.join(chr(__RSV) for __RSV in [(______+_______+(((((_____(_**_)))(_**_)))(_**_))), (___+______+_______+(((((_____(_**_)))(_**_)))(_**_))),((_**_)+_____+_______+(((((_____(_**_)))(_**_)))(_**_))), (___+____+_____+_______+(((((_____(_**_)))(_**_)))(_**_))),(____+______+_______+(((((_____(_**_)))(_**_)))(_**_)))])); __________=str(''.join(chr(__RSV) for __RSV in [((_**_)+___+_______+(((((_____(_**_)))(_**_)))(_**_))), (_____+_______+(((((_____(_**_)))(_**_)))(_**_))),(___+______+_______+(((((_____(_**_)))(_**_)))(_**_)))])) getattr(__import__(________), _________)(getattr(__import__(________), __________)(((_**_)+(((((_____(_**_)))(_**_)))(_**_)))))
    usage: obfuscator.py [-h] [--debug] inputfile outputfile positional arguments: inputfile Name of the input file outputfile Name of the output file optional arguments: -h, --help show this help message and exit --debug Show debug info 
    • Should I use this for distributing my source code?
      As of the time I’m writing this, I highly recommend against that idea. There are some instances of code in that the parser cannot handle (multi-line strings, for instance). Also, the output really won’t do much to prevent reverse-engineering.
    • The output is too big! How do I reduce the output size?
      As of right now, the biggest impact is the inefficiency of encoding strings. For the smallest output, make sure to set the following constants in the script:
    USE_HEXSTRINGS = True OBFUSCATE_BUILTINS = False REMOVE_COMMENTS = True 
    • Brandon Asuncion — Code
      Questions/Comments? Feel free to contact me at: me@brandonasuncion.tech
    • /u/ntxhhf — For the idea, and his breakdown of using lists/sets to create boolean values and integers

    About

    Transform regular Python code into a human-averse, yet still-functional equivalent.

    Источник

    Читайте также:  Python отслеживание появления файла
Оцените статью