As we all know, sophism is regarded as the immoral, malformed twin of philosophy in Plato's dialogues. Socrates sees a fundamental distinction here:
However, as I put it, cookery is flattery disguised as medicine; and in just the same manner self-adornment personates gymnastic: with its rascally, deceitful, ignoble, and illiberal nature it deceives men by forms and colors, polish and dress so as to make them, in the effort of assuming an extraneous beauty, neglect the native sort that comes through gymnastic. Well, to avoid prolixity, I am willing to put it to you like a geometer—for by this time I expect you can follow me: as self-adornment is to gymnastic, so is sophistry to legislation; and as cookery is to medicine, so is rhetoric to justice. But although, as I say, there is this natural distinction between them, they are so nearly related that sophists and orators are jumbled up as having the same field and dealing with the same subjects, and neither can they tell what to make of each other, nor the world at large what to make of them.
Gorgias, 465b-c
But how is this compatible with the sophists that Socrates actually meets?
Sure, Euthydemos and his brother Dionysodoros are pretty ridiculous. But they don't seem dangerous, or able to corrupt people's minds - they only stump the audience with their tricks but hardly influence it. They are of advanced age, so we know that they dedicated their whole lives to be basically professional clowns while not attaining any wisdom. They're just tragic figures.
Protagoras is one of the few conversational partners who are on the same intellectual level as Socrates. In the dialogue of the same name, he doesn't seem to be overly manipulative and despite some flaws (his ego), he comes across as a sympathetic and insightful man. In the Theaetetus he holds extreme views about the nature of knowledge, but are they really more extreme than many Platonic ideas (e.g. anamnesis, the utopia in The Republic)?
Gorgias is perhaps the most problematic (he identifies as an orator, but Socrates sees not much difference to a Sophist - see quote above). He treats Socrates mostly fair and remains polite (despite Socrates' harsh words), but he is morally uneven and tries to weasel himself out of any responsibility for the bad effects of rhetorical art. And his student Callicles, a kind of proto-Nietzsche, is the best example of how bad those effects can be.
The overall picture is very mixed. So how is this condemnation of sophism without exception and this binary dichotomy of sophism vs. philosophy compatible with the actual sophists in the dialogues?
In the dialogues, which supposedly show us the real world, the binary distinction does not exist and sophism and philosophy seem to rather exist on a spectrum.
Every philosopher is a sophist to some degree (in the Sophist dialogue, we learn that Parmenides has unintentionally supplied the foundation for sophism), and the other way around.