Australian shares have staged an unlikely comeback from three days of losses with a late rally in technology stocks.