Yes; they are legal. As long as you receive 100% plagiarism-free work, you’re not breaking the laws. You can use the work as your own. Ghostwriting has always been around. Some of your professors relied on ghostwriters to write their books; they just don’t share the info. You can safely use a dissertation writing agency.