Regarding John the Baptist, the parallel passage in Mt 3 makes it clear that he was calling the scribes and pharisees a brood of vipers.
The account in Matthew is much shorter than the one in Luke. In Luke we are told that right after John gave that rebuke and warning,
"the people asked him, saying, "What shall we do then?" 11 He answered and said to them, "He who has two tunics, let him give to him who has none; and he who has food, let him do likewise."
That indicates that the people in general got the sense that he was also addressing them. Concerning the passage in Luke this is what Matthew Henry writes, which I agree with:
"In Matthew he is said to have preached these same things to many of the Pharisees and Sadducees, that came to his baptism (Mt. 3:7-10); but here he is said to have spoken them to the multitude, that came forth to be baptized of him, v. 7. This was the purport of his preaching to all that came to him, and he did not alter it in compliment to the Pharisees and Sadducees, when they came, but dealt as plainly with them as with any other of his hearers. And as he did not flatter the great, so neither did he compliment the many, or make his court to them, but gave the same reproofs of sin and warnings of wrath to the multitude that he did to the Sadducees and Pharisees; for, if they had not the same faults, they had others as bad. Now observe here,
1. That the guilty corrupted race of mankind is become a generation of vipers; not only poisoned, but poisonous; hateful to God, hating one another. This magnifies the patience of God, in continuing the race of mankind upon the earth, and not destroying that nest of vipers. He did it once by water, and will again by fire.
2. This generation of vipers is fairly warned to flee from the wrath to come, which is certainly before them if they continue such; and their being a multitude will not be at all their security, for it will be neither reproach nor loss to God to cut them off. We are not only warned of this wrath, but are put into a way to escape it, if we look about us in time.
3. There is no way of fleeing from the wrath to come, but by repentance. They that submitted to the baptism of repentance thereby evidenced that they were warned to flee from the wrath to come and took the warning; and we by our baptism profess to have fled out of Sodom, for fear of what is coming upon it.
4. Those that profess repentance are highly concerned to live like penitents (v. 8): "Bring forth therefore fruits meet for repentance, else, notwithstanding your professions of repentance, you cannot escape the wrath to come." By the fruits of repentance it will be known whether it be sincere or no. By the change of our way must be evidenced the change of our mind.
5. If we be not really holy, both in heart and life, our profession of religion and relation to God and his church will stand us in no stead at all: Begin not now to frame excuses from this great duty of repentance, by saying within yourselves, We have Abraham to our father. What will it avail us to be the children of godly parents if we be not godly, to be within the pale of the Church if we be not brought into the bond of the covenant?
6. We have therefore no reason to depend upon our external privileges and professions of religion, because God has no need of us or of our services, but can effectually secure by his own honour and interest without us. If we were cut off and ruined, he could raise up to himself a church out of the most unlikely,””children to Abraham even out of stones.
7. The greater professions we make of repentance, and the greater assistances and encouragements are given us to repentance, the nearer and the sorer will our destruction be if we do not bring forth fruits meet for repentance. Now that the gospel begins to be preached, now that the kingdom of heaven is at hand, now that the axe is laid to the root of the tree, threatenings to the wicked and impenitent are now more terrible than before, as encouragements to the penitent are now more comfortable. "Now that you are upon your behaviour, look to yourselves."
8. Barren trees will be cast into the fire at length; it is the fittest place for them: Every tree that doth not bring forth fruit, good fruit, is hewn down, and cast into the fire. If it serve not for fruit, to the honour of God's grace, let it serve for fuel, to the honour of his justice."