Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Legal? In most countries it would not be illegal to work for two companies. You may violate contractual agreements, though.
That said, think of yourself first. Do you want to work for your old manager? They have the source code, in theory they can find somebody else.
From your description, it seems like they want to take advantage of you. Don't let that happen. Negotiate a rate that you are comfortable, make sure it's not low, you have nothing to lose here. They came to you and not you to them after all.
Can you get a contract with them as software consultant, so at least they pay you for the job done?
If you're unsure, I bet there's someone at your university who can help about your legal question. Never pay out of your own pocket to support an employer's business.
Sometimes, 'no, thank you' is the right answer. This might be one if those times.