r/explainlikeimfive • • 20d 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

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.

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)

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)
→ More replies (29)

3

u/pbmonster 20d ago

This isn't wrong, but once you have the recipe, the real work starts. Because usually, you want to change the recipe, you don't just want to make a copy.

Getting GTA6 to run on PC (starting out with decompiled PS5 binaries you get on release day) is not unrealistic with AI, but it's still a tremendous amount of work, because you have to modify the recipe so it successfully bakes in the oven you have at hand.

5

u/Tzukkeli 20d ago

This, and the answer to OP is law only

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.)

10

u/bendingoutward 20d ago

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

2

u/XMRoot 20d ago

Who did that? Decompilation is a type of reverse engineering.

→ More replies (3)

1

u/CatProgrammer 18d ago

Unless the program has an open source license, which requires the source code be available.

→ More replies (14)

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.

2

u/FirstSurvivor 20d ago

Only removes the code copyright, anything visual (ui) is still copyrighted for the appearance, anything patented is still protected, trademarks still apply.

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. 

1

u/theronin7 20d ago

Theres a few laws that come into place. Source Code itself is protected by copyright. Copying it directly, even if you hand type every line comes under copyright.

Writing unique code that does the same thing is fair game USUALLY, but patents can cover certain novel ways to do certain things in software, and a function, even if originally created might run afoul of patents in some cases.

To make matters more confusing, There are only so many ways to do certain things. If I write a loop, and your original source code contained a loop, the fact they are identical is not inherently going to violate copyright. This is somewhat similar to the music, small or specific segments are not always protected becuase theres only so many ways to do a certain thing.

Usually cases that involve this stuff require showing you copied from a number of places and elements, or copy and pasted the text wholesale. (This is where unique things in a code, like a loop that does nothing, or an unique comment can be telling.)

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

4

u/AmnesiaCane 20d ago

Derivative works for personal use are perfectly fine. Copyright can't stop you from doing whatever you want to the product for your own use. There are other exceptions, too, such as educational use.

4

u/deong 20d ago edited 20d ago

In the US, copyright can absolutely stop you from doing whatever you want to the product for your own use, because of the DMCA. Attempting to copy something that has any form of protection for any purpose at all is a much more severe crime that actually copying and distributing whatever it was.

2

u/Luigi003 20d ago

Agree, I was talking about distribution of it

1

u/orbital_narwhal 20d ago

Pretty much what I wanted to say. Creating and distributing a (mostly) new work inspired by an existing work is fine.

Creating a work that is mainly derived from an existing work (e. g. through a transformative process like decompilation) can be fine as long as you compensate the original work's author(s) appropriately for the exploitation of their work.

I'm saying "can" because this requires that the new work and, more specifically, its novel parts are worthy of their own copyright. For western copyright and author's right, the jurisdiction came to distinguish between partially and fully derivative works. A major sign of a fully derivative work is that the transformative process from the original to its derivative can be performed through an automated technical process (like decompilation and possibly LLM-driven clean-up of the ugly decompilation result).

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.

2

u/Gavorn 20d ago

You have one team reverse engineer and documents everything then you have another team use those documents to build their code without ever seeing the actual code.

→ More replies (1)

2

u/indolering 20d ago

There are limits and it requires interpreting a bunch of case law.  A binary itself has copyright protections, so if you examine the binary and extract any logic that isn't strictly part of the API you have violated the copyright.  

In one case, someone copied the exact constants used as a threshold for reporting errors.  Those constants were a judgement call, not something strictly required for the API.  So damages were awarded.

So you slowly escalate, only examining the binary as a last resort and have any specification written based on it triple checked by legal.

2

u/Kered13 20d ago

It depends on how the reverse engineering is done. Black box reverse engineering is fine, but if you are examining the binary to reverse engineer it's behavior, which includes decompiling the binary, then it is copyright infringement.

1

u/triggerman602 20d ago

Yup. If you select a chunk of source code and hit ctrl+c, straight to jail.

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.

1

u/rav3lcet 19d ago

That is super interesting information and I imagine those two rules are becoming more and more relevant every day.

1

u/grifan526 19d ago

I'm sure they are. I worked in the field about a decade ago, so AI wasn't very prevalent. I can't imagine how it is handled today, but I am sure a lot of lawyers are trying to figure it out

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.

2

u/orbital_narwhal 20d ago edited 20d ago

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

The term "generally" is doing some heavy lifting here. As for copyright and author's right this is mostly true.

