From my understanding, self propagating worms generally work in the following way:
Let's assume an exploitable vulnerability is found in MegaFTP. This allows for code execution on the box with MegaFTP installed. Instance 1 of MegaFTP is compromised. It will call back and download a copy of the worm. The worm will then scan other devices looking for MegaFTP. Probably with a port scan or the data in a TCP/UDP reply. something like ---Welcome to MegaFTP version 1.0.4---
From there the cycle continues. Now, this is all my understanding, which could be completely wrong, I'm definitely not a malware expert.