And each step of the operation is tracked, with a lot of beneficiaries along the way.

"When a ship is caught, the pirates call at the city. Everybody celebrates," the study says. "When the ship comes at the port, a crew comes to secure it. Everything is written down, every food, drink, any kind of transaction. The final amount will be deducted from the ransom at the end. The investor pays."

Pimps, cooks and militia benefit too

Cooks, pimps, lawyers and the militia controlling ports also get a piece of the pie.

The pirates' money is "typically spent on alcohol, khat, and prostitutes," the report said. "Proceeds from piracy are also reinvested into the financing of future pirate operations and may support the purchase of real estate, investment in the khat trade, and other business investments and ventures."

Pirates in Somali areas controlled by the al Qaeda-linked militant group Al-Shabaab also pay a development tax to access the ports, according to the study.

Although the piracy trade is controlled from Somalia, its effects spill into surrounding areas.

Proceeds are moved by the kingpins across borders through smuggling, money laundering and wire transfers, the study shows. And the funds are widely distributed among various industries.

Khat, a narcotic plant popular in the region, is another favored investment, with pirates establishing their stakes in the trade. In neighboring Kenya, the drug is traded without much government oversight, making the nation a lucrative supplier, the study shows.

It may benefit some people financially, but piracy has evolved into an international nightmare, hurting economies and sending the cost of living soaring.

Though incidents of piracy have plummeted since 2011, it costs the global economy $18 billion a year in increased trade expenses, according to the study. It has reduced maritime activity in affected waters, affected tourism and led to the closure of money transfer services, a lifeline for some communities.