Back to the Moon worm, it begins the attack by requesting a /HNAP1/URL from devices behind the scanned IP addresses. The HNAP (Home Network Administration Protocol) allows configuring and managing the networking devices. So, the request to HNAP brings in the model of the router and version of the firmware. The device being vulnerable, allows the worm to send another request to a particular CGI (Common Gateway Interface) script which allows the execution of local commands.
The name of the CGI script that attacked the Linksys routers remains disclosed, having been known to have contained authentication bypass vulnerability. The worm sends random admin credentials but they are not checked by the script, which the Linksys was aware about. Following the CGI script request, the second request will launch a simple shell script that will request the actual worm, which is about 2MB in size.
Once the code is run, the router scans for other vulnerable victims around. Mission accomplished. It is then the dominoes start to fall. Upon scanning and infecting the victims, they in turn scan for more vulnerable devices around.