×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    158

    Obfuscate python code

    Create a SIS file does not prevent users from viewing the source code (the python code can be found somewhere in the installation directory). Is there a way I can obfuscate the source code in a SIS file?

  2. #2
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Obfuscate python code

    You could compile your code into bytecode (.pyc files). It doesn't obfuscate it as well as on most other languages, but it's at least something.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Obfuscate python code

    Hello ,

    Decompyle can decompile .pyc file !
    But try this open source project pyobfuscator !
    http://freshmeat.net/projects/pyobfuscate/

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    158

    Re: Obfuscate python code

    pyobfuscate is nice, but it doesn't make the code completely unreadable. Isn't the pyc route safer?

  5. #5
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    295

    Re: Obfuscate python code

    bercobeute, the pyobfuscate makes decompiled source harder to read.

    But anyway, usually there is no point to worry about this. Even if you develop in java or c++, people can decompile and see your algorithms.

    I suggest that you distribute .pyo files. If somebody decompiles them, they won't see the comments nor docstrings. This gives about the same level of protection as distributing java or c++ programs (well, python readibility helps to reverse-engineer, so maybe it is bit easier with python).

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    Quote Originally Posted by cyke64 View Post
    Hello ,

    Decompyle can decompile .pyc file !
    But try this open source project pyobfuscator !
    http://freshmeat.net/projects/pyobfuscate/
    could someone help me on how to install and use this project please?
    i got this error while installing it

    C:\pyobfuscate>setup.py install
    running install
    running build
    running install_data
    Traceback (most recent call last):
    File "C:\pyobfuscate\setup.py", line 17, in <module>
    data_files=[('/usr/bin', ['pyobfuscate'])]
    File "C:\Python25\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
    File "C:\Python25\lib\distutils\dist.py", line 974, in run_comm
    self.run_command(cmd)
    File "C:\Python25\lib\distutils\dist.py", line 994, in run_comm
    cmd_obj.run()
    File "C:\Python25\lib\distutils\command\install.py", line 510,
    self.run_command(cmd_name)
    File "C:\Python25\lib\distutils\cmd.py", line 333, in run_comma
    self.distribution.run_command(command)
    File "C:\Python25\lib\distutils\dist.py", line 994, in run_comm
    cmd_obj.run()
    File "C:\Python25\lib\distutils\command\install_data.py", line
    dir = convert_path(f[0])
    File "C:\Python25\lib\distutils\util.py", line 138, in convert_
    raise ValueError, "path '%s' cannot be absolute" % pathname
    ValueError: path '/usr/bin' cannot be absolute

  7. #7
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Obfuscate python code

    Hello Hope

    Easy ! Comment line with data_files= in setup.py
    Code:
    setup install
    
    pyobfuscate
    
    pyobfuscate ex1.py >ex1_hidden.py
    Result :
    Code:
    import appuifw
    import e32
    import telephone
    if 64 - 64: i11iIiiIii
    if 65 - 65: O0 / iIii1I11I1II1 % OoooooooOO - i1IIi
    appuifw . app . title = u'Incoming call Test'
    if 73 - 73: II111iiii
    def IiII1IiiIiI1 ( state ) :
     appuifw . note ( u"Chiamato" , "info" )
     if 40 - 40: oo * OoO0O00
    def IIiIiII11i ( state ) :
     appuifw . note ( unicode ( '0:' + str ( state [ 0 ] ) + ';1:' + str ( state [ 1 ] ) ) , "info" )
     if ( state [ 0 ] == telephone . EStatusRinging ) :
      IiII1IiiIiI1 ( state )
      if 51 - 51: oOo0O0Ooo * I1ii11iIi11i
      if 48 - 48: oO0o / OOooOOo / I11i / Ii1I
    def quit ( ) :
     IiiIII111iI . signal ( )
     if 34 - 34: iii1I1I / O00oOoOoO0o0O . O0oo0OO0 + Oo0ooO0oo0oO . I1i1iI1i - II
    appuifw . app . exit_key_handler = quit
    IiiIII111iI = e32 . Ao_lock ( )
    if 100 - 100: i1IIi . I1i1iI1i / Oo0ooO0oo0oO * OoooooooOO + iii1I1I * I11i
    telephone . call_state ( IIiIiII11i )
    #telephone.incoming_call()
    if 99 - 99: O0oo0OO0 . Ii1I / iIii1I11I1II1 * iIii1I11I1II1
    IiiIII111iI . wait ( )
    Have you recognized this code ?

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    hello cyke64,thanks for replying
    i still can't get it ,i'm new to this
    could you explain more please and how to convert .pyc file to .pyo!

  9. #9
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    cyke64 you mean i should add that 1st code to setup.py?
    please explain

  10. #10
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Obfuscate python code

    Quote Originally Posted by h0pe_ View Post
    cyke64 you mean i should add that 1st code to setup.py?
    please explain
    By commenting code I mean add a # character at the beginning of this line in setup.py

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  11. #11
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    Quote Originally Posted by cyke64 View Post
    By commenting code I mean add a # character at the beginning of this line in setup.py

    BR
    Cyke64
    i still can't install it
    here is the setup.py file
    http://rapidshare.com/files/85388473/setup.zip.html
    can you add that code to it?

  12. #12
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Obfuscate python code

    Quote Originally Posted by h0pe_ View Post
    i still can't install it
    here is the setup.py file
    http://rapidshare.com/files/85388473/setup.zip.html
    can you add that code to it?
    Okay I have downloaded your file ...
    The following code works for me ...
    Code:
    #!/usr/bin/env python
    
    DESCRIPTION = """\
    Python source code obfuscator
    """
    
    from distutils.core import setup
    
    setup (name = "pyobfuscate",
           version = "0.3",
           license = "GPL",
           description = "pyobfuscate",
           long_description = DESCRIPTION,
           author = "Peter Astrand",
           author_email = "astrand@cendio.com",
           url = "http://www.lysator.liu.se/~astrand/projects/pyobfuscate/",
           #data_files=[('/usr/bin', ['pyobfuscate'])]
           )
    Do you use M$ windows or Linux or MAC ?

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  13. #13
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    i'm using windows & i always get this error
    File "C:\Python25\lib\distutils\util.py", line 138, in convert_
    raise ValueError, "path '%s' cannot be absolute" % pathname
    ValueError: path '/usr/bin' cannot be absolute
    with the code you posted i got
    running install
    running build
    then nothing happend

  14. #14
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Obfuscate python code

    Quote Originally Posted by h0pe_ View Post
    i'm using windows & i always get this error
    File "C:\Python25\lib\distutils\util.py", line 138, in convert_
    raise ValueError, "path '%s' cannot be absolute" % pathname
    ValueError: path '/usr/bin' cannot be absolute
    with the code you posted i got
    running install
    running build
    then nothing happend
    I'm using also Windows and here's the result of installation :
    Code:
    C:\app\pyobfuscate-0.3>setup install
    running install
    running build
    running install_egg_info
    Removing C:\Python25\Lib\site-packages\pyobfuscate-0.3-py2.5.egg-info
    Writing C:\Python25\Lib\site-packages\pyobfuscate-0.3-py2.5.egg-info
    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  15. #15
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Obfuscate python code

    but i don't have microsoft c++ compiler
    i installed mingw32 then uninstalled it

Similar Threads

  1. Security code bug on 6230!
    By dabII in forum General Development Questions
    Replies: 1
    Last Post: 2005-05-17, 17:21
  2. Fixing a bug in an already obfuscated midlet (no source code) ?
    By SPGremlin in forum Mobile Java General
    Replies: 1
    Last Post: 2004-01-12, 21:52
  3. Replies: 2
    Last Post: 2003-11-09, 14:00
  4. Replies: 0
    Last Post: 2003-09-26, 15:07
  5. Testing HTTP client for Nokia 3650; Looking to share code
    By nawkboy in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-09-10, 15:30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×