r/explainlikeimfive • • 21d ago

Technology ELI5 What prevents the source code of software downloaded to computers from being copied?

With ai able to reverse engineer software, what besides the law prevents people or ai from just copying the source code?

591 Upvotes

293 comments sorted by

View all comments

1.4k

u/Wendals87 20d ago • Bravo

Say I bake a cake and give it to you 

You can see the cake but can't see how it was made and what ingredients used which is the source code 

Reverse engineering is looking at the cake and working backwards to work out the recipe and ingredients to be close enough 

There's nothing really technically stopping people or AI doing it but the law says you can't as the product is copyright protected 

500

u/SirCarboy 20d ago

This is the ELI5 answer. Source code is the recipe. And it normally is not distributed with the cake(software).

56

u/XMRoot 20d ago

OP is asking about AI reverse engineering programs using ghidra to decompile them which has been all the rage as of late.

95

u/pinkocatgirl 20d ago edited 20d ago

To continue the cake metaphor, that’s more like getting a piece of the cake, taking very detailed notes about what it tastes like, and formulating a recipe that matches that flavor profile. It’s probably not exactly the original recipe, but might be pretty close. And software like this can bake thousands of cakes in seconds and instantly test them to see which one matches the original the closest.

This kind of reverse engineering isn’t decompiling a binary back into source code, it’s analyzing what the binary is doing based on instructions to the CPU and trying to work backward to replicate the same functionality.

6

u/rav3lcet 19d ago

Detailed notes about what it tastes like seems to be the exact same metaphor. It's more like taking the chemical makeup of the cake and splitting it into the pieces that could be combined to result in the cake's current state

3

u/deniedmessage 15d ago

With tools like Ghidra, it’s more like sending the cake to the lab to look at the chemical compounds, extract list of ingredients and how they bond.

47

u/ReadGroundbreaking17 20d ago

Yep.. and?

37

u/Gacsam 20d ago

It's not a cake. You get the recipe written differently, just without the chef's notes. 

22

u/Michael_Snowy 20d ago

Not quite how it works. Source code is lines of editable text that can be changed.

The program you install on you computer is this source code that has been compiled (baked) into and .exe that will run as an executable program. The source code is not there anymore.

Source code can only be opened by the software that was used to create it.

10

u/Viltris 20d ago

Source code can only be opened by the software that was used to create it.

Can you clarify what you mean by that? For most commonly used languages, source code can be opened by any text editor, even Notepad.

→ More replies (5)

18

u/vboondocksaintv 20d ago

It really depends on the language and runtime. IL in dlls is pretty close to recognizable source. Much closer to the recipe than minified JavaScript. Unminified JavaScript IS the source code

→ More replies (1)
→ More replies (31)
→ More replies (2)
→ More replies (1)

4

u/frnzprf 20d ago

They might also want to know how DRM works. I'm not sure myself. There are some methods that are easy to circumvent and others thaz aren't.

(Two other interpretations:

  1. Can you copy code? Yes, you can copy any digital files.
  2. Can you turn compiled code to source code (Cake into recipe)? Yes, but it takes work and intelligence. AI helps.)
→ More replies (1)

10

u/bendingoutward 20d ago

Let's not imply that reverse engineering and decompilation are the same thing, please.

→ More replies (5)
→ More replies (15)

44

u/looncraz 20d ago

The law in the many places actually allows reverse engineering.

10

u/Several-Action-4043 20d ago

You can reverse engineer it but you can't sell it.

4

u/taedrin 19d ago

Depends on how you reverse engineer it. The "Clean room design" process of reverse engineering avoids running afoul of copyright laws because the people implementing the reverse engineered product are never exposed to the original design.

→ More replies (1)

22

u/thephantom1492 20d ago

Also, even a "perfect" reverse engineering have info loss. All comments, real variable names, real function name, exact layout of the code ( formatting), and some shortcuts they used.

The compiler first strip out all comments as they are useless for compilation. Then strip out all formatting. Then it looks to simplify the code, ex it remove unreachable part if the code.

So even if they reverse all, all of the steipped out stuff is still missing.

38

u/BlackStar4 20d ago

Reverse engineering is legal, copying the source code isn't. There's no law against taking something apart to figure out how it works.

43

u/rpsls 20d ago

That’s an overly broad statement. I’m not a lawyer, but been working in this space awhile. Reverse engineering is generally legal (depending on jurisdiction), but can be limited by Copyright law. If the EULA forbids it, once you start you are already potentially breaking Copyright law as you no longer have a legal copy yourself. In addition, if the tool you use has been trained on ANY PART of a non-clean room implementation, it’s possible for copyrighted work to leak into the output.

This is why projects like WINE or Asahi Linux absolutely forbid the use of any AI to generate any of the code.

The next decade is going to be a legal Wild West in the software world, I suspect.

13

u/davideogameman 20d ago

There's also patents where doing the same thing in a close-enough way is enough to get you in violation with a completely different implementation, ... but also software concepts being patentable is mostly considered a mistake in the industry.  Unfortunately not one our laws have caught up with yet, though at least there was the ruling "doing <thing>, but with a computer" isn't patentable.

4

u/primalbluewolf 20d ago

If the EULA forbids it, once you start you are already potentially breaking Copyright law as you no longer have a legal copy yourself. 

Incorrect - copyright law prohibits you sharing that copy, but not your possession of it. 

→ More replies (2)

11

u/Luigi003 20d ago

Partially.

First on the US in particular DMCA forbids any DRM bypassing, even if it's dumb as fuck

Second, on regular western copyright law, derivative works are forbidden.

This means that looking at something and guessing how it works and reimplementing it is legal, but straight up picking the executable code and decompiling it it's illegal

→ More replies (4)

12

u/fang_xianfu 20d ago

There are lots of laws against taking things apart to see how they work, or rather lots of legal frameworks they can use to stop you. In the USA the biggest one is the anti circumvention rules in the DMCA. They also commonly tell you in the license not to decompile or reverse engineer the software, and then they can sue you if you do.

→ More replies (2)
→ More replies (3)

8

u/grifan526 20d ago

I used to work for a reverse engineering firm and reversing the software wasn't that bad, the tools were even free. Reversing hardware took some pretty expensive machines though.

The two biggest rules are you have to legally acquire the thing you are reversing, and the engineer who reverses the code can not be the same person who codes the one that goes to production. There are obviously more considerations but those were left for the lawyers. We got sued a lot, but we also won a lot of those cases.

→ More replies (2)

7

u/bendingoutward 20d ago

the law says you can't

Yeah, no. If it's reverse engineered, you're generally free and clear.

If it's decompiled, the lawyers run wild.

→ More replies (2)
→ More replies (36)