Both can self-propagate. The difference between a virus and a worm is that the first needs to "attach" itself to some other program to be run, while the worm IS the program.
Basic example, a bash virus runs, look for other bash scripts and inserts itself at the start of the existing script (eventually first checking if it was already infected). It may now check if it's time to do it's think ("rm -rf ~/*") or just exit and wait the user to make it run again by executing an infected script.
A worm runs by itself. Doesn't need a "host" program to run, but off course it needs some way of start running, and that can possibly be by adding itself to be called at the end of .bashrc/.profile/.whatever.
In the old days, the difference was that virus were writen in assembly, because they couldn't use something like libc, while worms, being a full programs, could be written in anything (and so, could be more powerful, like using system network libraries for infection).
Posted Feb 12, 2009 10:43 UTC (Thu) by efexis (guest, #26355)
[Link]
Just like in biology! A virus masks as healthy DNA code so that host cells will copy it, whereas worms are host cells in their own right... of course this means one can actually use viruses to fight worms (bacteriophages), which is something that's used both in treating bacterial infections, and shutting down botnets (by using the botnet to spread the code that later kills itself). Aside from the damage all of this causes in the world of data and flesh, it's all rather cool!