Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-12

Detecting when decompiler is running

19 messages · 8 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi All,
I was wondering if there was a way where an application, written in Lazarus, could detect when a compiler is running, perhaps by it's mutex? My idea was, in my application, I could periodically check to see if a decompiler was running and then my app could perform an operation, such as maybe closing.

Thanks in advance

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/b2744aea/attachment.html>

Reply by email

Richard Mace
to Michael Schnell

Because this particular application of mine, is not open source.

Richard

"Michael Schnell" wrote 19 lines
On 12/04/2015 09:29 AM, Richard Mace wrote: My idea was, in my application, I could periodically check to see if a decompiler was running and then my app could perform an operation, such as maybe closing. Why should open source software need a decompiler ? -Michael -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/85ec37a8/attachment.html>

Reply by email

Sven Barth
to Michael Schnell: Why should open source software need a decompiler ? -Michael -------------- next part…
"Michael Schnell" wrote 5 lines
On 12/04/2015 09:29 AM, Richard Mace wrote: > > > My idea was, in my application, I could periodically check to see if a

decompiler was running and then my app could perform an operation, such as maybe closing.

Why should open source software need a decompiler ?

Why do you assume that every software written in Lazarus/Free Pascal is automatically an open source one?

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/ff3e98b5/attachment-0001.html>

Reply by email

Sven Barth
to Richard Mace: I was wondering if there was a way where an application, written in Lazarus, could detect…
"Richard Mace" wrote
Hi All, I was wondering if there was a way where an application, written in

Lazarus, could detect when a compiler is running, perhaps by it's mutex?

My idea was, in my application, I could periodically check to see if a

decompiler was running and then my app could perform an operation, such as maybe closing.

You can't do anything actively against a decompiler (please don't confuse this with "compiler"...) or dissasembler as these are running while your application is not. You'd need to use code obfuscation for that - especially on the assembly level - so that neither a human nor an algorithm can easily reconstruct the code's meaning.
What you cam do at runtime though is to protect against debuggers. Since this isn't specific to Lazarus/Free Pascal I'd suggest you to look also in context of C/C++ programs.

