The attacks are the terrorists’ first assaults on commercial shipping in weeks.