CNN) -- Pirates off the Horn of Africa hauled in hundreds of millions of dollars in recent years -- and funneled those funds into drugs, prostitution, real estate and other ventures.
Somali pirates and their peers hijacking vessels in the region made about $400 million in ransom over the past eight years, according to a report published Friday.
The report, Pirate Trails, was conducted by the United Nations crime unit, Interpol and the World Bank. It tracks the underbelly of the pirate world in Djibouti, Ethiopia, Kenya, Seychelles and Somalia.
Most of the funds came from exchanging captives for ransom, an increasingly sophisticated process mostly controlled from Somalia.
In the boat patrolling for pirates
In total, 179 ships were hijacked off the coast of Somalia and Horn of Africa between April 2005 and the end of 2012. About 85% were released for ransom.
Kingpins and foot soldiers
Pirate financiers, considered the "money kingpins," earned the most loot -- about 30% to 50% of the total ransom paid, the study shows.
Low level pirates, mostly foot soldiers sent to the high seas to do the dirty work, earn between $30,000 and $75,000 a vessel.
Pirates who board the vessel first or use their own weapons in an operation get a bonus $10,000, the study says.
Rewards aside, there is also punishment.
Those who refuse to follow orders, mistreat the crew or fall asleep on the job get fined, according to the study,
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.
"Pirate financiers invest into a range of sectors ... some of these proceeds are recycled into financing criminal activities, including further piracy acts, human trafficking and investing in militias and military capacities on land in Somalia," the study says.
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.
"Unchallenged, piracy is not only a menace to stability and security, but it also has the power to corrupt the regional and international economy," said Stuart Yikona, a World Bank senior financial sector specialist and the report's co-author.