In the last five years, Ahmed Mansoor, a human rights activist in the United Arab Emirates, has been jailed and fired from his job, along with having his passport confiscated, his car stolen, his email hacked, his location tracked and his bank account robbed of $140,000. He has also been beaten, twice, in the same week. Mr. Mansoor’s experience has become a cautionary tale for dissidents, journalists and human rights activists. It used to be that only a handful of countries had access to sophisticated hacking and spying tools. But these days, nearly all kinds of countries, be they small, oil-rich nations like the Emirates, or poor but populous countries like Ethiopia, are buying commercial spyware or hiring and training programmers to develop their own hacking and surveillance tools.