Oh that's a relief! (that it wasn't a used litter box)
He's been thru an awful lot! He was shipped to you, then ended up being loose for a long time. He's scared & defensive but that's normal: captive-bred snakes are still
wild animals, which means they rely on their instincts first. But just be patient...some of his attitude right now may have to do with being really hungry, and also
you mentioned he might be in a shed cycle, & that normally makes snakes defensive too. Yes, I'm sure he'll calm down, but not overnight: after a shed & a few meals,
he's bound to feel a lot better...be patient. Might try offering food...he may or may not take it, but he sure needs it. I normally don't feed snakes in shed, but I would
offer in this case, as he's been without for so long.