In the movie The Matrix Revolutions, Agent Smith possessed the body of Bane in the real world. But he was just an AI program, nothing but some code that exists in the Matrix, so how could he end up in the real world? Machines can do that using AI, but Smith is not a machine. So what is the explanation for this?
If you think our brain as just a CPU, and memory storage, you'd think of yourself as your memories + your thinking capacity. When you hack into the Matrix, you connect a jack to your head, and you basically send yourself inside the Matrix, where you are represented by an avatar of how you think you should look (without plugs, grown hair, etc), where yourself is reduced to code, very much like an AI (running in a human body). This self is tethered to the real body in the chair. If at any time you loose the connection (remove the head plug, or loose power on the ship) yourself in the Matrix dies.
In short, the plug translates the brain thoughts and memories to Matrix code, and translates Matrix code back to the brain.
Agent Smith infects Bane's avatar in the Matrix. While his virtual representation changes to that of Agent Smith, it's still very much Bane's Body and mind running "Bane's avatar" on the Matrix. When Bane wakes up in real life, his mind is infected with Agent's Smith. Agent Smith's code was translated into thoughts and memories on Bane's brain.
There are multiple possible explanations for this.
If you're prepared to accept Zion as the "real world", then I think you have to assume that the hardware that all the matrix born humans have implanted in them is able to be infected by software. Smith, using new found abilities since being himself infected (and then killed) by Neo at the conclusion of the first movie, is able to take over Bane's implants. He has in effect hacked the interface to Bane and taken over his consciousness or at least taken over control of his body. Since Bane isn't permanently connected to the Matrix, we have to assume that the implants have enough capacity to store all or a significant subset of Smith's code.
As @DForck42 suggests - there's a distinct possibility that the "real" world is just another layer of the Matrix. This also would explain some of the other rather weak points in the explanation of the Matrix - like the "human battery" thing. It's also one explanation for how Neo can have unusual powers in the real world too.
Smith would not have been able to do that in the first part.
Neo was the One, who is living in the real world and begins to have much more control than anyone possible which also gives him superpowers in the Matrix (bullet slowdown, flying, incredible strength and speed).
The critical event was that Neo plunged into Smith, rewired him and apparently destroyed him. But what was really happening is that Neo unintentionally imbued Smith with remnants of supernatural powers which not only allowed Smith to survive, be a free being and replicate as parasite, but gain the power of possession in the real world.
So Smith II is not an AI program anymore, he is something much more sinister and powerful because Neo manipulated his essence.
He also explained his transformation in detail before the "Burly Brawl" fight. He is really glad about this new powers, but he does not like the "rewiring phase" of Neo with the intent of destroying him at all.
Agent Smith is the one. This is confirmed in the second movie when the architect tells Neo that Neo isn't special at all. I believe the oracle also mentions Neo not being the one at some point, but I don't remember where that happens. That's why Agent smith is able to piece together the knowledge required to steal a human body by essentially hacking the process the matrix uses to keep human consciousness busy - the whole humans as batteries thing still makes no sense - to put his mind into the humans body instead of their own mind. That's why it's important that Agent Smith starts creating multiple instances or copies or something of himself when he goes rouge instead of just shooting lasers out of his eyes or something.
The set up suggests that humans can download their minds into the matrix i.e. there is some technology that can convert brain impulses into electrical impulses that then become bits in a computer memory. If you accept this technology is possible then when humans return from the matrix it happens in reverse. Agent Smith is simply using the converter in the same way to convert computer bits, to electrics, to brain impulses. If you understand how brains work, then it could never work, but if you accept the rules of the film then that's why it works.
You can argue he has something special or more complex about him because he interfaced with Neo, but really the magic is all in the converter, not in Agent Smith. Possibly human minds have a particular pattern of bits in the matrix and he can now express/simulate that pattern, so the matrix phones think he's a mind and upload him.
Who says that the real world is the real world? It might be some backup plan that the machines had. There could be a Matrix inside the Matrix humans call real world. (Like an inverse honeypot. "You want to leave? Sure. 'exit' won't work. Enter 'connect reality'.")
Most likely the interface in their heads is a mix of hardware an software - because you can't change things when everything is hardwired. (And wiring humans to "USB" might be harder then "they will grow into it".)
The reasons that Smith is using most of his army in the Matrix might be:
there is nothing special about the "one" or his opponent (all power they have is granted by the Matrix) -> he might be not allowed to hack everyone? But he is able to hijack their connections (or whatever).
or the machines would kill each body Smith escapes in asap. (Reasons to do that: the bodies would be worthless (no energy after they are unplugged) and Smith is the new enemy #1 (The machines can't beat him. Smith might be the (only) "administrator" - maybe there is someone with higher access level who could stop him (architect?). So the machines could only unplug/destroy the Matrix and "kill" themselves. So why not start with the bodies? Else Smith could upload himself later... I'll stop here.)
That the bodies are weak - because they have not been used until now.
That humans messed up with their security (->"jailbreak") and Smith can't hack the humans who are still connected to the Matrix because there is "some kind of protection". So he is not hijacking their brain - only their connection. [6 billion people offline for some hours. They'll be p*ssed.] (Else: How did the machines remove Smith from the brains? (Brains are closer a layout/chip than they are to "software". Installing Smith = replacing at least some "hardwired routines".) Did they have ~6 billion backup files? Did they install the file "generic brain"? Are all humans who got hacked (=everybody connected to the Matrix) now dead? ...)
The reason why Smith needed to infect humans in the first place? I guess his routines/the system only allowed him to interact inside the Matrix while he had a host. After he was freed only one thing changed: he was able to "use more than one host at a time". (A lot like a virus. But maybe it was part of the system?)
But back to the question/answer:
So the easiest way to explain the "hacking the humans" thing would be a "firmware upgrade" for Cipher (and other people)
and a "firmware upgrade" or a "man in the middle attack" for 6 billion people.
The rest would depend on the capabilities of the hardware. But a hardware that keeps people from moving while "being awake" (maybe they were at sleep all the time - hard to say in fiction ;) ) and simulates pain could be capable to take over certain functions of the body.
If not it should be able to run a "single player" version of the Matrix and make the body move.
(Stuff like voice, behavior, ... of Smith might have been for the audience. To transport the idea that people got hacked outside of the Matrix.)
Several examples in fiction exist which effectively allow artificial agents to become, possess, or overwhelm human beings. One film ("The Thirteenth Floor," after the novel "Simulacron-3", by Daniel F. Galouye), has the main character as a program climbing its way out of processors to take control of a rogue human being and steal his wife.
In the Matrix series, that example is a rogue security program (Smith) which finds a way to transmit itself via a human being (Bane) to a human-machine interface (Neo, or Neo's equipment). This doesn't mean that the Smith program 'ended up in the real world', per se. It means Smith exploited a route of control to bridge into Neo's consciousness through another human being's hardware.
Some interesting answers here, but the clues all exist within the films. There is no need for the "is the real world another matrix?" as we can apply Occam's razor to explain.
From the first film we learn:
- The Matrix is a system of control
- Humans born in the matrix have implants to interface with the virtual world, and these are too tightly integrated to remove. You may ask how we know that, if you look you see they don't remove the ports. If you could you might keep the matrix port and the mainline, but you would remove all the spinal connections etc, even if only to get a good nights sleep.
In the sequels we learn the following:
Neo and Smith are able to cross the barrier from the Matrix to the real world (in opposite directions).
- Neo can see without eyes, and is able to interact with the machines to exert control over them. The prime machine also takes on a humanoid form when dealing with Neo who has no real world vision, so it is aware he is able to "see".
- Smith is able to exit into the real world via Bane
We also learn something else in the sequels:
The Real World (Zion) and the resistance is ALSO a system of control for the percentage of humans who reject the Matrix world.
This changes some big facts we thought we knew:
- The pursuit of Zion Mainframe codes is bogus. The machines know the location of, and have visited Zion and destroyed the humans at least 6 times before. They may even have built both the machines that keep the humans alive and the hovercraft (the humans are unsure of how/when they were built).
- The pursuit of the One by the agents is bogus. Their mission is to lead the Humans to the current One to fulfill the program and allow the Matrix to reset and restart (why? It culls the resistance numbers back and allows the simulation to avoid modelling history beyond the late 90s).
- The Architect is an unreliable narrator The interaction with him is a set part of the fake story, you cannot trust anything he says at this point
- The machines won the war The history known to the resistance is what the machines let them know, and at the end we actually just see the Matrix reset, maybe this was no different to the previous times really, maybe the "lead the survivors to the source" is part of the fake story (see agents above)?
Based on this, it is likely the implants in humans contain some kind of communications ability (possibly how the sentinels find them in the tunnels?). We know the humans are dependent on this technology (which the machines may have actually built), so might not be able to detect the comms themselves.
So simply, for Bane/Smith and Neo to have abilities within the real world there must be communication to the machine world, and would also make sense from the machines control perspective.