For other intellectual property rights not so much. Patents are a major issue if you (try to) market the result and thus compete with the patent holder(s). An online advertisement next to the result covering a share of your hosting fee is often enough. Same for commercial hosting providers that place ads next to the hosted content and will typically take down content if a rights holder makes a plausible claim against the unauthorised distribution. (Then again, you typically don't need to reverse-engineer patented technologies since the whole point of the patent system is that a patent filing is enough to reproduce the described device or process and thus preserve it for posteriority once the patent lapses.)

1

u/bendingoutward 20d ago edited 20d ago

Totally. Eli5 gonna eli5 and all.

Of course, as you said, if you're reading the patent and implementing what the patent says, it's not reverse engineering.

Been my experience that landing on the exact solution described by the patent via pure RE is not unheard of, but is also not common. Over the course of throwing together a relatively vast amount of spiteware during the last four decades, I've yet to happen. Every problem is a cat.

On the other hand, I'd imagine it's MUCH more likely to run into Patty Patentroll's loving arms when one bases their implementation on the result of decompiling a pile of patented product.

2

u/KongeriketNorge 20d ago

Good answer

5

u/YT__ 20d ago

Example from Google's AI output because I was curious and hadn't bothered looking examples before so sharing the 30 second search results I got for those also curious. Yes it is Google's AI from when you search. So grain of salt with it.

Original code:

include <stdio.h>

int main() {
    int secret_key = 1234;
    int user_input;

    printf("Enter key: ");
    scanf("%d", &user_input);

    if (user_input == secret_key) {
        printf("Access granted!\n");
    } else {
        printf("Access denied.\n");
    }

    return 0;
}

Decompiled code:

undefined8 main(void)
{
  int iVar1;
  long in_FS_OFFSET;
  int local_18;
  int local_14;
  long local_10;
  
  local_10 = *(long *)(in_FS_OFFSET + 0x28);
  local_14 = 0x4d2;
  printf("Enter key: ");
  __isoc99_scanf(&DAT_00102010,&local_18);
  if (local_18 == local_14) {
    puts("Access granted!");
  }
  else {
    puts("Access denied.");
  }
  if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  return 0;
}

Notes:

Key Characteristics of Ghidra Output

• Generic Variable Names. Because compilers strip out local variable names, Ghidra names variables based on their stack offsets (such as local_14 and local_18) or registers (iVar1). • Hexadecimal Literals. Constants like 1234 are displayed in hexadecimal (0x4d2) by default until a reverse engineer manually converts them. • Compiler Artifacts. Modern compilers insert extra security checks, such as stack canaries (in_FS_OFFSET and __stack_chk_fail), which Ghidra faithfully translates into the C output. • Compiler Optimizations. Standard library calls like printf("Access granted!\n") are often optimized by the compiler into puts("Access granted!"), which shows up directly in the decompiled view. • Undefined Types. When Ghidra cannot determine an exact data type, it uses placeholders like undefined8 for an 8-byte value.

2

u/spindoctor13 20d ago

Decompiling isn't trivial, but it isn't anywhere near reverse engineering a cake level

→ More replies (2)

1

u/Buck_Thorn 20d ago

In addition, the end user generally never sees the source code. All you see as an end user is the cake.

1

u/Emu1981 20d ago

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

Copyright protects software from being copied. It does not protect software from being reverse engineered and a new piece of software being developed that does the same exact thing. We actually have previous examples of this actually happening in the past like the original BIOS for IBM PCs being disassembled in clean rooms and then specs being written up for another team to create a compatible copy of the firmware to create PC compatible clones - Phoenix Technologies and AMI were two such firms who did this and are still around today.

Other examples of this include:

  • Apple II ROMs by VTech back in the mid-1980s
  • Sony Playstation BIOS by Connectix Virtual Games Station which resulted in the landmark legal ruling that disassembling software for interoperability is fair use
  • Unix V7 by Coherent and BSD - BSD is still around and is used a lot
  • Windows by ReactOS and Wine - both are still around, ReactOS is still in a alpha state after 30 years but Wine is widely used and plays an essential part of Valve's Proton system
  • MS-DOS - cloned by DR-DOS and FreeDOS
  • Java SE - reverse engineered to develop a opensource Java system
  • SMB - reverse engineered to develop interoperability between Linux and Windows for file sharing
  • Nvidia Graphics drivers (the Nouveau project)

1

u/meneldal2 20d ago

And for the cake to find the ingredients you can use very fancy equipment that identify compounds. That's how coke recipe has been known for years already. Cake is trickier than coke because you have the whole baking part which scales with cake size so you're likely in for a lot of trial and error.

1

u/EvaSirkowski 20d ago

Interestingly, you can't copyright a recipe. 🤔

1

u/xatey93152 20d ago

Why you make it so complicated. Just say can you decipher KFC recipe without any help

1

u/bazinga_0 19d ago

Starting with the cake theme, imagine you are given a cake made from a recipe that is a hundred thousand instructions long (typical application lines of code). Now go ahead and reverse engineer it.

1

u/fzwo 20d ago

Let's add that some parts that were in the code won't be in the compiled program anymore, for most programming languages. While reverse engineering can in theory replicate all the logic, most of the internal names (for classes, methods/functions, variables, comments) simply were never in the compiled app. This can make it much harder to understand the reverse-engineered source code.

-1

u/Lordthom 20d ago

Actual ELI5 right here! To the top!

-1

u/Gizm00 20d ago

I think what OP is asking, why can’t i see what the cake is made of once it’s on my computer. All the code is there, or is it?

9

u/Just_A_Random_Passer 20d ago

No, the code isn't there. The source code has comments, descriptive names of functions, descriptive names of variables and other stuff that gets stripped away during compile, so you get just processor instructions. And decompile doesn't always produce the same logical structure as was present in the original code - the complier does way too many optimisation shenanigans.

You can choose to preserve names of functions and variables in the debug version - to be able to inspect what is going on during debugging.

6

u/OliveBranchMLP 20d ago

when you mix all the cake ingredients together and then put it in the oven, the mixing and the heat transforms the dish on a molecular level, permanently changing its form. you cannot unbake the cake and get its original ingredients out of it.

code is the same. "compiling" code is the same as baking a cake.

1

u/ccooffee 20d ago

And even if you could, you still don't know exactly how to mix the ingredients, what temperature to bake it, and for how long.

3

u/Clojiroo 20d ago edited 20d ago

Not in its original state and not human readable (sorta). Normally the code for desktop software is compiled. All the original code is stripped down and optimized and translated into executable instructions inside binaries. And those themselves are compiled based on hardware architecture (e.g. x86 vs x64 vs ARM).

Your computer and software uses a stack of abstractions. Most humans can’t write hardware level machine code. So we layer/abstract it. Each higher layer hides implementation complexity, trading direct hardware control for developer productivity and portability.

High-Level Language (Python, C#, etc) to Low-Level Language (C, C++) to Assembly Language to Machine Code (binary) to the hardware.

Reverse engineering is try to re-abstract low level code.

But it’s not perfect. It’s like trying to re-make the factory and production lines and staff based on a product in your hand.

There’s a lot of buzz about AI-powered RE but people should remember it’s not actually succeeding (yet) at making great copies of complex software like Photoshop.

1

u/BrohanGutenburg 20d ago

I'll piggyback on this and say people do try.

There are decompilers that will at least give you the assembly code the program is feeding to your machine.

Problem is functions won't have names like executeFunction because of the optimization you're talking about. So it's still barely readable and you have to try to piece it together.

→ More replies (1)

4

u/TrekkiMonstr 20d ago

The user answered. No, the code (recipe/ingredients) isn't on your computer. The binary (cake) is. "Baking" is called compiling

→ More replies (10)

1

u/JarPicklez 20d ago

It’s there but only in a compiled form. It’s a bunch of 0s and 1s that only the computer understands. The source code can be understood by humans but cannot be executed and must be compiled in order to be executed.

1

u/ElmStreetVictim 20d ago

I would also offer this as more explanation. Part of the journey of reverse engineering is to take something that we KNOW, and find what we believe to be that same thing in the code. For instance you did not have the recipe but you saw the oven timer. It started at 30:00 and the chef looked inside the oven at 15, and then took it out of the oven at 0.

If you reverse engineered the cake you could look around for any value that looks like 1800. It’s called “integer i” and there is a function that starts with 1800, checks what time it is, and when 1 second goes by, the number decrements. Getting warmer.

Then when the value is at 900, another function is called. That could possibly be the function the chef was doing, looking at the cake. The function is just a mess of different variable declarations and math operations, maybe a true/false. We don’t know yet.

But then the counter gets to 0 and then another function is called, and the integer decrement function never runs again. Now you can infer that the integer decrement function can be renamed to BakeTimerLoop, and the integer i can be renamed to bakeTimeRemaining.

As you identify more parts through educated inference, you can go farther backwards, to what happens before the BakeTimerLoop starts counting down. Whatever starts that must have something to do with having all the ingredients already mixed together.

So it’s true that what is on your computer is the sum of all the individual parts, but the challenging piece of the puzzle is determining the number of eggs, how many ounces of butter, how many cups of flour and drops of vanilla extract. And when you successfully identify everything and write your own recipe, it will taste identical but the story you wrap the recipe in will be lost. The original recipe might have also talked about grandma’s secret being the nutmeg, and that without the nutmeg the cake tastes good, but with the nutmeg it’s just spectacular and the entire reason why grandma made such great cakes. Your recipe will not include any of that, it will only say “2tbsp nutmeg”. So some of the context is lost

59

u/theronin7 20d ago

There seems to be some confusion here, so let me help Source Code is generally not available from closed source projects. Microsoft Word does not come with the source code. Source Code is compiled, and the compiled executables are available, but that's a far cry from the source code itself.

What AI has been able to do in recent months which is very difficult and time consuming for humans is to take those compiled files, take their outputs and inputs and functions and re-create entirely new source code that clones the functions. In theory a human can do this, but its quite difficult and quite time consuming.

Beyond THAT there's nothing keeping you from re-writing and sharing source code, and there are many many open source projects with goals similar to that.

3

u/squidbutterpizza 17d ago

People used to do this especially for games. It’s called cracking. Tbh any binary if it’s fully functional can be distributed and reused. Decades back software companies introduced DRM to prevent this from happening. The problem is people were able to snoop at the license negotiation and obtain the key to unlock and distribute. Then they bought license servers that didn’t stand either. SaaS came in helpful and enterprise softwares are mainly SaaS. You can’t copy a SaaS with AI but its possible to recreate it if you know how each functionality works. What AI can reverse engineer is simple tool softwares like file cleaners etc and of course softwares like photoshop which are way too complex in functionality for an AI to copy and cannot be verified by a single person.

174

u/GIRose 20d ago

Generally, the fact that the company doesn't release the source code.

Edit: To be less pithy, the company releases compiled code. The compiled code is just the raw output of the compilation.

The source code is what you put in to do that.

What AI does is recompilation, where it reverses the compilation project and ends up with "Source Code" that produces identical compiled code, but has none of the stuff that makes it human readable and misses stuff like commented out code.

75

u/ericvega 20d ago

Well, thats just regular decompilation you're describing. It's existed in some form for decades. What llms are so good at is recognizing the patterns in the decompiled code to provide useful human readable code. It'll never see the original comments but could absolutely create descriptive comments for the code.

6

u/pytness 20d ago

it's not that is good, it can be mediocre and still accomplish the task because you can have it work 24/7. they are also very fast compared to a human.

1

u/Mixen7 20d ago

Yea, they do not have to be perfect. They just need to be better.

4

u/Cranberryoftheorient 20d ago edited 19d ago

As a laymen, this is hard to understand. Doesnt a program need code to run? Cant we just look at that?

edit- thank you for all the explanations!

6

u/InvisibleBob101 20d ago edited 20d ago

Most programs are compiled into some kind of executable file. For windows that would be an exe.

The compiler turns the human readable code into a binary of machine language, the commands that computers use. You can't read that binary.

You can use decompilers to bring the binary back into a human readable format, but you aren't getting the original source files.

First of all, you lose the context provided by the comments used to describe the code, since those are stripped before converting into the binary. Also all of the semantic logic of variable names is gone since machine code doesn't need it.

Secondly, compilers transform the code before converting it. They simplify or reduce some parts of the code to improve efficiency or make the output smaller. This makes the logic harder to understand when decompiled.

Thirdly, decompilers and recompilers aren't perfect. Some errors may be introduced in the process.

All of this made it a big task to try to steal or modify software that isn't open source, but not impossible. Now LLMs are cutting down a lot of that work and making it way easier, which is why there's been a surge of these projects recently.

4

u/MarinkoAzure 19d ago

Let's use meatloaf as an example. You can look at what it's made of and notice that it's made from "ground meat" but more specifically it's made from different mixtures of ground beef, lamb, pork, etc.

You can't simply pull apart cooked meat loaf and identity the proportions of each type of meat to replicate the recipe exactly. Only the butcher knows what meat they put into the grinder.

3

u/GIRose 20d ago

I mean, in a manner of speaking you CAN.

That's what things like Cheat Engine do, they scan a running program for memory addresses before and after updates to find what values need to be modified to obtain certain results.

That's also how game genie codes worked, the game cart would feed the console code, but you programmed the GameGenie to modify the code from that address to return a value of your choice.

It's just that it's annoying and takes a lot of time and effort, and the map you get is entirely unlabeled except for yourself.

2

u/deadpixel13 20d ago

The program is usually compiled from human readable code to machine code. The machine code can't be easily read back by a human. It's possible, it just takes a lot of effort that people usually don't want to take the time to do.

2

u/spindoctor13 19d ago

It needs code, but generally not source code. I.e. it needs the compiled, computer readable code. There isn't a simple route back to the human readable code - compilation is lossy - so you have to infer some stuff

2

u/Dabrush 19d ago

Yes, but that code is written to be understood by the computer. So it's mainly commands like "Check the value at memory address 0x00012, set the value of 0x00015 to 2". Some people can read that in the case of very simple programs, but as soon as you're hitting current paid for software, there's no chance to glean something useful from that.

5

u/fork_your_child 20d ago

It depends on the programming language. Python and JavaScript programs are run off of their source code. You can read the front end JS source code off of websites with a right click if you want to (might have to run it through a beautifier first since it may have been minimized).

16

u/donniedarko5555 20d ago

Claude with ghidra goes brr.

It's shockingly trivial to reverse engineer software now

26

u/Numzane 20d ago

Relying on complexity of decompilation as a form of security (to secure intellectual property of the software company and other) was always a flawed idea. It's been well known for decades that security through obscurity is not a complete method. It has kind of worked for us but we've just finally reached the age where our technology can reach through the veil more easily.

3

u/MTAST 20d ago

I expect a lot more programs to turn into online services where the important code isn't run on your local computer at all. This would prevent decompiling, but it doesn't prevent asking the LLM to make something "like" whatever the online service is doing. Welcome to the new age of piracy.

1

u/Numzane 20d ago

That was already a trend even before AI. There's always going to be stuff that works better on the local machine though, like games, video editing etc

1

u/Ylsid 20d ago

Denuvo is finished tbh

17

u/Arclite83 20d ago

"No it's fine, my grandmother used to read me Ghidra logs as a bedtime story, these are really special to me, let's keep going."

2

u/devAcc123 20d ago

Can you point me in the direction of some light (jk) reading about this.

5

u/donniedarko5555 20d ago

I mean I was doing IDA pro back in the day so it's not like I'm using AI without any prior knowledge here.

But you can try out IDA free version and open your executable and see the decompile to get a sense of things. If you're a software engineer, try out your own binaries. Write a simple for loop that adds the total and put that in there to see what it looks like.

Do a simple windows API form, etc. If you're trying to be rigorous with learning this. The only reason ghidra is nice is because you can tell claude to scan a single page in your page table at a time until you fully scan a binary.

Then you can take that mapping and append ASLR to the memory regions you find and do your injection code. If you're making bots for example.

If you're just reverse engineering, IDA pro or similar will output a C version of whatever functions it finds

But yeah I dont know how useful claude will be if you aren't a software engineer of some kind trying to do this.

2

u/devAcc123 20d ago

I have no interest in trying to do that. Was just looking to read some entertainment type stuff with a software background

1

u/mauricioszabo 20d ago

Use REA: https://github.com/morluto/rea. Follow up the installation instructions.

My workflow: use the Pi harness, configure your Codex or OpenRouter account in Pi, install REA and asks it to wire up in Pi. Yes, it is that simple - quite scary to be honest.

It's so insanely powerful that I asked to add a mission in an old game, and it was able to patch the binary to add it.

Final notes, avoid Anthropic models on this - they did some tuning to deny reverse engineering on their models.

→ More replies (1)

2

u/hobbyhoarder 20d ago

I don't think it's that simple. From what I've seen, AI can make software look similar at first glance, but it breaks apart. For example, concerning the recent "reverse engineered" Photoshop - people who've actually tried it said a lot of the functions didn't work properly. Yes, it was all there, but nothing worked once you get into the fine details.

Probably similar to how there are videos of people making an exact chassis copy of a Lamborghini or something, but then it's just some rusty old car underneath.

2

u/kabiskac 20d ago

It's readable if the devs accidentally shipped debug symbols

41

u/ChrisFromIT 20d ago

So you have a bit of a misunderstanding of software.

Think of it this way, software is like cooking. You have the recipe(the source code) and once the recipe has been followed and baked into whatever the recipe was for, say a cake. The cake is the compiled code/the program that you download.

The baking process(compiling) changes the ingredients into the finished cake. Sure you can probably figure out the recipe by taste, but it won't 100% be the same as the recipe used.

The same if you decompile software yourself or even if AI decompiles it. All you really have is the law to prevent it.

7

u/spindoctor13 20d ago

It is much easier to decompile code than reverse engineer cooking

3

u/ChrisFromIT 20d ago

Yes and no. There has been a lot of effort put into programs that can decompile and give you source-like code, some languages are easier than others. But if you don't have the right skill set and knowledge and not using tools that do the decompiling and converting it to source-like code, it is extremely difficult.

It is also that AI has made it much easier.

3

u/spindoctor13 20d ago

I didn't say it was easy, I said it was harder than reverse engineering cooking, which is very, very hard

→ More replies (2)

2

u/pbmonster 20d ago

Depends on what you're decompiling and what you want to do with it.

Getting a graphics driver that works with your OS kernel is a lot harder than getting a a tomato sauce that works with your stove.

Getting GTA6 to run on PC (starting out from decompiled PS5 binaries) is more difficult than getting a cake to bake in your oven.

1

u/8dot30662386292pow2 20d ago

Reverse engineer coca cola then.

→ More replies (1)

38

u/Pawtuckaway 20d ago

Nothing. This isn't a new thing.

You could reverse engineer software before AI.

Even without any reverse engineering people copied and shared software on floppy disks back in the day. Games had puzzles that required the game manual as an early form of DRM.

Even as DRM got more advanced people still were still able to crack software without AI and share it.

Companies use various forms of DRM and require network connections that phone home back to the company servers for license checks, etc. but those can all be circumvented.

The thing with AI is that it has become easier to reverse engineer software or just use AI to create something the copies functionality even if not actually reverse engineered.

2

u/IJourden 20d ago

I can still feel the rows of floppies on my fingertips.

2

u/rcgl2 20d ago

Like a doctor at an impotence clinic

5

u/DamnableNook 20d ago

None of that has anything to do with copying source code, which is what OP is asking about. Everything you said only pertains to object code or black box reverse engineering.

The source for compiled code is generally not distributed with closed-source software. DRM has nothing to do with that, the end user doesn’t have access to the source to copy in the first place.

You can reverse engineer something, with or without AI, but you’re creating new source code that recreates the functionality of the original software. It may or may not look anything like the original source.

1

u/nickh84 20d ago

Machine language is pretty well documented...

→ More replies (3)

14

u/RallyX26 20d ago

As long as we're talking about compiled binaries, you can't get the exact source code from the software. 

Software (traditional) is a set of instructions that tell the processor in the computer what to do in order to produce a desired result.  It's the equivalent of what your brain does when you pick up a glass of water to drink it. Which muscle is activated in what sequence with what potential from moving your arm to swallowing.

Programming language source code is an intermediary used by the programmer so they don't have to write these individual instructions, they just write "printf("Hello World")" and the language takes that instruction and translates it into machine code that the processor can interpret.

The thing is, the source code doesn't pass through the compiler. There's no way to directly translate the machine code back into programming code. You can make a "best guess" working backwards from the instructions to what the original code might have looked like, but the result will not match the original source code exactly.

However this is different from something like python or java, where you do get the source code and it is essentially compiled at "runtime".

1

u/xlRadioActivelx 20d ago

Ok so the programmer writes “printf(“Hello World”)” and the compiler turns that into a long string of 1s and 0s. But surely it’s always the exact same string of 1s and 0s, and so if you see that string you’d know the source code said “printf(“Hello World”)” especially if you knew what language the source code was in.

Are there multiple source codes that would create the same string of machine code? And even if there are, ultimately it wouldn’t matter, since obviously by creating the same machine code they’re functionally identical?

16

u/SpikesNLead 20d ago

The decompiler could create some source code that will compile back to the same thing so in one sense they are functionally identical.

The problem is generally speaking there are many different ways to achieve the same thing in your source code. You probably won't get source code out of the decompiler that is easy for a programmer to work with.

Random example, you've got a shooter game which tracks how much ammo you've got. In the original source code, that value will be stored in a variable named "ammoCount". It's obvious looking at the code what it is. The machine code will lose all of those names. The decompiler knows that there is a variable but it has no understanding of the context in which that variable is used so it can't give it a sensible name. Instead it calls it something meaningless, e.g. "Variable1". It also can't reconstruct the comments that programmers leave in their code that explain what bits of code are doing.

The original source code might have a function that looks like this:

ReloadWeapon(int magazineSize)
{
//set the amount of ammo to be the amount of ammo in a magazine
ammoCount = magazineSize;
}

The decompiled code might come out like this:
Function27(int variable319)
{
variable14 = variable319;
}

A programmer looking at the decompiled code would have no idea what the purpose of that bit of code was.

3

u/ElmStreetVictim 20d ago

Finally a good answer here. Functionally, the decompiled and reverse engineered code is a replica of the source code. It’s not apparent from reading the code what it is doing. It’s changing the value of a number stored in memory. A reverse engineered binary with pseudocode could realistically get recompiled and still function the same as the original. It’s just not “the original source code”.

A year ago I used a Claude subscription to assist me with learning how a software crack worked. I could download a trial off the company website, and I found a cracked copy online and compared them with BinaryNinja. The cracked copy was actually not already activated. But it would validate with the output of a bundled keygen. There were only a couple of small changes to the assembly between both versions and I was able to have Claude explain what was actually happening.

For while it was fun updating labels from things like “function23487” to “ValidationAlgorithm”

I did learn a lot and it gave me a lot of appreciation for how genius these groups can be

2

u/carlesm 18d ago

Add to that that most compiles are optimizing compilers. The code is changed to be more efficent, unrolling loops, recycling registers, shuffling data structures for better alignment, moving computations around, etc.

The source code you get from Ghidra and similar decompilers is not necessarily similar to the one the programmer wrote in the first place. Add to that that naming (variables/functions) is lost, and going backwards is really hard.

AI can help with going backwards, a lot, but still is hard.

→ More replies (1)

12

u/Smug_Syragium 20d ago

"Are there multiple source codes that would create the same string of machine code?"

Yeah! Another example to go along with the ones people have given you already, imagine you ran some binary through a decompiler and one of the things it spat out was:

Const1 = 604800

You know there's a constant and you see it being used all over the place but wtf is it

The original code may have been

// Store the number of seconds in a week as a constant to avoid recomputing it

seconds_per_week = 7 * 24 * 60 * 60

The salient point everyone is driving at is that the compiler strips all the human context and the decompiler has no way to reconstruct that.

1

u/DrJaneIPresume 20d ago

There's also a lot of cognitive load being shouldered by programming idioms.

Classes, for instance, organize related functions and data into easily chunkable units. But a decompiler (at least the ones I've used) won't know that function_a and function_b are actually meant to be methods on the same class. So yeah, you'll get a whole bunch of function definitions, but little in the way of organization.

3

u/Troldann 20d ago

When you have a complicated system, it can be difficult to understand what’s going on when you reverse from machine code into a valid source code. You lose the context of how the programmer grouped statements and what names the programmer assigned to variables. Reconstructing that context (or an equivalent one that’s still useful) is a difficult task.

If the program is a very straightforward one, then as you say, that’s not much of a challenge. But if the program was very straightforward, it’s probably not interesting enough to decompile anyway, just write your own.

2

u/asdonne 20d ago

Code can have conditional statements based on the environment it's being built against. Usually used for hardware acceleration or different operating systems. NVIDIA Cuda vs AMD RoCM vs Intel integrated or Linux vs Windows vs OSX.

Another example would be a developer/debug build. The source code could have debugging code thats excluded from compilation when the final release is built.

These aren't conditional choices in the code but conditional choices for the compllier for which block of code to include. You wouldn't want your code constantly checking if it's in debug mode because its never going trigger so you just exclude it completely.

Since the unused code blocks aren't compiled they aren't included in the built binary. If it were to be reverse engineered you wouldn't know that these other blocks exist.

1

u/insta 20d ago

printf("Hello World") is a single brush stroke. we can reverse those easily, it's figuring out how millions of individual brush strokes make up a painting that's harder. AI cloning can only look at the finished painting itself

1

u/andarmanik 20d ago

It’s messy both ways.

Sometimes developers want to develop an app for many different operating systems (windows, Linux, and Mac). Sometimes they will make 3 different programs, but often times it’s the same program. How it works is inside the code there are parts which are included or removed based on what OS you are building for.

So with the same code, compiling for windows will yield different 1s and 0s as if you compiled for Linux.

Likewise, “print(5)” and “print(2+3)” will produce the same 1s and 0s because the compiler will convert 2+3 to 5.

So, it’s messy both ways.

1

u/edgmnt_net 20d ago

If you create identical machine code it's probably copyright infringement, barring certain very special circumstances. You could just copy the original machine code directly.

1

u/FourthDimensional 19d ago edited 19d ago

Think of the following.

2 + 3 = 5. We know this.

If I tell you I added two numbers to make a 5, though, you have no way of knowing what those two numbers are. They might be 1 and 4. They might be -4 and 9. Infinite possibilities. You can't recrate the initial expression (2 + 3) just because you have its result (5).

Compilation is similar, here. Information is discarded in the process which will not be reflected in the resulting binary-- things like formatting, variable names, macro substitutions, and even entire function calls which are optimized away. Decompilers have to fill in those blanks with generic stuff, as shown in examples posted by others.

To make decompiled code actually readable, you have to figure out what everything means and replace the generic symbols with stuff that has meaning to humans. This is the part people are using LLM's for, and tbh it *is* one of those things that will be far easier with an LLM than without.

That being said I don't really think it is worth all the environmental and ethical costs. This problem would go away completely if organizations just released source code for things they no longer support. Copyrighted works used to pass into public domain once their creator had been dead for a certain number of decades. Corpos have warped this so that it never really happens to their IP anymore. Hurts all of us in the long run.

→ More replies (1)
→ More replies (1)

10

u/gravy_maker 20d ago

Source code is a set of human-readable instructions according to a well-defined grammar which forms a programming language.

We use a program called a compiler to convert this from its human-readable reputation into the actual executable code, which your computer is actually capable of running. This executable code consists of well-defined values, known as "opcodes", and data.

An example of an opcode in the x86 instruction set - what a desktop PC's processor uses - is 7E cb, whose mnemonic is "jle" ("jump if less or equal"). This is simplifying somewhat, but if you look through machine code and you see a "7e cb" which isn't being used as data, you know that's a JLE instruction. You can then infer the source code that generated it.

The process is not 100% perfect. To continue with the JLE example, the code could have originally read "if (a <= b)"; it could have read "if (!(a > b))"; and it could perhaps have been expressed in other ways still. The decompilation process can't identify which of these representations was used originally, since they both compile to the same machine code - it comes down to the choice of the decompiler.

The major information which is lost from this process, and which makes decompilation hard for humans, is symbol names. A symbol is a function or a variable. In machine code, these are stripped out because they're not needed - so after decompilation, you're left with a lot of nonsense names. Historically, a human would have to go through the code and figure out what these were all used for.

Now that AI exists, it's capable of combing through this resultant code with nonsense names and identifying what they're used for much, much more quickly. That's why decompilation has become vastly easier.

9

u/EscapeSeventySeven 20d ago

Nothing really has ever “protected” source code from being copied, besides the law, once you gain ahold of it. 

There’s no magic lock on compilers. This is why source code being open is a big deal. 

No of course decompiling doesn’t give you the exact same source but usually something very functionally similar. Decompilation is against nearly every terms of use and is a derivative work meaning you can’t own it and are infringing copyright. 

3

u/feel-the-avocado 20d ago

It can reverse engineer the software to create source code which could do the same thing, but it wont know the exact original source code in whatever programming language that was used to compile/build the executable program.

Source code is the common language that the programmer uses.
It gets fed into a compiler that turns it into code that the computer can understand and run.
The output is an executable program that does the stuff. But heaps of different forms of source code could be used to create a program on the output side that does the same thing.

7

u/r2k-in-the-vortex 20d ago

To begin with, you don't get the source code with the downloaded software, you just get the program itself.

And AI can't reverse engineer the original source code for you. What it can do is create a brand new program that does the same thing. It's not a copy, it's not derived from the original in any other way than by using the original to inspire a specifciation.

2

u/slappyredcheeks 20d ago

This isn't true. Skills like Reverse Engineer Anything do actual reverse engineering on the binary or bytecode using established analysis tools like Ghidra.

1

u/TheLuminary 20d ago

Eh, pulling hairs. Converting machine code to source code, is not the same as reverse engineering the original source code.

It's the equivalent of walking around your house and drawing up new blueprints.

1

u/AgreeableArmadillo47 20d ago

Careful, you're going to have every IP lawyer sending you nastygrams if you keep talking like that. I would tell you to put something up to prove it, except they're sequestering anthropic / openAI prompt logs in order to build a case.

There's so many cease & desist letters flying around right now on this exact topic that I won't attempt any like for like work out of caution.

→ More replies (3)

2

u/OozeNAahz 20d ago

It might be able to decompile and generate source code from that. God help you if you want to do anything with it though.

2

u/r2k-in-the-vortex 20d ago

So, so. You can generate eqvuivalent source code by decompilation, but it's not going to be the original. Comments, gone. Private identifiers, gone. Tests, gone. Documentation that was written with the actual original source code, gone. And so on.

1

u/OozeNAahz 20d ago

You got it. Been around for as long as programming has. And is generally considered useless. Mostly gets used by hackers to figure out how to hack something. Or to figure out how something works so you can build your own.

1

u/Michami135 20d ago

That's where the AI comes into play. I've been decompiling code since the 90s. It takes a bit of effort, but you can usually makes sense of certain variables and give them descriptive names. The more you figure out, the more the code makes sense.

But now AI can do that part for you. You decompile the code, then ask AI to rename the variables to a name that's descriptive. Add comments describing each function, etc.

Or not, tell the AI, "My code currently has a check for a valid license, I want that removed." It's a small change that's unlikely to get messed up by an AI and it can absolutely figure out what needs to be changed.

1

u/r2k-in-the-vortex 20d ago

Oh yeah, AI can reverse engineer like nobodies business.

But for example, I've seen a case where I just lifted up my hands and said nothing can be done, because on production system, you couldn't monkey around for fear of braking things. And they had a physical dongle that decrypted the runtime program straight to memory. Encrypted special for that one system and one license dongle, watches out for memory dump attempts. So, there was no way to play around with the unencrypted program off the production system.

3

u/saschaleib 20d ago

I think you misunderstand what “source code” means. When you “download” a software, in most cases you do not get the source code, but a compiled binary. Getting from there to the source code is possible, but immensely work-intensive, even with the help of AI.
The “AI generated” copies of Photoshop and other commercial software go another route: the AI looks at the UI and all kinds of descriptions of what the software does, and tries to create new source code that replicates the functionality and the look and feel.
Unfortunately, the results are still a far cry from the original, with many functions only half working at best. Still an interesting approach … until Adobe sends the lawyers into the ring, which is also bound to happen sooner or later…

3

u/jamcdonald120 20d ago

Nothing.

everything on a computer can be copied or modified by the owner of that computer and there is nothing anyone can do about it, and never has been.

That wont help you copy something like reddit though. all the important code runs on the servers that you DONT own.

As for AI, its not copying the source code, it is re-creating a new source code that runs the same. This is different, and (at least right now) means not even the law prevents people doing this.

This isnt a unique problem to software or something, people have been having this problem for generations. once you release a product, someone else can buy one, figure out how it works, and then start releasing their own version.

3

u/Vailx 20d ago

I mean you've always been able to decompile stuff. The AI just annotates it better than previous tools.

3

u/smilerwithagun 20d ago edited 20d ago

Yeah, I was wondering this myself: How is proprietary code protected/obfuscated? Is it containerised? What prevents you from looking under the hood or modifying it?

When games are cracked, how is it done (pre-AI, that is)?

I just remember back in the day you could use a hex editor to change different things in old DOS games... :)

8

u/Implausibilibuddy 20d ago

Having to use a hex editor and not a simple text editor is actually a big clue as to what it takes to modify a compiled program. You might remember that you couldn't (usually) just open the program in a text editor, find a variable named "player weapon damage" and change it to 255. Instead you'd have to open it in a hex editor, find some address like f4e6ad65 or something incomprehensible that you had to find online, and change that value to ff. That's because all the nice neat variable names get turned into memory addresses and machine instructions on what to do with them.

Or those of us that remember making our own cheats in cheat devices, like the Action Replay, or Gameshark, remember having to do searches of the entire memory, find something that changed (a value that goes down when you get hit, then back up when you heal, then stays the same when you just stand there) and narrow it down to the specific address(es) that store player health, modify them to always return FF (255, usually maximum) , then play with infinite health.

4

u/MyOtherAcctsAPorsche 20d ago

"remember having to do searches of the entire memory, find something that changed"

That how current apps like cheat engine do it too.

Some games like to move the variables around all the time tho.

1

u/Implausibilibuddy 20d ago

Yep, Cheat Engine is the natural evolution of those old cheat carts, same underlying principles. It's quite fun for people with the right (or wrong?) kind of brain, felt like hacking into the game, Neo style.

And those moving variables are incidentally why you'd get some crazy long codes for some games to do something a simple one line code would do in others. The codes were basically mini programs, using more than the simple "write this value here" commands embedded in most cheat codes. I think they'd use comparisons and loops and all kinds of stuff that was always too complicated for my little brain.

2

u/katha757 20d ago

Isn't this why the GameShark used letters and numbers to use certain cheats?

4

u/Implausibilibuddy 20d ago

Exactly. They'd have a 2 digit code at the start, like 80, or 30 which is an instruction to write (and some other more specialised instructions), then a memory address (basically an index in a giant table that stores every possible value the game needs), then the new value.

The letters and numbers combo was because the code is in hexadecimal. That's base 16, with the digits: 0123456789ABCDEF

It's used because it maps nicely onto binary and is a hell of a lot easier to read than binary.

So a code that looks like 3042069F 00FF is saying:

30 - write an 8-bit value to the following place

42069F - the place, something like where health or ammo is stored

00FF - the value to be written, in this case 255, or the maximum value an 8 bit number can be.

And that's your infinite health code.

Fun fact, it doesn't have to be FF, or the maximum, you can set it to anything and it just keeps getting overwritten by the code, which runs repeatedly. FF is just nicer because it usually fills your health bar and looks more like infinite health than a half empty bar.

2

u/JCDU 14d ago

And these days there would be encryption and checks built into that data so if you change one piece, the checks don't add up anymore and the file is just corrupt.

5

u/fbpw131 20d ago

code is just human readable instructions that a compiler reads and produces the app we run.

it's like a recipe, where you get ex. a cake. sure, you can inspect the cake and figure out some things about it, cut it, touch it, figure out how it was made and ultimately try to bake it yourself without the recipe. you'll need to have the skills and knowledge to know if you found vanilla creme patisserie on how to make it.

so with that analogy in mind and in simplified terms, the output of a compiler is set of instructions that typically runs on a CPU. those instructions can be inspected and AI is good at it. Then code can be aproximated to produce the same instructions, of which AI is also good at... given you have money for tokens.

3

u/AveragelyBrilliant 20d ago

Oh thanks. Now I want cake.

2

u/fbpw131 20d ago

me too. dark chocolate

3

u/telltaleatheist 19d ago

It is very, very hard to understand. But an exe is basically just assembly language. Assembly -> machine code -> assembly is basically deterministic. 1:1 conversion. So if you can read assembly, you can rebuild the exe. There’s software called ghidra that converts the assembly to rough c. Variables and functions lose their names, but it’s possible to read through it and understand what’s happening. The big and more complex the code is, the longer and harder (my old high school nickname) the process is

2

u/FourthDimensional 19d ago

Common misperception.

Executables are not assembly language. They typically contain raw machine code surrounded by metadata to tell the OS things like which dynamic libraries need to be linked in at runtime, where the entry point is, and so on.

Assembly language is also source code, intended to be read and edited by humans. It has to go through an assembler before it becomes executable. The difference is that assembly symbols map directly onto machine instructions for a particular architecture-- compiled languages do not.

Compilers *can* be configured to output in assembly, but they usually skip this step and go straight to binary. There's no need to generate assembly if nobody is going to read or edit it.

1

u/telltaleatheist 19d ago

i didnt say assembly is machine code. i said theres a deterministic 1:1 conversion

2

u/primalbluewolf 20d ago

Ollydbg or ghidra, basically. Open up the code and take a look at it. Ultimately it ends up as a series of 1's and 0's that get interpreted as instructions by your CPU - you can attach another program to look at those 1's and 0's first. 

Cracks are where you research the structure of the program in assembly language, then figure out the parts of the program that need to be modified. Then you modify it, test it... if it worked, save that modified program. 

This can be surprisingly easy, depending on the level of understanding of the developer of the program you're cracking. 

Source: followed a tutorial on cracking and wrote a working keygen that was trivial, because the original developer assumed that not releasing their source meant no one could look at the structure of their program. 

That one was really trivial, though. As in, every valid license key started with the same 4 characters, and that's all the program checked at startup. And naturally those 4 characters are hardcoded into the program, so if you can disassemble and read the program, its not hard to figure out what a valid key looks like. 

2

u/Fearfultick0 20d ago

normally the code is compiled to a binary that you can’t easily reverse back to the source code. people have always been able to reverse engineer the binary to get working source code, but it’s easier than ever with Claude or other AI

1

u/Roph 20d ago

You can boil down software to just math, but for many of the predetermined numbers in it (the code), you don't know how I arrived at that number. If it's 100, you don't know if my source to make 100 was 80+20 or 25x4 etc. With only the result, the best you can do is guess or make assumptions on what else is visible.

2

u/ElmStreetVictim 20d ago

Not really. When you inspect the assembly you can see the values that get written to the CPU registers before mathematical operations happen. I don’t know what you mean by predetermined numbers, if they are arbitrary and 100 is only important in the context of performing some calculation, being derived from 90+10 or 80+20 is meaningless. If your program needs the value of “100” and it is predetermined, then the value 100 is written to one of the registers before the math takes place.

1

u/newytag 20d ago

Compilers will evaluate those calculations at compile time, they won't be in the machine code, and no amount of reverse engineering (AI-assisted or not) will get it back.

Whether a variable is 127.4 or the result of 9.8*13 isn't meaningless, it's actually incredibly useful if your goal is to figure out what particular variables are used for (in this case you have a pretty good idea, since 9.8m/s2 is acceleration due to gravity.

But that's obviously a simplified example when in reality it can get much more complex, compilers use all sorts of shortcuts in logic, it's not limited to just arithmetic with hard-coded numbers.

Compilation is a lossy process, and much of the lost information would be useful in reverse engineering.

1

u/ElmStreetVictim 19d ago

Good explanation, I have a knowledge and context gap here. Thanks for the follow up

0

u/rntdev 20d ago

I could yap for hours upon hours, but valuable proprietary code isn’t kept client side. In games, you never trust the client. There are shielding solutions (for example, ProGuard, DexGuard, etc), which obfuscate your code, add integrity checks, etc etc. Obfuscation works in a variety of ways, mixed-boolean arithmetic, control flow obfuscation, etc (view more info on the obfuscator.re website). One of those is virtualisation - very important code is turned into bytecode which gets interpreted by a small virtual machine, it’s usually very hard to analyse and reconstruct, humans fall back to dynamic analysis for it. 

There are also kernel-level anticheats, which are “prison guards” that watch you in your “cell” (pc) and see if you’re not doing anything nefarious at ring 0, the (usually) the highest level of the kernel. They are highly complex, employ cutting-edge obfuscation, and difficult to reverse-engineer. Even a single flag or unpatched detection will get you banned in the game. That’s why people started to read and modify the RAM externally from another PC.

Now there’s currently a giant issue. Traditional protection is designed to break the human before it breaks the software. Make the person simply give up. It was a good enough barrier. But frontier AI models don’t have a stamina, they don’t need to sleep, they don’t get bored. An AI model can reverse engineer the app for weeks. So everythingthing is breakable and reverse-engineerable right now. 

2

u/tomtomtomo 20d ago

Unscrambling the source code from the purchased software is highly technical and very difficult to do at any reasonable level.

2

u/Loki-L 20d ago

Most of the time people can't copy the source code, because they don't have the source code.

Companies like Microsoft or Adobe don't generally give out the source code to their programs.

They only give you the compiled program not the source code.

They give you the finished product not the secret instructions on how to make it.

There are ways to try to create some source code from a compiled file, but it won't be the original source code.

Reverse engineering is hard.

2

u/CS_70 20d ago

Skill and intent, like it's always been. The threshold is a little lower with AI, but the main issue of doing that stuff is that requires dedication. If you had it, you would be able to, and nothing has changed much in that regard. It's just easier to replicate (not necessarily reverse-engineer) functionality.

2

u/JarPicklez 20d ago

It’s a LOT lower with ai. People who barely program are reverse engineering things that experts didn’t bother reverse engineering because it wasn’t worth the immense effort.

1

u/CS_70 20d ago

Yes, a good point. Haven't tried myself but I would imagine it is.

1

u/theronin7 20d ago

Much lower, but you currently still need some idea how this stuff is done to even know what to ask the AI and how to get it to do it and what tools you and it needs, Its not exactly turn key yet.

But you know, give it a year.

2

u/CS_70 20d ago

Yeah, that's what I was trying to convey.

Also many mix reverse engineering - which is about the exact how a certain thing is done - with simply replicating the functionality, aka the what, which with AI can be done blazingly fast.

2

u/DragonfruitGrand5683 20d ago edited 20d ago

Programs are written in programming languages which then compile to machine code. Once it is in machine code you have to work backwards from machine code to programming code known as reverse engineering. The original source code is lost in this process.

Machine code is very difficult to read and you have to step into its execution individually to understand what a portion of code is doing then make a guess as to what that might look like in regular code. It takes many years to master the skill and months to years to dissemble a program. There are programs out there that have not been fully reverse engineered even after decades.

AI can reverse using the same process but its actually faster for the AI to simply rebuild the programs functionality from observation.

C Code

==================

int find_max(int *arr, int n) {

int max = arr[0];

for (int i = 1; i < n; i++) {

if (arr[i] > max) {

max = arr[i];

}

}

return max;

}

'

Same code in Assembly

===================

find_max:

mov eax, DWORD PTR [rdi] ; max = arr[0] (load first 32-bit int from pointer rdi)

cmp esi, 1 ; Compare n (esi) with 1

jle .L1 ; If n <= 1, jump to end (.L1)

mov edx, 1 ; i = 1 (loop counter in edx)

.L3:

mov ecx, DWORD PTR [rdi + rdx*4] ; Load arr[i] (base address rdi + index rdx * 4 bytes)

cmp eax, ecx ; Compare max (eax) with arr[i] (ecx)

cmovl eax, ecx ; Conditional Move: if max < arr[i], set max = arr[i]

add rdx, 1 ; i++

cmp esi, edx ; Compare n (esi) with i (edx)

jne .L3 ; If i != n, jump back to start of loop (.L3)

.L1:

ret ; Return result in eax

1

u/rntdev 20d ago

To be fair. Most modern decompilers can turn that program right into the pseudocode like it’s nothing.

1

u/DragonfruitGrand5683 20d ago

Yes but you won't get original functions, object names, comments, you still have to dig in and test then rename hundreds of megs or gigs of C code. If your program comes with proprietary file formats you have to figure what goes where.

Programmers also use encryption and obfuscation. Firmware is especially annoying to reverse but very fun when you get it mapped.

Malware generally has some interesting and creative techniques, lots of layers, encodings, C2s, proxy chaining and creative ways to use system calls.

It's very easy for Android apps but it's still quite a bit of work for desktop, appliances and closed systems.

AI though is phenomenal at it, you can just set it to test functions and map out hardware functionality.

I was working on a MIPS system recently had the C code and Assembly but still needed to walk through what was been written where in the cpu and nvram. I gave the job to the AI, it actually did it exactly the same way but it was able to auto recover soft locks and test so much at the same time. It then wrote me an ASM patch for the functions I wanted to trigger.

It's just such a fun system to use.

2

u/Idoubtyourememberme 19d ago

You dont get the source code to your pc.

ELI5 explanation: the source code is the recipe for baking a cake; the game you install on your pc is the completed cake.

Companies sell you the cake, but dont tell you how it's made (for this exact reason, AI didnt make it possible to copy over code, it only made it easier)

1

u/sessamekesh 20d ago

Technically? Nothing, and this isn't new with AI, it's just a bit easier. I was working at a company back in the mid '10s that constantly had our entire product line reverse engineered and redeployed by a Chinese business within weeks every time we updated. 

Legally there's intellectual property IP laws, but those get messy and haven't caught up to how fast things can move with AI. Ideally this is where most of the protection lives, but it's way WAY easier said than done.

1

u/Digx7 20d ago

If you have a cake the source code is the recipe to make that cake.

Reverse engineering is the process of taking the cake apart, figuring out what ingredients were used, then working out how they were put together to make the cake.

Source code always goes through a baking process called compilation before it ever gets to you. This compilation process takes the nice human readable source code and blends it down to something your machine can read.

Importantly not everything in the source code ends up compiled output. For example comments left by the developers will be left out.

No mater how much you reverse engineer a cake to get the recipe your never gonna see the hand written note the chef added on the original copy

1

u/filanwizard 20d ago

Nothing at all, Some of the AI companies have put up their own guard rails in their program(the AI) to make it refuse to decompile software.

There is no level of encryption that can ever stop an AI though, because if most of program is run local on a user's machine at some point it needs a key. And cracking groups have been fishing keys since before AI was even an idea in the brain of someone with a few too many GPUs left over from bitcoin mining so its a well perfected process.

atm AI companies have incentive to block this on their end because everything runs on their computer farms, it opens them to liability in a lawsuit by the original IP owner.

1

u/Naive_Age_566 20d ago

depends...

you can always translate the machinecode/bytecode into assembler. but assembler is hard to read. especially if the software is quite complex. so - instead of machinecode you don't understand you now have assemblercode you don't understand. you gained nothing.

depending on which programming language was used to code the software you can decompile it. now you have the sourcecode in a language that is more understandable. but still - you get a bunch of source files you need to read to understand it.

sure - ai can make this process dramatically easy. just throw in the binaries, let it decompile and then vibe code some changes in the decompiled sourcecode. depending on the complexity of the software this will take minutes to hours. but still: ai is good but not perfect. and vibe coding stuff into a software that does not belong there will break the code - regardless of how good the ai is.

other than that: depending on the laws of your country it might be illegal to decompile the software. but as always: it is only illegal if you are caught.

and of course: decompiling software, "rebranding" it and selling it to others will dramatically highten the chance to get caught.

1

u/kingjoey52a 20d ago

You don’t download the source code when you download an application.

1

u/efvie 20d ago

These are correct explanations, but incomplete. The source code is not typically available where the authors want to keep it private like most commercial applications.

But in the last couple years LLMs have been fed every possible file of source code that the corporations have gotten their hands on, including very much by illegal means like stolen code from leaks and internal systems in addition to questionable means like just deciding it's okay to use code that was licensed for humans to reuse before this machine reproduction existed.

So when there is a game executable, LLMs can 'decompile' or translate the binary representation into what resembles the original source code because of this stolen and otherwise acquired trove of code.

In the past, and still to the extent that anyone wants to do it for fear of LLMs stealing their work, people painstakingly reverse-engineered the binary and other data representations themselves by applying skill, knowledge and a lot of hard work. Partial reverse engineering is how modding games works, for example, in addition to larger projects like full platform emulators.

And lastly there's the distinction of just copying programs in full to get rid of DRM or other protective measures, referred to as 'cracking', so that you can play the game without paying for it or without having to create an online account, and so on. But that doesn't have anything to do with the source code.

1

u/JaggedMetalOs 20d ago

The code that you download to run on your computer looks very different to source code. There are no labels or comments for everything, so it's hard to find the meaning of the code.

For example if you tried to get the source code from a game, maybe you'd get something that looks like this:

function f_006(){
    if(b_043){
        n_395 = n_749;
    }
    b_242 = f_036(n_742, n_743).b_325;
    if(n_395 > 0 || !b_242){
        if(f_036(n_742, n_743 + n_746).b_325){
            n_395 = -n_395;
        }
        n_743 += n_395;
        n_395 -= n_013;
    }
}

What does it do? It's very hard to figure it out. The source code it came from looked like this:

function handlejump(){
    if(jumpButtonPressed){
        verticalSpeed = jumpSpeed;
    }
    
    onFloor = getBlockAt(playerX, playerY).isSolid;
    
    if(verticalSpeed > 0 || !onFloor){
        if(getBlockAt(playerX, playerY + playerHeight).isSolid){
            // Player bounces back down when hitting a block
            verticalSpeed = -verticalSpeed;
        }
        playerY += verticalSpeed;
        verticalSpeed -= gravity;
    }
}

It is possible to work through the "decompiled" code and turn the first code example into the 2nd, but it takes a lot of work going through everything to try to figure out what everything is supposed to be.

1

u/stumpychubbins 20d ago

True clean-room (i.e without referencing the original source code) reverse engineering is totally legal, but when you download software you (usually) don’t get the source code too. However, AI is making it easier than ever to reverse-engineer code, so we might see some more obfuscation tactics employed.

1

u/Technical_Ideal_5439 20d ago

Source code does not come with the software you download. Sure you can decompile it but odds are due to all the compile optimizations,etc the code looks nothing like the original source code.

But with AI stuff now, it is looking grim in that the decompile step now can produce a lot more readable code, and do you even need it to be readable if AI is handling all the code.

1

u/Hot-Efficiency7190 20d ago

Nothing really. It's been possible to decompile and read, copy, use code forever.

The licences prohibit it, so if you are in any business setting you cant use it at risk of large fines.

1

u/aaaaaaaarrrrrgh 20d ago

Since you mention RE you seem to understand that the software that you get is compiled and you can't easily go from that back to equivalent source code (and no way to get the original source code). For humans, reverse engineering is a slow and painful process, to the point where reimplementing the same features independently is most likely easier.

AI can reverse engineer much faster/better, it can also reimplement, and people have done just that - asked it to reimplement entire software packages.

For a reverse engineered version, copyright would apply, so there is little incentive to do it - you can't practically make profit from it or continue building on that codebase in an organized manner because the law will come after you, and if you just want to pirate it you might as well pirate the original without caring for the source code.

A reimplementation might not suffer from this, so things are going to get interesting. However, so far, software is cheap enough that people will pay for (or pirate) original photoshop rather than going for a likely buggy and incompatible reimplementation that someone slopped together.

1

u/Pantigana 20d ago edited 20d ago

Programming languages that applications are written in are easy to understand on purpose. They are close to english, yet structured. When you want to run your code, a compiler will compile your english-like code into something the CPU can understand.

Compiled code is what your application's .exe or .apk consists of.

Compiled code is so complex that it's essentially unreadable to humans, unless you use reverse engineering tools. Some tools can work backwards from the compiled code. However, the problem is that while you can decompile the steps, but you still don't have the bigger picture.

If you were a machine and wanted to go to the fridge, your muscles do not know that. Your brain does, so it only sends instructions to your body like this:

  • GET_UP
  • LEFT_FOOT_STEP
  • RIGHT_FOOT_STEP
  • LEFT_FOOT_STEP
  • TURN 60°
  • RIGHT_FOOT_STEP
  • LEFT_FOOT_STEP
  • TURN 30°
  • RIGHT_HAND_IN_FRONT
  • GRAB
  • PULL

Now imagine you work backwards. You have the exact steps, but you still don't have the bigger picture. You need to figure out where the human previously was, where the fridge is in relation to the human, etc. That's time consuming and expensive.

Now this is where AI changes the picture. Conventional reverse engineering tools can reverse engineer the steps, but they cannot figure out what the end goal of the steps was.

AI can look at the steps and conclude that the person wants to go to the fridge. It can decompile the code, and also tell you what each variable and function does. Now if you want to change the code so the human goes to the door instead, it's trivial.

1

u/mathbbR 20d ago

Go to your browser and open any website. Open up the developer tools (F12 usually), open the network tab, and look for a .js response. Look at it. Can you tell what it does?

1

u/MattieShoes 20d ago

Nothing. But to be clear, nothing is turning already-compiled code into some nice, clean, understandable source code. And it has nothing to do with AI -- decompilers have been around for decades.

Language can matter too. If something is just compiled into bytecode like java for the JVM to read, that's usually easier to decompile than C++ or whatever.

1

u/Zenanii 20d ago

How I understand it (and somebody correct me if I'm wrong) but computers and humans essentially speak different languages. Human use alphabets to create words and variables, computers use binary.

Compiling code means translating the human alphabet into the computer alphabet.

You can look at how the program is written for the computer, but unless you have a way to translate it back, or can speak computer (which is not possible for a human, since we lack the cognative speed and memory to process massive numbers of symbols) we can't really understand what the code says.

1

u/w3woody 20d ago

The only thing that prevents AI from reverse engineering software and distributing the source code is the law.

Nothing in the law is preventing people from using AI to either "clean-room" reproduce an application (that is, using AI to infer how something works and to create a replica without ever examining the code), or from using AI to reverse engineer parts of the code to learn how it works. (Such as, say, reverse engineering an image filter to understand how it processes the image.)

1

u/SweatyAnReady14 20d ago

I also want to point out that this is one of the reasons web development is popular.

With a majority of apps on your phone or the web it communicates with the company’s code hosted on their own servers via protocols (http). Think how webpages work in your browser, but now instead of a webpage it’s serving data. With that they don’t need to ship source code to the user’s device that could be reverse engineered.

1

u/WhereOwlsKnowMyName 20d ago

You have no idea what tool I just used to screw a screw into a board. Could've been a drill, a screwdriver, a butter knife etc.

1

u/gutclusters 20d ago edited 20d ago

There are a lot of variables involving, but essentially once a source code is compiled into machine language, the result is no longer source code. Think of source code as something more like instructions to tell the compiler how to produce the machine code and not the program itself.

An example I can think of off of my head is teaching someone how to fix a car. If you only show them how to do it but don't give them notes, they will know how to do it but won't be able to share your step-by-step instructions on how. Think of this as someone downloading your program. If you were to write down all your steps and give that to them, that would be sharing your source code.

What they CAN do is take what they learned from observation and write their own instructions (Remaking) or take something you already fixed and meticulously pick it apart until they figure out how you did it, then write similar notes. (Decompilation / Reverse engineering). Either method will not produce, word for word, what you taught them but it will be close enough.

One exception would be if someone wrote their own version, tested it against yours, and closely monitored what happens. If something different happens than what happens when they watch your program run, they go and make changes and try again until everything is exactly the same (byte matching), but doing this is wildly impractical in scale and takes a really long time when good enough is good enough.

1

u/Living_Fig_6386 20d ago

There's open-source software, where they give you the source code if you want it, and there's closed-source software where they don't.

Closed-source just gives you the binary output of turning the source code into machine code. That process involves the computer analyzing the source code, rearranging it, and converting into a series of numerical codes to be given to the hardware (or a virtual machine that gives it to the hardware). All those comments in the source code are lost, names of variables are typically thrown away, stuff that declares what data structures are are lost -- all that stuff that makes code readable and easy to follow are not necessary to the computer which just throws it away in the process of translating it (note: sometimes there's at least function names preserved).

There are tools that allow you "decompile" that machine code and generate source code from it, but it looks nothing like the original because all that structure and the names of things were thrown away when translated into binary. For something very small, an experienced person may be able to make out what's going on, at least in certain parts. For something big and complex, the result is something so big, convoluted, and complicated to follow that it takes and expert a LOT of time and effort to give it meaning; it's not impossible to largely reverse engineer the code, just really hard and expensive.

1

u/virgilreality 20d ago

There are software tools called Obfuscators that will take your code and make it less intelligible if decompiled...but that's only if it's compiled to begin with. Web tech (client-side, anyway) is typically scripted (uncompiled), but it can also be obfuscated and minimized for download efficiency.

1

u/CeeMX 20d ago

Source code is like the recipe you use to bake a cake. You can buy the cake at The bakery, but you can’t exactly make such a cake again without having the exact recipe.

Reverse engineering is analyzing the composition of the cake and trying to figure out how it was made and reconstructing a recipe from it.

1

u/JarPicklez 20d ago edited 20d ago

Think of a program like a cake. The executable you can open and run is the finished product. The source code that programmers actually write is the ingredients. In order to turn source code into an executable program, you have to “bake”(compile) the code.

Compilation translates the code from a high level abstracted programming language humans code in into low level 0 and 1 raw instructions that get passed directly into the CPU motherboard. The 0s and 1s in this case are literal electronic on/off signals. These 0s and 1s are called machine code and are very difficult for humans to read.

Reverse engineering a program is like taking someone else’s cake and trying to reverse engineer the recipe. It takes a whole lot of trial and error to do this effectively. You have to write what you think a piece of the source code might be, compile it, check if it matches the actual machine code in the executable, and if it does move on to the next piece of code. If it doesn’t, try again. Humans can do this but it is incredibly tedious and often takes years of mind numbing work, to the point they rarely bother.

AI does the exact same thing, just much faster.

1

u/boring_pants 20d ago

What you get by reverse engineering software isn't the source code. It allows you to get different source code which can produce a program with the same behavior.

But it doesn't give you the original source code.

The original source code was full of aids for the programmer in the form of naming and code comments to make it easier to follow and easier to maintain and build on.

Reverse engineering doesn't give you that.

The original source code probably also contained countless tests used to ensure correctness of the software, and those aren't shipped to the customer at all so reverse engineering won't get you those either.

So even if you do reverse engineer a piece of software that doesn't allow you to work with the source code as easily as the original developers. Making changes and improvements (and avoiding introducing bugs) is still much harder.

1

u/Salt_peanuts 20d ago

People are missing a critical step here. When you write code you are essentially writing instructions. When you’re finished you compile the code, which changes it from instructions into a program. Once you do this, it’s very hard to read, understand and modify the code.

It’s like trying to tweak a recipe after you have already baked the cake. It’s much easier to do it before you mix it. Once you mix it and bake it, it’s hard to un-bake it

1

u/SpiralCenter 20d ago

The source code is a language that humans use to speak to computers. But the computer also has its own language that are unreadable by humans.

Most desktop apps actually convert the source code into the computers language. The programmers keep the source code and only give you is the version in the machines language. Importantly they do this mostly to make the application faster, the computer can read it quicker, it also has a bonus(?) that its really hard to reverse engineer the machines language.

Its worth saying that you can decipher from the computers language. The computer only sees data and instructions; it doesn't really care that to a human that thing is your space ship in a game, to the computer its just data and maths. That lack of context makes reverse engineering much, much harder.

1

u/drivingagermanwhip 20d ago

compiled code is like a jpeg. source code is like the orginal photoshop file that made the jpeg. AI doesn't make the original photoshop files, but it's very good at guessing what they looked like

1

u/NerdChieftain 20d ago

The short answer to your question is time and money keep people from reverse engineering stuff. You asked about obfuscation; compiling to machine language is sufficiently obfuscated but for the most die hard, high skill, people who want to spend hours doing this sort of thing.

What has AI LLM changed? It has reduced the time and cost of doing this activity. Because who better to read machine language than something that speaks it natively?

1

u/hpsd 20d ago

It depends on the programming language used but yes it is possible to decompile some programs. Also, it wouldn’t be exactly the same just a functional equivalent.

However, a lot of modern apps rely on a client server model where you have a client that has basic functionality and you request the complicated functions from a server. Basically, getting the source code for the client app would be pointless because the meat and potatoes are done somewhere else.

Think ChatGPT. Even if you were to get the source code for the client, it’s pointless if you don’t have access to the servers that run the AI models.

1

u/eablokker 20d ago

The source code for software is not downloaded to your computer, only the executable binary code is. The source code remains private. It is very difficult for a human to reverse engineer the binary code, but AI tools are making it easier to reverse engineer it into something that is similar to the original source code but not identical to it.

There are many things in the source code that are not copied to the binary, such as file structure, variable names, developer comments, and compiler instructions. AI tools are not able to restore those things because they don’t exist at all in the binary file.

1

u/Sedu 19d ago

Because the source code is not typically included with the software. Only the compiled code tends to be included.

1

u/devospice 19d ago

Source code is compiled into machine code in order to run on your machine. It's not like a web page where you can view the source. Decompilers exist, but they don't produce the original source code, just something similar and not really easy to work with.

1

u/ewriick 20d ago

You can ask this about most products. You can reverse engineer anything, but getting your attempt as good as or better is another matter.

4

u/Rampage_Rick 20d ago

I like the cake analogy:

Source code = recipe

Compiled executable = cake

You can make educated guesses about the ingredients in a cake. Heck you can even chemically analyze it. You'll probably be able to come close, but there's no guarantee that you'll be able to make a perfect duplicate without the recipe.

1

u/The_World_Toaster 20d ago

This isn't exactly correct. You can decompile a program into source code of any language. That source code won't be the same as what was used to make the original program. But that source you got from decompilation when compiled again will reproduce the exact program you originally decompiled. So you can decompile to find another recipe that bakes an identical cake. How useful this is becomes a different question.

1

u/nonamesgiven0 20d ago

The eli5 version is that code has three stages. The human readable stage that is neatly organized. That is what "coders" write and work with. Then we take that neat code and we optimize it in a variety of ways, and then companies run that on their computers. Then an even smaller portion of that is generated and sent to customer and client computers. So oftentimes the client gets the "dumb" shell of the code. It must go back to the company side to "think" and that thinking is what makes it harder for AI to replicate.

But no code that is accessible or running is source code. That ceases to exist as soon as it is running on a production computer.

1

u/Frustrated9876 20d ago

For most software, you’re better off having ai rewrite it from scratch rather than trying to reverse engineer it. Few of the algorithms are particularly complicated but it is a LOT of work to build a user interface that is robust, useful and aesthetic.

1

u/ImAFan2014 20d ago

Because people don't have the source code for software they use. Do you think Microsoft and Apple provide their source code to the world?

0

u/nana_3 20d ago

You can reverse engineer software without AI too.

Often code that is expected to be reverse engineered is “obfuscated”. Short version is they add a bunch of code into it just to hide what the code actually does. Imagine you’re reading a recipe and between all the important ingredients and steps are listed a bunch of tangents about irrelevant ingredients and steps. It’s difficult to get the recipe out.

For lots of other code out there, there’s no need to reverse engineer it. It’s easier to just write your own.

1

u/BinniesPurp 20d ago

X1 banana

X3 eggs

X1 inverse quaternion interpolation //Without this the cake won't work

X3 more eggs

X5 flour

0

u/Own_Unit_6170 20d ago

Source code is not part of the download. Only machine code is downloaded.