It depends. If you are in a “state of venial sin”–that is, grace is injured in you, then see CCC 2565: “In the New Covenant, prayer is the living relationship of the children of God with their Father who is good beyond measure, with his Son Jesus Christ and with the Holy Spirit. The grace of the Kingdom is ‘the union of the entire holy and royal Trinity . . . with the whole human spirit.’ Thus, the life of prayer is the habit of being in the presence of the thrice-holy God and in communion with him.” This communion with God in prayer will heal the injury to you.
We see this in Luke’s parable of the Pharisee and the Tax Collector (which we heard just nine days ago on Sunday, October 27!) where the tax collector prays, “O God, be merciful to me, a sinner!” and goes home justified. The Church continues to pray at every Mass, “Kyrie eleison! Lord, have mercy!” (CCC 2613)
And then CCC 2631: “The first movement of the prayer of petition is asking forgiveness, like the tax collector in the parable: ‘God, be merciful to me a sinner!’ It is a prerequisite for righteous and pure prayer. A trusting humility brings us back into the light of communion between the Father and his Son Jesus Christ and with one another, so that ‘we receive from him whatever we ask.’ Asking forgiveness is the prerequisite for both the Eucharistic liturgy and personal prayer.”
But you are right, in principle. If you are in a state of full (mortal) sin, and so outside of the state of grace, then you need the graces of the sacrament of confession (reconciliation), or its equivalents (reconciliation in the sacrament of anointing of the sick, or of course baptism if you have not yet been baptized) to return to grace.
Even then, though, the prayer of other such as Moses can intercede for us and move us to repentance and return to grace through the sacrament of reconciliation (CCC 2577)