Do you want to protect your whole application or only a specific part? (e.g. a specific algorithm you don't want to disclose or the license validation code)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/6a974cd4/attachment.html>

Reply by email

Michael Schnell
to Sven Barth: decompiler was running and then my app could perform an operation, such as maybe closing.…
Sven Barth wrote
Why do you assume that every software written in Lazarus/Free Pascal is automatically an open source one?

I don't assume "is" but I assume "should be", as I consider closed source projects as a fraud against the highly valuated fpc and lazarus team members. pen source software of course can be payed for customer projects, but any obfuscation of the true working of a program in neither "nice" towards the customer nor sensible, as a decent hacker will crack it, anyway.

-Michael

Reply by email

Richard Mace
to Sven Barth: Lazarus, could detect when a compiler is running, perhaps by it's mutex? decompiler was…
"Sven Barth" wrote
Do you want to protect your whole application or only a specific part?

(e.g. a specific algorithm you don't want to disclose or the license validation code)

Regards, Sven

Hi Sven,
I guess just the license checking part really.
I am already using OnGuard but I was just thinking about maximising the protection before its released.

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/23c2971a/attachment.html>

Reply by email

Mark Morgan Lloyd
to Michael Schnell: I don't assume "is" but I assume "should be", as I consider closed source projects as a…
Michael Schnell wrote 7 lines
On 12/04/2015 10:44 AM, Sven Barth wrote: > > Why do you assume that every software written in Lazarus/Free Pascal > is automatically an open source one? > I don't assume "is" but I assume "should be", as I consider closed source projects as a fraud against the highly valuated fpc and lazarus

The only fraud would be if something was written in contravention of the appropriate licenses (i.e. reused bits of something that was GPLed, or modified something which was LGPLed without offering the changes to the community).

However as a lesser fraud I'd suggest something which was closed source and refused to even acknowledge what language etc. had been used. (Object) Pascal needs public support, particularly with what's happening to Delphi, and a few words in the right places that got people to look at it as a high-level language superior to Python et al. could be really valuable.

team members. pen source software of course can be payed for customer projects, but any obfuscation of the true working of a program in neither "nice" towards the customer nor sensible, as a decent hacker will crack it, anyway.

Maybe, maybe not. But it's not just a case of who's worked out how a program (supplied as a binary or as "shrouded" source) works, but who's got a right to re-use bits of it. And quite frankly, I'd suggest that banging the "anything written using an open source tool *MUST* be open source" drum doesn't help anybody.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Richard Mace
to Gabriele Cappelletto: An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/laz…

On 4 December 2015 at 11:01, Gabriele Cappelletto <

Show quoted text 8 lines
wrote: Even my project is not open source and if I see him I would be willing to make a small donation to the project FreePascal / lazarus Gabriele

?I intend to make a contribution to FreePascal / Lazarus for each copy of this application that is sold as my part of giving back.

Richard?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/4a6c2743/attachment.html>

Reply by email

Marc Santhoff
to Richard Mace: I was wondering if there was a way where an application, written in Lazarus, could detect…
Richard Mace wrote 6 lines
Hi All, I was wondering if there was a way where an application, written in Lazarus, could detect when a compiler is running, perhaps by it's mutex? My idea was, in my application, I could periodically check to see if a decompiler was running and then my app could perform an operation, such as maybe closing.

As others said, decompilers and disassemblers are not detectable. But for protection there are other counter measures.

1. Protect your program using checksums. Refuse to run if tampered.

2. Use varying protection schemes randomly. I did sth. like that by including protection code that is switched from the make process between multiple versions. If some hacker really solves the riddle for one executable, her hack will fail on most others. Same scheme as compiling in a serial number, that is changed for each compilation.

3. Check integrity of the program often, from many placces in the program. If really paranoid, you can combine with randomly selected checking routines. Using a code scanner/parser and injection code for checks is relaitvely simple, e.g. at the start of a procedure insert a check and exit code (or leave out, depending on the moons phase or so).

If you have enough checks, enough randomness between varying mechanisms, hackers will give up for sure. You are in trouble if those programm sould be distributed on DVD from one master, though.

I'd like to hear from others about their anti hacking tools ... ;)

Marc

Btw., the licence of the library code permits making closed source programs. Only Lazarus itself and the compiler code are open source. One point I like FPC/Lazarus for and use it.

Marc Santhoff

Reply by email

Sven Barth
to Richard Mace: (e.g. a specific algorithm you don't want to disclose or the license validation code) I…
"Richard Mace" wrote 5 lines
On 4 Dec 2015 09:48, "Sven Barth" wrote: > Do you want to protect your whole application or only a specific part?

(e.g. a specific algorithm you don't want to disclose or the license validation code)

Show quoted text 8 lines
> > Regards, > Sven > Hi Sven, I guess just the license checking part really. I am already using OnGuard but I was just thinking about maximising the

protection before its released.

I can't comment on how good OnGuard is regarding that, but the hints from Marc Santhoff are definitely something and other than that I'd search for C/C++ stuff as that can most likely be adapted for FPC.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/de37b6af/attachment-0001.html>

Reply by email

Sven Barth
to Michael Schnell: I don't assume "is" but I assume "should be", as I consider closed source projects as a…
"Michael Schnell" wrote 5 lines
On 12/04/2015 10:44 AM, Sven Barth wrote: > > > Why do you assume that every software written in Lazarus/Free Pascal is

automatically an open source one?

> I don't assume "is" but I assume "should be", as I consider closed source

projects as a fraud against the highly valuated fpc and lazarus team members. pen source software of course can be payed for customer projects, but any obfuscation of the true working of a program in neither "nice" towards the customer nor sensible, as a decent hacker will crack it, anyway.

Maybe you never had the problem of your software to be illegally distributed or even hacked to be distributed as such. There is a certain point when you *must* do something, otherwise your losses get too large. And this also applies to otherwise legal customers not adhering to the license restrictions because they aren't technically enforced anyway. Also it doesn't need to be protected forever, just long enough that you can release the next version where the crackers would need to begin anew (of course one needs to adjust one's copy protection/tamper proofing then). Also the more complex a software is to crack the further down in the ToDo list of the cracker it is.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/87c647bf/attachment.html>

Reply by email

Mark Morgan Lloyd
to Marc Santhoff: As others said, decompilers and disassemblers are not detectable. But for protection…
Marc Santhoff wrote 12 lines
On Fr, 2015-12-04 at 08:29 +0000, Richard Mace wrote: > Hi All, > I was wondering if there was a way where an application, written in > Lazarus, could detect when a compiler is running, perhaps by it's mutex? > My idea was, in my application, I could periodically check to see if a > decompiler was running and then my app could perform an operation, such as > maybe closing. As others said, decompilers and disassemblers are not detectable. But for protection there are other counter measures. 1. Protect your program using checksums. Refuse to run if tampered.

The ld linker for ELF can embed a fingerprint, that can be read back fairly easily but I've not attempted to verify an entire binary against it. What I don't know is what part of a binary contribute to this, and whether- as a specific example- stripping symbols changes it.

The real problem however is the ease with which an attacker can substitute a hostile library, e.g. using (something like) LD_LIBRARY_PATH on unix.

Show quoted text 11 lines
2. Use varying protection schemes randomly. I did sth. like that by including protection code that is switched from the make process between multiple versions. If some hacker really solves the riddle for one executable, her hack will fail on most others. Same scheme as compiling in a serial number, that is changed for each compilation. 3. Check integrity of the program often, from many placces in the program. If really paranoid, you can combine with randomly selected checking routines. Using a code scanner/parser and injection code for checks is relaitvely simple, e.g. at the start of a procedure insert a check and exit code (or leave out, depending on the moons phase or so).

Making random choices can be unwise, because sooner or later you hit a weak combination.

Also as a general point I once had a colleague who spent his lunchtimes methodically single stepping through AutoCAD with a view to finding out how the security dongle worked, and he was broadly successful despite professing to know no x86 assembler.

So you can obfuscate things as much as you want, but that's no protection against somebody with patience.

If you have enough checks, enough randomness between varying mechanisms, hackers will give up for sure. You are in trouble if those programm sould be distributed on DVD from one master, though.

Yes, big trouble. And I assume that you've seen yesterday's news about Raspbian being insecure because all copies start with the same (or no) "entropy", so SSH is seeded the same.

There is no substitute for a piece of hardware or software being uniquely serialised, and the user's contract (or license, or whatever you want to call it) being tied to that.

Show quoted text 7 lines
I'd like to hear from others about their anti hacking tools ... ;) Marc Btw., the licence of the library code permits making closed source programs. Only Lazarus itself and the compiler code are open source. One point I like FPC/Lazarus for and use it.
Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to Michael Schnell: Don't connect the computer that holds the sources to the Internet. -Michael
Michael Schnell wrote
On 12/04/2015 02:09 PM, Marc Santhoff wrote: > 1. Protect your program using checksums.... Don't connect the computer that holds the sources to the Internet.

In principle, it should be possible for a binary to be signed in such a way that it can't be rebuilt, even from unmodified sources.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marc Santhoff
to Mark Morgan Lloyd: The ld linker for ELF can embed a fingerprint, that can be read back fairly easily but…
Mark Morgan Lloyd wrote 18 lines
Marc Santhoff wrote: > On Fr, 2015-12-04 at 08:29 +0000, Richard Mace wrote: >> Hi All, >> I was wondering if there was a way where an application, written in >> Lazarus, could detect when a compiler is running, perhaps by it's mutex? >> My idea was, in my application, I could periodically check to see if a >> decompiler was running and then my app could perform an operation, such as >> maybe closing. > > As others said, decompilers and disassemblers are not detectable. But > for protection there are other counter measures. > > 1. Protect your program using checksums. Refuse to run if tampered. The ld linker for ELF can embed a fingerprint, that can be read back fairly easily but I've not attempted to verify an entire binary against it. What I don't know is what part of a binary contribute to this, and whether- as a specific example- stripping symbols changes it.

Not easy but possible ...

I will not publicly tell more about the nasty upper and the ghastly lower layers in use ... ;)

The real problem however is the ease with which an attacker can substitute a hostile library, e.g. using (something like) LD_LIBRARY_PATH on unix.

For hacking protection external functions are not used. External in the sense of being located in some dynamically loaded lib.

Protection against other frauds is another topic.

Show quoted text 14 lines
> 2. Use varying protection schemes randomly. I did sth. like that by > including protection code that is switched from the make process between > multiple versions. If some hacker really solves the riddle for one > executable, her hack will fail on most others. Same scheme as compiling > in a serial number, that is changed for each compilation. > > 3. Check integrity of the program often, from many placces in the > program. If really paranoid, you can combine with randomly selected > checking routines. Using a code scanner/parser and injection code for > checks is relaitvely simple, e.g. at the start of a procedure insert a > check and exit code (or leave out, depending on the moons phase or so). Making random choices can be unwise, because sooner or later you hit a weak combination.

Never had that problem. In principle you're right, but If the goal is to check some validation points and exit on fail it is meaningless for the rest of the program. The other case is "do nothing if OK". If there are some timing sensitive hardware function, those have to be taken out of the code insertion run.

Show quoted text 7 lines
Also as a general point I once had a colleague who spent his lunchtimes methodically single stepping through AutoCAD with a view to finding out how the security dongle worked, and he was broadly successful despite professing to know no x86 assembler. So you can obfuscate things as much as you want, but that's no protection against somebody with patience.

That's why often and unexpected are the main guidelines for this scheme. You need to hack each and every executable, which mostly isn't worth the effort. And even if you try, it will take ages.

The other thing is, the hacker has to distribute the binary executable of the program hacked, for all others it will not work. If the program is worth a lot you'll have to fight against illegal copying in any case.

For the general case of software distribution the use of activation codes bound to some checksums retrieved on the target computer are safe (enough), me thinks.

Show quoted text 11 lines
> If you have enough checks, enough randomness between varying mechanisms, > hackers will give up for sure. You are in trouble if those programm > sould be distributed on DVD from one master, though. Yes, big trouble. And I assume that you've seen yesterday's news about Raspbian being insecure because all copies start with the same (or no) "entropy", so SSH is seeded the same. There is no substitute for a piece of hardware or software being uniquely serialised, and the user's contract (or license, or whatever you want to call it) being tied to that.

What I did not mention is, that I used this scheme from the solid position of being able to rely on some hardware serial numbers.

General software (only) distribution needs another source of checksum, but that one will need to be checked, too.

> I'd like to hear from others about their anti hacking tools ... ;)

Still so, how do you protect?

Marc

Marc Santhoff

Reply by email

Martin Frb
to Richard Mace: I was wondering if there was a way where an application, written in Lazarus, could detect…
Richard Mace wrote 6 lines
Hi All, I was wondering if there was a way where an application, written in Lazarus, could detect when a compiler is running, perhaps by it's mutex? My idea was, in my application, I could periodically check to see if a decompiler was running and then my app could perform an operation, such as maybe closing.

Well there is no 100% protection.
Even if you make it so hard, that it is financially not interesting for a cracker, there will be someone who does the job to make him self a name, add it to their trophy list.
Hence my opinion: if you spent to much time/money on protection, then thats already your loss.

Anyway, there are 2 ways your app can be hacked.
1) a key can be distributed.
1a) Either stolen, or bought with wrong credentials 1b) a key generator can be written
2) a patch can be written to modify your exe.

