Protecting PHP Code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harold Crump

    #1

    Protecting PHP Code

    Greetings,

    I have a PHP/MySQL application that I am deploying at a client's.

    I am fairly certain that they will steal my source code and re-sell to
    other companies.

    I would like to somehow protect the source code.

    Here are some of the options I have thought about.

    Can someone give me some ideas and feedback about these --

    1. Host the most critical .php file on my own host server, and
    everything else on their's.
    I modify the HTML form elements to submit data to my site (using a
    full URL, rather than a relative one).

    The php file then connects to the database on their server using
    the full host name or IP address.

    After doing the processing, it redirects back to their site.

    This solution is complex, there is a performance impact, cookies won't
    work across sites, and there is a liability issue for me if my host
    server is down and their business stops because of that.

    2. A less complex solution is to rip out some of the key functions
    from the .php files and host them as an include file on my server.
    This way, the cookies will still work as-is, and there is a
    slightly less performance impact.
    But we still have the issue of their site being dependent on mine.

    3. Use an obfuscator that sits between the web server and the PHP
    runtime and encrypts/decrypts the .php files on the fly.

    I have looked at some common obfuscators and they are no good.
    All they do is replace function and variable names with some gibberish,
    but a simple Find/Replace using Notepad can break the obfuscation.

    Can anyone recommend a real obfuscator that is less stupid than the
    person stealing the code?

    4. The last option is to rip out the important functions and put them
    in a C++ DLL and call the DLL from the PHP code.
    This solution appeals to me the most, but means a lot more work for me.

    I don't know much C++, but I know enough to write simple functions.

    But I don't know which C++ to use - like which compilers, etc. so that
    the DLL runs on their environment.
    I think their host is UNIX/Linux based, but not sure which flavour.
    Any help appreciated.

    Thanks,
    Harold.

  • Kevin

    #2
    Re: Protecting PHP Code

    I think a lot of developers overestimate the risk of source code theft.
    However, since you sound certain that your client will resell your code,
    here are some options:

    1.) Legal: Have a lawyer experienced in IP create a license that identifies
    what the client may and may not do with your source. If they "steal" your
    source, you have a legal recourse. This is your best option.
    2.) Turn your license model into an Application Service Provider-- (i.e.,
    you host the application) Be sure your client understands this. They will
    ask what happens if you go out of business or your server crashes.
    3.) Use an encoder like Zend Encoder or Ioncube. The drawbacks of these are
    that not all hosting environments support them.

    - Kevin

    "Harold Crump" <orientletter@y ahoo.com> wrote in message
    news:1104848128 .015768.306920@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    > Greetings,
    >
    > I have a PHP/MySQL application that I am deploying at a client's.
    >
    > I am fairly certain that they will steal my source code and re-sell to
    > other companies.
    >
    > I would like to somehow protect the source code.
    >
    > Here are some of the options I have thought about.
    >
    > Can someone give me some ideas and feedback about these --
    >
    > 1. Host the most critical .php file on my own host server, and
    > everything else on their's.
    > I modify the HTML form elements to submit data to my site (using a
    > full URL, rather than a relative one).
    >
    > The php file then connects to the database on their server using
    > the full host name or IP address.
    >
    > After doing the processing, it redirects back to their site.
    >
    > This solution is complex, there is a performance impact, cookies won't
    > work across sites, and there is a liability issue for me if my host
    > server is down and their business stops because of that.
    >
    > 2. A less complex solution is to rip out some of the key functions
    > from the .php files and host them as an include file on my server.
    > This way, the cookies will still work as-is, and there is a
    > slightly less performance impact.
    > But we still have the issue of their site being dependent on mine.
    >
    > 3. Use an obfuscator that sits between the web server and the PHP
    > runtime and encrypts/decrypts the .php files on the fly.
    >
    > I have looked at some common obfuscators and they are no good.
    > All they do is replace function and variable names with some gibberish,
    > but a simple Find/Replace using Notepad can break the obfuscation.
    >
    > Can anyone recommend a real obfuscator that is less stupid than the
    > person stealing the code?
    >
    > 4. The last option is to rip out the important functions and put them
    > in a C++ DLL and call the DLL from the PHP code.
    > This solution appeals to me the most, but means a lot more work for me.
    >
    > I don't know much C++, but I know enough to write simple functions.
    >
    > But I don't know which C++ to use - like which compilers, etc. so that
    > the DLL runs on their environment.
    > I think their host is UNIX/Linux based, but not sure which flavour.
    > Any help appreciated.
    >
    > Thanks,
    > Harold.
    >[/color]


    Comment

    • Felix

      #3
      Re: Protecting PHP Code

      Dear Mr. Crump,

      Have you considered a non-technical solution?
      I mean, talking to a lawyer and getting your
      clients sign a tough non-dislosure agreement?
      Because if they really want to steal your
      source code, even reverse engineering a DLL
      will not be a problem for them.

      But if you insist, the reference compiler for
      *nix platforms is GCC or, in this case, G++.
      As for portability, application logic code
      should not need to rely on platform-specific
      features. Anyway, GCC ports exist for other
      platforms as well, such as MinGW for Windows.
      Be careful, it's very picky about the standard!

      Hope this helps,
      Felix

      Comment

      • John Bokma

        #4
        Re: Protecting PHP Code

        Harold Crump wrote:
        [color=blue]
        > Greetings,
        >
        > I have a PHP/MySQL application that I am deploying at a client's.
        >
        > I am fairly certain that they will steal my source code and re-sell to
        > other companies.[/color]

        Why did you do business with them in the first place?

        --
        John MexIT: http://johnbokma.com/mexit/
        personal page: http://johnbokma.com/
        Experienced programmer available: http://castleamber.com/
        Happy Customers: http://castleamber.com/testimonials.html

        Comment

        • Harold Crump

          #5
          Re: Protecting PHP Code

          Thanks everyone for the suggestion.
          I have some follow-up questions.
          [color=blue]
          > 1.) Legal: Have a lawyer experienced in IP create a license that[/color]
          identifies[color=blue]
          > what the client may and may not do with your source. If they "steal"[/color]
          your[color=blue]
          > source, you have a legal recourse. This is your best option.[/color]

          I agree, but the problem is how would I know when they steal the code
          and to whom they re-sell it?
          I am writing code for an industry where all the competitors provide
          very similar services and the code would need very little customisation
          when re-sold.

          Some else asked me why am I doing business with them in the first place
          - the answer is that it is a good business opportunity for me, and the
          revenue is needed.

          I can get a lawyer to create a contract agreement like suggested, but I
          have no way of knowing when they will copy the code and re-sell it by
          removing the copyright notices in the source code.

          They have some in-house programmers, who know enough to change some
          variable and function names by doing a global Find/Replace using
          Notepad.

          Even if I find out, I have neither the time nor the money to go after
          them with a lawsuit.

          Someone mentioned the GCC compiler for C++.
          Are there any links and where is it downloadable from?

          I can play with it and see what it would take to rip out some functions
          into a C++ DLL.

          I think there host is running Apache on Linux, but am not sure about
          the versions.
          Would GCC binaries work in this case?

          Thanks,
          Harold.

          Comment

          • John Bokma

            #6
            Re: Protecting PHP Code

            Harold Crump wrote:
            [color=blue]
            > Thanks everyone for the suggestion.
            > I have some follow-up questions.
            >[color=green]
            >> 1.) Legal: Have a lawyer experienced in IP create a license that[/color]
            > identifies[color=green]
            >> what the client may and may not do with your source. If they "steal"[/color]
            > your[color=green]
            >> source, you have a legal recourse. This is your best option.[/color]
            >
            > I agree, but the problem is how would I know when they steal the code
            > and to whom they re-sell it?
            > I am writing code for an industry where all the competitors provide
            > very similar services and the code would need very little
            > customisation when re-sold.[/color]

            Basically you can't protect your code. If you add some "call home"
            option, this is very easy to detect, and very easy to disable.
            [color=blue]
            > Some else asked me why am I doing business with them in the first
            > place - the answer is that it is a good business opportunity for me,
            > and the revenue is needed.[/color]

            So so went for the quick money. From your story it sounds more like a
            bad business opportunity.

            Make them an offer they can't refuse then. Tell them that for every new
            customer they bring to you they get x%, and free support and
            extension(s) on the version they got.
            [color=blue]
            > I can get a lawyer to create a contract agreement like suggested, but
            > I have no way of knowing when they will copy the code and re-sell it
            > by removing the copyright notices in the source code.
            >
            > They have some in-house programmers, who know enough to change some
            > variable and function names by doing a global Find/Replace using
            > Notepad.[/color]

            So why did they hire you in the first place :-D.
            [color=blue]
            > Even if I find out, I have neither the time nor the money to go after
            > them with a lawsuit.
            >
            > Someone mentioned the GCC compiler for C++.
            > Are there any links and where is it downloadable from?[/color]

            You probably have to write your code in C(++) then. Are you able to do
            that?
            [color=blue]
            > I can play with it and see what it would take to rip out some
            > functions into a C++ DLL.[/color]

            Which can be copied. If they want to steal your software, they do it.
            [color=blue]
            > I think there host is running Apache on Linux, but am not sure about
            > the versions.
            > Would GCC binaries work in this case?[/color]

            Think again:

            - you think you are not able to do the lawsuit thing
            - the code can be copied & modified, always (you only can make
            modification a bit harder)

            So why waste more time on this project? Give them the stuff. You are not
            able to track if they stole your code anyway.

            Also, if you want to do business with them, do business with them. Make
            them a good offer.

            --
            John MexIT: http://johnbokma.com/mexit/
            personal page: http://johnbokma.com/
            Experienced programmer available: http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html

            Comment

            • Manuel Lemos

              #7
              Re: Protecting PHP Code

              Hello,

              on 01/04/2005 12:15 PM Harold Crump said the following:[color=blue]
              > I would like to somehow protect the source code.[/color]
              [color=blue]
              > 4. The last option is to rip out the important functions and put them
              > in a C++ DLL and call the DLL from the PHP code.
              > This solution appeals to me the most, but means a lot more work for me.
              >
              > I don't know much C++, but I know enough to write simple functions.
              >
              > But I don't know which C++ to use - like which compilers, etc. so that
              > the DLL runs on their environment.
              > I think their host is UNIX/Linux based, but not sure which flavour.
              > Any help appreciated.[/color]

              I think you want to use Roadsend PHP compiler. It turns PHP source code
              in .DLL in WIndows or .so in Linux/Unix.




              --

              Regards,
              Manuel Lemos

              PHP Classes - Free ready to use OOP components written in PHP
              http://www.phpclasses.org/

              PHP Reviews - Reviews of PHP books and other products
              http://www.phpclasses.org/reviews/

              Metastorage - Data object relational mapping layer generator

              Comment

              • John Wellesz

                #8
                Re: Protecting PHP Code

                On 04 janv. 2005, Sir "Harold Crump" <orientletter@y ahoo.com> claimed in
                news:1104848128 .015768.306920@ f14g2000cwb.goo glegroups.com:
                [color=blue]
                > Greetings,
                >
                > I have a PHP/MySQL application that I am deploying at a client's.
                >
                > I am fairly certain that they will steal my source code and re-sell to
                > other companies.
                >
                > I would like to somehow protect the source code.[/color]

                You should use Zend Encoder, it was designed for that purpose... The only
                problems are:
                - You have to make your client install Zend Optimizer on their server.
                - Zend Encoder is rather expensive $960...

                Zend Encoder:

                Perforce, a software company, offers a wide range of enterprise DevOps solutions across the software development lifecycle.


                Zend Optimizer:

                Perforce, a software company, offers a wide range of enterprise DevOps solutions across the software development lifecycle.



                Comment

                • Chung Leong

                  #9
                  Re: Protecting PHP Code

                  "Harold Crump" <orientletter@y ahoo.com> wrote in message
                  news:1104848128 .015768.306920@ f14g2000cwb.goo glegroups.com.. .[color=blue]
                  > Greetings,
                  >
                  > I have a PHP/MySQL application that I am deploying at a client's.
                  >
                  > I am fairly certain that they will steal my source code and re-sell to
                  > other companies.[/color]

                  Put a backdoor into the program that let you hijack their server.


                  Comment

                  • lunatech

                    #10
                    Re: Protecting PHP Code

                    Chung Leong wrote:[color=blue]
                    > "Harold Crump" <orientletter@y ahoo.com> wrote in message
                    > news:1104848128 .015768.306920@ f14g2000cwb.goo glegroups.com.. .[color=green]
                    > > Greetings,
                    > >
                    > > I have a PHP/MySQL application that I am deploying at a client's.
                    > >
                    > > I am fairly certain that they will steal my source code and re-sell[/color][/color]
                    to[color=blue][color=green]
                    > > other companies.[/color]
                    >
                    > Put a backdoor into the program that let you hijack their server.[/color]


                    Get yourself checked out. This is unethical.

                    Harold, by any chance are you writing a program to control a nuclear
                    reactor or a rocket ? If not, most likely your customers will be able
                    to find better source code to "steal" in the gazillion of Open Sourced
                    programs. Your software is not special, get over it. That will make
                    life easier for all involved.

                    Cheers
                    Raj Shekhar

                    Comment

                    • Felix

                      #11
                      Re: Protecting PHP Code

                      > Someone mentioned the GCC compiler for C++.[color=blue]
                      > Are there any links and where is it downloadable from?
                      >[/color]
                      That was me. Visit http://gcc.gnu.org/
                      if you like, but GCC should be included
                      with any GNU/Linux distribution, and
                      you're going to need one for the build
                      process anyway.
                      [color=blue]
                      > I think there host is running Apache on Linux, but am not sure about
                      > the versions.
                      > Would GCC binaries work in this case?[/color]
                      It can be arranged by doing what is called
                      "static linking". You get a binary that
                      does not depend on any dll's.
                      [color=blue]
                      > Thanks,
                      > Harold.[/color]
                      You're welcome :-)
                      Felix

                      P.S. I just realized you probably want to
                      write a PHP extension. Oops. You will also
                      need a program called SWIG (www.swig.org),
                      unless you can organize your C++ code as a
                      stand-alone program and call it with exec().

                      Comment

                      • Michael Vilain

                        #12
                        Re: Protecting PHP Code

                        In article <1104898961.588 071.112420@f14g 2000cwb.googleg roups.com>,
                        "lunatech" <r.shekhar@gmai l.com> wrote:
                        [color=blue]
                        > Chung Leong wrote:[color=green]
                        > > "Harold Crump" <orientletter@y ahoo.com> wrote in message
                        > > news:1104848128 .015768.306920@ f14g2000cwb.goo glegroups.com.. .[color=darkred]
                        > > > Greetings,
                        > > >
                        > > > I have a PHP/MySQL application that I am deploying at a client's.
                        > > >
                        > > > I am fairly certain that they will steal my source code and re-sell
                        > > > to other companies.[/color]
                        > >
                        > > Put a backdoor into the program that let you hijack their server.[/color]
                        >
                        >
                        > Get yourself checked out. This is unethical.
                        >
                        > Harold, by any chance are you writing a program to control a nuclear
                        > reactor or a rocket ? If not, most likely your customers will be able
                        > to find better source code to "steal" in the gazillion of Open Sourced
                        > programs. Your software is not special, get over it. That will make
                        > life easier for all involved.
                        >
                        > Cheers
                        > Raj Shekhar[/color]

                        Or ensure that any contract you've signed gives your customer
                        "right-to-use" license for the software. Then put ways of identifying
                        your code into the source. If it ends up somewhere it shouldn't,
                        confront the company that's running the unlicensed copy and ask for a
                        license fee. File copyright infringement litigation if they refuse with
                        suitable publicity.

                        If you're doing "work for hire", forget it. They own anything you
                        produced and you have no grounds for anything. Then get a life and move
                        on.

                        --
                        DeeDee, don't press that button! DeeDee! NO! Dee...



                        Comment

                        • Sean

                          #13
                          Re: Protecting PHP Code

                          Resell them the hosting on top of the site coding and never give them
                          the password to the site.

                          Albeit, then you must support your code too.

                          enjoy,

                          Sean


                          "In the End, we will remember not the words of our enemies,
                          but the silence of our friends."

                          - Martin Luther King Jr. (1929-1968)

                          Photo Archive @ http://www.tearnet.com/Sean
                          Last Updated 29 Sept. 2004

                          Comment

                          • syren

                            #14
                            Re: Protecting PHP Code

                            OK, I understand your point in saying that the customer can find source
                            code elsewhere, but seriously. This guy came on here for help and you
                            respond with "your software is not special, get over it". That's
                            really nice. Maybe when you're done on the computer you can go kick a
                            couple of puppies, too.

                            Comment

                            • syren

                              #15
                              Re: Protecting PHP Code

                              OK, I understand your point in saying that the customer can find source
                              code elsewhere, but seriously. This guy came on here for help and you
                              respond with "your software is not special, get over it". That's
                              really nice. Maybe when you're done on the computer you can go kick a
                              couple of puppies, too.

                              Comment

                              Working...