When the SEC files a lawsuit, the government gets the money.
A "derivative action" can be filed but only by a shareholder, and it is filed against the management and Board of Directors, and it is the company itself that receives any funds that are derived.
A shareholder can also file a class action against a management and its Board, and the company itself. This is done on behalf of all shareholders that purchased shares between specified dates (and only those shareholders). The dates are determined by when the purported improper conduct began, and when it was reported. The shareholders usually get what amounts to a cup of coffee while the lawyer that manages the class action gets rich (I recently received a coupon for an oil change at my favorite auto dealership after the nationwide chain was sued for overcharging customers in the service bays).