There'll be 6 wires in there. 12v + & -, a tamper pair and an alarm pair. You need to power down the panel as there are some small fuses in the panel, if you just go at the cables in the sensor you'll most likely pop one of the fuses for the 12v power. Colours used can vary so you'd need to make a note of what cable is doing what in the sensor. They are small and can be fiddly.
Taking the cover off the sensor will trigger a tamper alarm if you haven't powered down the panel first.
If you get the identical sensor you can keep the sensor housing screwed to the wall or wherever and just swap out the board inside it.
Reassembling you need to make sure the sensor board and cover is seated properly as there are some micro switches for the tamper circuit.