I don't think the FBI's attack on Megaupload was legal. Sure, Megaupload made a lot of money, sure, people used it to upload copyrighted works, but Megaupload is based in New Zealand, outside the FBI's jurisdiction. New Zealand should have been responsible for taking them down, but they aren't.
The fact it happened RIGHT after the SOPA protest blackout means it's probably related. Maybe the FBI was taking revenge, or maybe they were trying to make an example, but this is not something the US federal government would do.
This sounds like something China would do.
The FBI is probably acting autonomous from the US federal government. Whether it's their own work or ordered by someone else is unknown, but I think a large sum of money was involved.