The Alvi Brothers: How Two Programmers in Lahore Wrote the First PC Virus
In 1986, Basit and Amjad Farooq Alvi wrote a piece of code to protect their medical software from piracy. It became the first virus to infect IBM PCs, and it carried their real names, address, and phone number.
In the mythology of computer viruses, origin stories matter. We know the names of the researchers who theorized self-replicating code: von Neumann, Shoch, Hupp. We've read the papers. We understand the lineage through the PARC experimental systems and the worm experiments of the late 1970s.
But those were academic exercises, proof-of-concept demonstrations that lived in controlled lab networks.
The first virus to actually escape the laboratory and infect real computers in the real world, spreading through the actual ecosystem of IBM PCs, didn't come from MIT or Bell Labs or Stanford. It came from a small medical software shop in Lahore, Pakistan, written by two brothers in their twenties. And when the world finally found them, they had left behind something no academic virus had ever done: their real names. Their address. Their phone number.
Lahore, 1986: The Piracy Problem
To understand why Basit and Amjad Farooq Alvi wrote the Brain virus, you have to understand what it meant to be a software company in Pakistan in 1986. The personal computer revolution was happening, but unevenly. IBM clones were flooding markets across Asia, cheap and accessible. The infrastructure for software distribution was scattered. Intellectual property enforcement was theoretical. And if you wrote something useful, people copied it.
The Alvi brothers had written something useful. Their company, Brain Computer Services, had developed a medical software package for blood banks. It was practical, it worked, and it solved a real problem for a real market. But that market was also copying it. Every install they could track became two; every licensed copy spawned five unauthorized versions passed hand to hand, floppy to floppy, across Lahore and beyond.
They were losing money. They were frustrated. And they decided to fight back.
Their solution would change the history of computing.
The Virus as Copy Protection
This is the essential, humanizing detail that transforms the Alvi brothers from anonymous malware authors into something more complex: they wrote the Brain virus as an act of self-defense. It wasn't designed to destroy. It wasn't designed to spread for the sake of spreading. It was designed to protect their property in the way they knew how: by marking it.
The virus infected the boot sector of floppy disks. When an infected disk was inserted into a PC, the virus would copy itself to the new machine's hard drive, modifying the disk's volume label and marking it as "BRAIN" or displaying messages identifying the infection. This was their copy protection mechanism: infect the disk, mark it, warn the user that they had obtained a copy.
The brothers believed that infected software was worthless software, that the act of infection itself would serve as a deterrent or at minimum as a marker. They weren't entirely wrong. But they dramatically underestimated something fundamental about their creation: once you have a piece of self-replicating code that actually works, that actually spreads, that actually infects machines, you cannot control where it goes or what people do with it.
The virus spread beyond their control almost immediately.
The Technical Innovation
The technical sophistication of the Brain virus, for 1986, was substantial. It was stealth code. It hooked interrupt 13h, the BIOS disk interrupt, allowing it to intercept disk operations and hide its presence. When the system booted from an infected disk, the virus would load itself into memory before the operating system, positioning itself as a gatekeeper for all disk access. When antivirus software tried to read the boot sector directly, the virus would feed back a clean, uninfected copy instead of the real one.
This was elegance in malware design. Not destruction, but invisibility. Not aggression, but persistence through misdirection.
The virus was 1,813 bytes. Small enough to fit in the boot sector and still leave room for the original code. Efficient in its operation. It replicated by infecting new floppies when they were accessed through the system. In a world where software distribution happened primarily through physical floppy disks shipped across distances, passed through user groups and conferences and informal networks, infection was guaranteed. Every shared disk became a vector.
And the virus carried a signature. The volume label would identify itself as "BRAIN." Some versions displayed text: "Welcome to the Dungeon. (c) 1986 Basit & Amjad (pvt) Ltd. Brain Computer Services, Karachi, Pakistan, Ph: 430-0672."
Here. We made this. Call us.
Names in the Code
This detail, more than any technical achievement, is what makes the Alvi brothers' story unforgettable. They embedded their company name, their city, their phone number in their virus. When antivirus researchers finally analyzed the code, when security researchers across the world began documenting this first wild computer virus, they had the authors' actual contact information.
It's almost impossibly naive from a modern perspective. It's also, in its own way, audacious. There was no understanding yet of what this code would become. There was no playbook for virus authorship. There was no concept of reputation, anonymity, the future consequences of attribution. They wrote their names the same way they would sign a piece of software they were proud of.
They didn't understand they were writing history.
The Spread
Brain spread in the way that only something distributed through an interconnected world of floppy disks could spread. University computer labs. International conferences. Software distribution networks. Corporate backup disks. Users bringing infected machines to repair shops, who then used the same repair disks on other machines. The virus was present on infected machines for longer than anyone realized because the stealth techniques worked: antivirus scanners of the era couldn't detect it.
By the late 1980s, Brain was everywhere. It was the most common virus in the wild. Antivirus companies documented it, studied it, made it the first entry in their viral archives. It was the proof of concept that viruses could exist outside of laboratory conditions, that self-replicating code was not theoretical but actual and present and spreading.
The virus itself never destroyed anything. It never deleted files. It never corrupted data. It infected, it marked, it spread, but it caused no actual harm beyond the psychological impact of infection, the violation of knowing that unauthorized code was living in your system. For a defensive copy protection measure, that was the entire point. But the world didn't know the intent. They only knew that there was a virus, and it was spreading, and no one could stop it.
The Response
By the time the world caught up with the Alvi brothers, antivirus companies and security researchers had already traced the contact information in the code. Basit and Amjad Farooq Alvi found themselves suddenly notorious, contacted by researchers and journalists and probably angry corporate IT managers.
Their response, from the available record, was straightforward: it was copy protection. It wasn't meant to cause damage. It was a mistake to let it spread this far. The Karachi phone number and company information became public. Brain Computer Services became synonymous with the first PC virus.
Critically, they were not prosecuted. Pakistan's legal framework in the 1980s had no laws against writing or releasing viruses. The Alvi brothers weren't criminals under Pakistani law. In the west, there was no international precedent for prosecution either. They became famous, and infamous, but they remained free.
What Happened Next
This is where the story becomes almost impossible to believe. Brain Computer Services, the company that had created the world's first escapee virus, continued operating. The brothers adapted. The shop evolved. Rather than disappearing into obscurity or notoriety, they pivoted. By the 1990s and into the 2000s, Brain Computer Services transformed into an Internet Service Provider called Brain NET, serving customers in Pakistan and beyond.
They never apologized. They never disavowed the virus. The code remained out there, documented, studied, taught. Computer science students learned about the Alvi brothers in their security courses. The virus appeared in museum collections and historical archives. Every antivirus company carried it in their virus database.
And the brothers went back to work.
Mikko Hypponen's Pilgrimage
In 2011, Mikko Hypponen, chief research officer at F-Secure and one of the world's most respected figures in computer security, made a documentary. He traveled to Lahore. He went to the Brain Computer Services office. He met the Alvi brothers. He interviewed them about the virus they had created, forty-five years earlier by the reckoning of internet time, a geological epoch ago in the history of computing.
The documentary footage is remarkable. The brothers are calm. They speak about their work with a clarity that suggests they'd had time to process the strange fame that had attached itself to them. Hypponen, interviewing them, asks about the decision to put their names in the code. They explain it simply: they didn't think it would matter. They didn't think it would spread like this. They made what they thought was a smart technical decision about copy protection and it became the first virus in history.
The pilgrimage itself is significant. Hypponen traveled to meet them the way a music historian might travel to meet an aging musician whose first album changed everything. There was reverence in the journey, an understanding that these two men in Lahore were pioneers, whether they intended to be or not.
The Philosophical Weight
Here's what separates the Alvi brothers' story from the mythology of viruses that came after: they did not write this code from malice. They did not write it to destroy. They did not write it for fame or notoriety or to crash systems or steal information or prove how clever they were.
They wrote it because they were trying to protect something they had made. They wrote it because piracy was eating their business alive and they didn't have the legal or economic tools available to them in 1986 Pakistan to fight back. They wrote it as an act of self-defense, and the fact that their copy protection mechanism happened to be a self-replicating program that could spread beyond their control was not a feature; it was an unintended consequence of innovation.
This is the profound difference between the Alvi brothers and every virus author who came after them. The thousands of people who would write viruses in the 1990s and 2000s, who would cause actual harm, who would destroy files and steal data and crash systems out of malice or profit or the pure exercise of destructive power, they were operating in a fundamentally different moral universe. They knew what they were doing. They intended the consequences.
The Alvi brothers didn't.
And yet their virus became the progenitor of an entire lineage of malware. Their code, however benign in intention, cracked open the idea that a personal computer could be infected without the user's knowledge or consent. It demonstrated that self-replicating code could escape laboratory conditions and spread through the wild. It proved that viruses were possible. Every virus that came after, every ransomware attack, every piece of malware that has cost corporations and governments and individuals millions of hours and billions of dollars, traces back in lineage to the Alvi brothers' boot sector code.
They were pioneers and they never meant to be.
Lahore Then and Now
Lahore in 1986 was a city remaking itself. Pakistan's tech scene was just beginning to take shape. The idea that a small software company in Karachi (Brain Computer Services was actually based in Karachi, though this is often misremembered as Lahore) could create something that would ripple across the entire globe was almost unimaginable. And yet.
Today, Brain NET continues operating. The brothers continue their work. They became a minor footnote in computing history, a trivia question, the answer to "who wrote the first PC virus?" But they were also, in their own way, pioneers of Pakistani technology. They demonstrated that sophisticated software development could happen outside of Silicon Valley, outside of the western technology centers. They showed the world that innovation could come from Karachi.
The Museum and the Memory
The Brain virus lives now in two places: in the actual memory of millions of infected machines and backup copies and stored floppies still sitting in archives around the world; and in the archives of digital history. The Phreak.fm museum has a specimen page dedicated to it, a technical breakdown, the code itself archived for posterity and education.
To understand the Alvi brothers is to understand something essential about the early history of viruses, about copy protection, about the unintended consequences of clever code released into an interconnected world. To read their story is to read the founding myth of an entire category of computing innovation.
They were two programmers in Lahore, trying to protect their work. And in doing so, they accidentally rewrote the rules of computing itself.
You can visit the technical archive at /museum/specimens/brain to explore the virus itself. But this is the story: the two brothers, the medical software, the decision to embed their names, the spread that no one could stop, the decades of infamy, the documentary interview, and the simple fact that they kept working. They kept building. They transformed their company and moved forward.
The Alvi brothers didn't set out to change history. But they did.
This article is dedicated to the pioneers of computing whose stories are often told only in technical terms, whose human decisions and motivations are lost in the archive. The Alvi brothers deserve to be remembered as more than their virus. They deserve to be remembered as they are: two smart programmers from Pakistan who tried to solve a real problem and accidentally became legends.