Marx's analysis suggests that capitalism exploits its workers through its lack of compensation. The factory owner or industrialist is able to make a great amount of money only because of the toil of the workers, who make proportionally less. The workers are subjected to conditions of hazard, long hours, and a small amount of compensation. Additionally, the manner in which workers are used and discarded also contribute to exploitation. In the end, the fact that capitalism is akin to a runaway train, where the desire for wealth supersedes all others, is where the exploitation happens. At the same time, Marx's vision of justice is where there is a public ownership of the means of production and wealth so that "each according to his needs" are met and that there is not a consolidation of wealth by the few, but rather in the hands of the many.
According to Karl Marx, workers are exploited in capitalism because they create value but they are not the ones who get the money that is paid when that value is bought.
Let's say I own a factory. I give you wood and you make it into furniture in my factory. I get paid more than you do even though you are the one who actually did the work. Thus, I am getting rich off of your work.
Marx does not actually say that capitalism is unjust. He actually says it is not unjust. As a website at Stanford University says
Capitalism's dirty secret is that it is not a realm of harmony and mutual benefit but a system in which one class systematically extracts profit from another. How could this fail to be unjust? Yet it is notable that Marx never concludes this, and in Capital he goes as far as to say that such exchange is ‘by no means an injustice’.
So I am not sure what you are asking about in terms of a formula of justice. My best guess is that it is "from each according to his abilities, to each according to his needs."
In this formula, everyone works as hard as they can and gets all that they need (and nothing more).
Yes, that is what is meant by the formula of justice.
but what does he state to justify it?