Rapid7 Inc. shares surged in the extended session Thursday after the cybersecurity company reported quarterly results and an outlook that topped Wall Street targets and forecast a surprise profit for the year ahead. Rapid7 shares rallied 8% after hours, following a 1.2% decline to close the regular session at $39.95. The company reported a fourth-quarter loss of $13 million, or 27 cents a share, under new accounting rules. Under the old rules, the company had a $17.2 million loss, or 36 cents a share, compared with a loss of $13 million, or 30 cents a share, in the year-ago period. The adjusted loss for the most recent quarter was 5 cents a share. Rapid7 reported revenue of $68.8 million. Under the old accounting rules, revenue would have been $70.6 million, up from $57.7 million in the year-ago quarter. Analysts surveyed by FactSet had forecast earnings of 9 cents a share on revenue of $66.6 million. Rapid7 expects an adjusted loss of 10 cents to 8 cents a share on revenue of $68.9 million to $70.5 million for the first quarter, and adjusted earnings of 5 cents a share on revenue of $304 million to $312 million. Analysts had forecast a loss of 6 cents a share on revenue of $65.3 million for the first quarter, and a loss of 1 cent a share on revenue of $290.7 million for the year.