(2) is always possible, and will happen unless (1) is really simple. But (2) is not so attractive to the users, as the risk is that they download a virus with it. IMHO attempting to protect against (2) is a waste of time.

(1) is important. Because downloading a key (usually a bit of text) is easy. Sign licenses with a private key. That should stop (1b).

(1a) can IMHO only be solved by phoning home. That in itself can loose you a small number of potential buyers.
Download a revocation list: hashes of keys no longer allowed, the overall list is signed, and it is issued with a time stamp, updated every minute. Your app will only run, if it can get a list not olden than x days. Downside if your server is down, longer that this ..... Also the user needs internet.
Alternatively you can try to bind the license key to the hardware signature of the users pc. Allowing to reactivate a few times, then having to phone you.... I remember some big company did that in the past.

The other option is a dongle. Then you do not need to phone home. Again some hacker will create a patch to your software. But hopefully enough users will pay, rather than risking a virus.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/f8270962/attachment-0001.html>

Reply by email

Chavoux Luyt

Hi

<snip> > I'd like to hear from others about their anti hacking tools ... ;)

In addition to some good points already made, I would refer you to an old and still good article at: http://71.6.196.237/fravia/protec.htm ( http://www.woodmann.com/fravia/protec.htm). This was written from the cracker's perspective. Keep in mind that often it is the challenge of cracking a program, rather than making money or "stealing" a program that drives the real cracker (somebody else often uses his work in order to try to make money or claim fame), E.g. I have reverse engineered legally bought copies of programs that I paid for in order to see how they did some kind of protection (essentially to learn what you are asking from us here) or occasionally to skip the inconvenience of having to insert a CD just in order to start a program).

I have also once been hit by the other side of not cracking a program when the original CD got scratched and my legally bought program became useless because I had no backup CD. So whatever protection you use, also keep in mind the fact that it might inconvenience your legitimate users enough that they might stop using your program (e.g. I will never buy ARC GIS, because a broken dongle, just as the GIS data for my thesis had to be analysed, made it impossible to use and I then discovered powerful Open Source GIS's: GRASS and qGIS which can do all and more for no money, but with a steeper learning curve).

Happy hacking!
Chavoux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151204/fd345921/attachment.html>

Reply by email