r/AskProgramming • u/eeeeeeevar • Oct 10 '26
Architecture Theoretically, could you make a virus that evolves under evolutionary principles?
The most basic part of evolution is, simplified:
- shit reproduces
- there is a random chance of mutation
- mutations more advantageous in the environment spread.
So in theory, could you create a computer virus that function under the same principles as an actual virus? Have it so that every time it reproduces, it makes a new copy of itself there’s a random chance to make random changes to its own code? Most of the time it would result in the virus breaking, but that’s also true for IRL.
7
Upvotes
11
u/sock_dgram Oct 10 '26
It's called an "Evolutionary Algorithm."
4
u/KingofGamesYami Oct 10 '26
That's one of the major known strategies for producing machine learning algorithms, pioneered in theory around 1950, with the first practical implementation emerging in 1981. There was also a surge of interest in this field from 2012-2018.
1
u/RealNamek Oct 10 '26
Yes, they have done this before. Not just as a virus, because that makes no money, content is made this way. You think every reddit article, comment section, youtube feed is exactly the same for everyone? What do you think FOR YOU means, it's literally an evolutionary alogirthm to feed you exactly what you want, at all times.
1
u/drbomb Oct 10 '26
Evolution is not about randomness but selection of beneficial traits.
1
u/SnugglyCoderGuy Oct 10 '26
Yes, but the chances of it not fizzling out almost immediately is next to zero.
Biological viruses have millions and trillions of chances of reproduction because the act on individual cells of any given organism, and there could be millions or billions of organisms it is acting upon.
There is also a humongous margin of error when it comes to DNA/RNA mutations versus mutations in code. One bit off and everything goes to shit. One different in nucleac pair could end up being completely benign. Most DNA is 'junk'.
1
u/owp4dd1w5a0a Oct 10 '26
Yes. And I think using genetic algorithms in a lisp language where the evolutionary algorithms involved (re)write and inject their own code would be incredibly interesting. In fact, this has been done and the most interesting form is called “autoconstructive evolution”.
https://dl.acm.org/doi/10.1023/A:1014538503543
1
u/Savings-Cry-3201 Oct 10 '26
The earliest one I’m thinking of was back in the 40hex days where one of the viruses highlighted would remix its code and add random bytes in while modifying its jump codes to dodge the random bits. That’s less of an evolution and more polymorphism. It was cool af though, an early method of trying to avoid antivirus heuristics.
The chance of adding random opcodes and generating something useful is incredibly small. Actual viruses replicate in the trillions and they simply have a bigger space to play in.
0
u/SgtSausage Oct 10 '26
LOL.
You've never written a line of code in your life. hava ya, Scooter.
-1
u/Worth-Wonder-7386 Oct 10 '26
In theory yes. The problem is that evolution is very slow and you need a good basis. And it would be hard to link the performane to the spread. Remember that real life viruses are selected for their own survival, not to perform some other goal.
And for viruss they have way more cells to try on than there are computers you get access to. but there are evolution based programs that you can run to try to optimize how a virus would work.
-1
u/Temporary_Pie2733 Oct 10 '26
Not just in theory; it’s been done in practice.
https://kk.org/mt-files/outofcontrol/ch15-a.html
-1
u/BoBoBearDev Oct 10 '26 edited Oct 10 '26
Yeah, maybe, but such ingenious virus probably takes 8GB of RAM and I only have 8GB of RAM. The software has to be so smart to write code, like a mini ChatGPT. Otherwise your mutation is so limited, it is not mutating in any meaningful sense.