Well, what our feathered friend was uttering essentially was, 'You, celestial being, have been created to be an angel of the Lord.' You've got into his operating system – his factory settings.
Mind Hacking is the art of breaching someone's or something's mind for information.
The minds of angels can be infiltrated by a physical lobotomy-like procedure. Naomi can hack into an angel's mind with a drill-like mechanism, through this Naomi was able to rewire the minds of angels, removing memories or implanting certain thoughts in an angel. It appeared that all lower ranked angels went through the debriefing process, except for the ones working under Naomi, who were never fully reset.
Demons like Crowley and Viggo were also able to achieve this through the use of a torture device which, when affixed to an angel's head, plants spikes into the angel's brain and forces them to relay information in Enochian depending on where the spike penetrates the cerebral cortex.
After using telekinesis to remove the metal spike in his forehead, Samandriel attempts to get a message to Naomi, but Viggo returns and plants the spike back into his head. Despite this, Naomi is able to hear Samandriel's message and sends Castiel to Hastings, Nebraska, to save him from Crowley. She persuades him to take whatever he needs to help save him.
Later, Viggo plants a headgear device on Samandriel's head and begins jamming spikes into his skull, causing Samandriel to start relaying a message in Enochian, prompting him to summon Crowley to translate. After listening to more of the message, Crowley deduces that Viggo accessed his "factory settings." Hoping to find more information on the demon tablet, Crowley and Viggo continue to tap into Samandriel's mind.
When Samandriel started to relay a message in Enochian, it caused a bush to catch fire and implode, maiming a nearby pedestrian. Dean and Cas are able to use this to find Samandriel's location, only to discover it is riddled with demons and angel warding. They go to Kevin at Garth's houseboat to make some demon bombs, as Cas is able to acquire the ingredients and even find Sam to help with the mission.
By the time the Winchesters clear the way for Cas to enter, he starts remembering something about Naomi. He sees Naomi drilling into the edge of his eye. When Sam and Dean are able to enter, Samandriel has already disclosed the existence of the angel tablet to Viggo and Crowley, who disappears. Sam and Dean are able to kill Viggo and the rest of the demons while Cas removes the spikes and the headgear from Samandriel's head.
After teleporting outside, Samandriel tells Castiel how Crowley was able to get into his coding, revealing secrets he never knew about Heaven and Naomi. He warns Castiel that she's controlling them, but Naomi uses that control to force him to kill Samandriel. She persuades him to tell the Winchesters that Samandriel had been compromised and had attacked, forcing Castiel's hand in self-defense. Naomi demands he bring Samandriel's remains to Heaven so she can see how much Crowley got out of his mind.
Naomi trains Castiel to kill Dean by having him kill multiple duplicates of Dean until she deems he is ready, at which point she sends him after Crowley's demons to recover the angel tablet before he can. All the while, she has Cas manipulate the Winchesters and Meg to ensure she gets her hands on it, even hiding the identity of their prize. After locating one of Lucifer's Crypts in Lincoln Springs, Missouri, Dean and Cas enter to locate the tablet while Sam and Meg stay outside and ward the place against Crowley's demons. Cas tries to take the tablet from Dean, but Dean demands to know how he got out of Purgatory before he gives it to him, prompting Naomi to make Cas attack Dean against his wishes. Eventually, Dean is able to get through to Cas, reminding him of his real family. Cas then picks up the angel tablet, which starts to glow and resets his brain, destroying Naomi's control over his mind. After healing Dean, Cas reveals that Naomi was the one who sent several angels to get him out of Purgatory and has been controlling him ever since. He then tells Dean that he has to protect the tablet from Naomi and everyone else, and disappears.
After Castiel is captured by Naomi and her angel minions at a Biggersons in Santa Fe, New Mexico, she reminds him about how they slew every firstborn infant in Egypt whose door wasn't splashed with lamb's blood. When he questions how many times she's torn into his head and washed it clean, she replies "too damn many." She tries to get him to reveal where the angel tablet is hidden, but Crowley appears and uses his gun to wound Ion and kill Esper. He also tries to kill Naomi, but she teleports away before the bullet can reach her. He then shoots Cas in the gut and Ion, revealed to be a hired gun for Crowley, takes Cas to his office to get the tablet.
Crowley reveals that he's been getting regular updates from Ion who told him how Naomi broke into his mind and tried controlling it. He believes that Cas touching the tablet broke her spell over him and that he has the tablet hidden in his person. He reaches into Cas's wound and rips the tablet out of his chest. He then heads to the houseboat where Kevin was translating Crowley's half of the demon tablet and had set up a trap for two of his demons.
While Crowley is away, Ion explains to Cas that Naomi has been in all their heads and that nothing matters. Cas tells him that they aren't machines to program and reprogram and that it all matters, then removes the angel-killing bullet from his own chest. Ion tells him that she never reset him completely since he always knew too much, but Cas knocks him down and jams the bullet into his eye, killing him. Cas later finds Sam and Dean, who take him to the Bunker.
Metatron and Castiel arrive in Houston, Texas, to retrieve the bow of a cupid to supposedly complete the second trial to seal the Gates of Heaven. Before the cupid arrives, Naomi and her angels arrive to kidnap Metatron and drag him to Heaven.
Naomi explains that the archangels wanted her to 'debrief' him after God left, but he escaped before she had the chance. She questions why the Scribe suddenly came out of the shadows, knowing that she would jump at the chance to extract all of God's secrets out of his head. Metatron teases her about not being a big reader as she starts to excavate Metatron's brain and learn all his secrets. After a while, she discovers Metatron's plans for the Gates of Heaven and asks him why he's doing it. He reveals that it's his revenge for being run out of his home and the archangels refusing to accept the way things have been after God left.
Later, she tries to warn Cas and Dean, who have already retrieved the bow of a cupid. At first, Cas is reluctant to listen to anything she says, but Dean wants to hear her out. Naomi reveals that Metatron's plan is to not only seal the Gates of Heaven, but to expel all angels from Heaven just as God cast out Lucifer. She acknowledges that the angels' real mission was to protect humanity and they forgot that at some point. Despite her desire to see the Winchesters seal the Gates of Hell, Naomi reveals to Dean that Sam is going to die if he completes the third trial. Before departing, she begs Cas to prevent this from happening, even allowing him to come back to Heaven when it's over.
After returning to Heaven, Metatron escapes from his restraints and impales the back of Naomi's head with her own drill. When Cas arrives moments later, Metatron captures him and steals his grace, which is the last ingredient of the spell.
While Dean tries to look for a way to exorcise the mysterious angel out of Sam's body, Castiel mentions how Crowley got into Samandriel's coding and theorizes that they could probably find a way to bypass the angel and talk directly to Sam. They go to Crowley to find out how to hack the angel's brain, but Crowley says that hacking an angel's brain is "more art than science" and offers to do it for them in exchange for going with them with the chains on.
The trio is eventually able to capture the angel and Crowley starts to jam spikes into his brain. After a while, Crowley is able to get the angel's name out of him: Gadreel. Cas identifies him as the angel who allowed Lucifer into the Garden to corrupt humanity. Unfortunately, Crowley is unable to bypass Gadreel, who mocks them about never finding Sam. This prompts Dean to get Cas to force Gadreel out of Sam's body. However, Cas can't possess someone without their permission, so Crowley offers to do it in exchange for his freedom. A reluctant Dean allows Cas to remove Sam's Tattoo and unfasten Crowley's restraints.
Crowley possesses Sam's body and tells Sam's consciousness everything that's been happening. When Gadreel intervenes, they both fight back against him, ending with Sam ordering a defeated Gadreel to leave his body. After he leaves, Dean and Cas remove the spikes from Sam's head and the trio leave Crowley behind in the warehouse when Abaddon arrives. At a pier, Cas heals Sam of the injuries to his head.
When Efram and Jonah are unable to get Castiel to tell them where Sam and Dean are, they decide to hack his brain. Jonah places a torture device on his head and starts to jam spikes into his brain. When Efram asks if Jonah knows how to do this, he replies that he "watched Naomi once." Hannah is unable to bear watching them do this to Cas and tries to get them to stop, even intervening when Efram tries to do it himself. After he attacks Hannah, Cas is unable to control the attack dog spell Rowena cast on him and starts to lash out, telekinetically forcing the spikes out of his head and retaliating against Efram and Jonah.
Dean uses the British Men of Letters device to enter Mary's mind in order to counter the damage done by Toni Bevell's brainwashing
In Apocalypse World, Michael hitches a ride on Lucifer's temporal lobe to get him to relay information on his world. He tells him God had a few great seconds when he created the universe and gave mankind a chance to live in paradise, but he got bored and left. After hearing about his world, Michael decides to leave Lucifer in his fortress and take up residence in Lucifer's world by opening a rift.
When Naomi reveals herself to be alive, she explains that her drill was incapable of killing her. Castiel expresses his frustration about when she stole his memories, made him repeatedly act out Dean's murder, and killed many people. She passes these off as "simpler times" and tells him that she had a few reliable angels spread the word that she was dead after Metatron attacked her. She has been incognito for the past five years due to drill-induced amnesia. Despite not remembering everything, she has to be in Heaven to help keep it from running out of power.
Using the British Men of Letters rig, Sam and Castiel attempt to hack into Dean's mind to drive Michael out of his body. After wading through his good memories, Sam and Cas find Dean in a dream world called Rocky's Bar with Pamela Barnes. Sam is able to use their go word "Poughkeepsie" to break Dean out of the loop. Michael subsequently appears and attacks the trio, saying that even if they can drive him out of Dean's meatsuit, he would be left catatonic. With no other choice, Dean locks him in the freezer, making his mind into a cage to hold Michael captive.