Troops backed by helicopter gunships attacked militant hideouts near the Afghan border after a rebel rocket attack killed four soldiers .