The querent posted that it was Brian Falkner's Brainjack.
Las Vegas is gone—destroyed in a terrorist attack. Black Hawk helicopters patrol the skies over New York City. And immersive online gaming is the most dangerous street drug around. In this dystopic near-future, technology has leapt forward once again, and neuro-headsets have replaced computer keyboards. Just slip on a headset, and it’s the Internet at the speed of thought.
For teen hacker Sam Wilson, a headset is a must. But as he becomes familiar with the new technology, he has a terrifying realization. If anything on his computer is vulnerable to a hack, what happens when his mind is linked to the system? Could consciousness itself be hijacked? Before he realizes what’s happened, Sam’s incursion against the world’s largest telecommunications company leads him to the heart of the nation’s cyberdefense network and brings him face to face with a terrifying and unforeseen threat.
From this review (emphasis mine):
The story starts in a big city with a teen in high school. This boy attempts to hack into one of the most secure business franchises in the world. After words, he and his friend use neuro-helmets that allow them to use a computer just by thinking. Then, the hacker gets arrested on the charges of hacking and terrorism. He is then taken to a prison made for hackers, and the like. He then escapes and is recruited by a secret organization that uses elite hackers to help protect the U.S. Very odd and scary things happen that lead three of the hackers to go on the run. They get held up in a mall but escape to the dessert with a hostage. They drive to Las Vegas, which has been destroyed by a bomb, and they hide there from a sentient A.I. or Artificial Intelligence that is taking over people’s minds. They are driven out and head southwest. They meet a resistance and then head for a mountain. At that mountain… well you’ll have to read the book to find out.