Up to 6 000 Libyans are detained in facilities run by revolutionary brigades that helped out Muammar Gaddafi, the UN says.