Hanrahan, 32, went 0-1 with a 9.82 ERA in only nine games for the Red Sox in 2013.
He had season-ending surgery last May to repair a torn flexor tendon muscle in his right arm.
Hanrahan saved 76 games for the Pirates between 2011 and 2012, allowing just 96 hits, 52 walks and nine home runs in 128 innings.
Hanrahan could have a lot of upside. Before his injury, he was still throwing very hard and he was dominant in his two seasons in Pittsburgh before being dealt to Boston last winter. He's a hard thrower with two pitches - a fastball and slider - that fit the profile of a closer. He often struggles with his command, but he typically misses a lot of bats and keeps the ball in the yard. If he hasn't lost too much velocity, he should be able to return to form when he's 100 percent healthy.