Pry up the nails securing the shingles around the chimney with the claw of your hammer. Because the same set of roofing nails penetrates two shingles in each row, you must pry up two shingles on all four sides of the chimney to expose the old flashing.
Pry up and remove the old flashing using the hammer's claw.
Use the old flashing as a pattern for cutting new flashing. Mark the cut lines and the bend of each piece of new flashing with a permanent marker. Discard the old flashing.
Clamp each piece of flashing to a 2-by-4 block of wood with metal clamps. Place another 2-by-4 wood block over the flashing and strike it with a hammer. This bends the flashing to a perfect 90 degree angle.
Align the bend in each piece of flashing with the groove where the chimney meets the roof. Slide a shingle over the flashing until the edge of the shingle lies flush with the groove between the roof and chimney.
Nail the shingle to the roof. The nails will pass through the flashing and secure it to the roof simultaneously. Lay the second shingle in place, ensuring that it partially overlaps the first shingle. Nail the second shingle to the roof. Repeat this process around the entire chimney.
Squeeze roofing caulk into the gap between the top of the flashing and the chimney to further reduce your risk of leaks and water damage.