Is it possible to overcome poor undergrad performance with a masters at a much lower ranked institution?
As Roger Fan says in the comments, great recommendation letters would probably get you into a top program.  People at any decent research school will know people at top schools, so their letters can be trusted, and most of your faculty should be experienced enough to compare you with grad students at top schools.  (This is assuming you're at a reputable research-oriented state university, such as the main campus of a state university---there are some branches of state schools where I would not put much trust in the letters of recommendation).

As for you question about a great thesis, yes that help get you into a top school, but the most likely way this would happen is because a great thesis will generate great letters.