Replace fire bricks in fireplace
If the firebox looks like that the inside of the chimney probably looks worse.  This is not a DIY job you need to have a pro run a chimney inspection camera down the chimney or your risking a chimney fire.  If you are feeling that lucky then buy a lottery ticket and your winnings will pay for the chimney guy. ;-)