This is not syphilis, but please see your doctor about it. Your shorts were on the entire time and you had no risk.
There is no risk for hand transmission, and certainly lying next to someone is not a risk. To transmit syphilis, you need direct contact with a sore or a syphilis rash, and the sore appears where the bacteria entered the body. As your shorts were on the entire time, this can't be syphilis.
With STDs, when we say skin to skin transmission, we mean direct, unclothed skin to skin mouth to genital/anal, or genital to genital/anal contact, which didn't happen here.
Please see your doctor. Abscesses often need treatment.