Amjad Alvi is remembered for writing the first free-range PC virus that went viral in an age before the internet. But he’s done so much more.
The first call came late one winter night. A journalist working for a university magazine in Miami, Florida, wanted to know about a mischievous computer programme that was driving students crazy.
“Hello, can I talk to Amjad or Basit Alvi?” she asked. Her American accent and the fact that Amjad, who took the call, was half asleep, made the conversation difficult.
“My [spoken] English is not really good,” says Amjad. It took him some time to realise she was talking about a code that he and his younger brother, Basit, had written a few months before on the Microsoft operating system.
“How the hell did she come across it?” he wondered.
That telephone conversation took place in 1986 when Amjad was 24 years old and still lived with his parents in Lahore, Pakistan.
It was an era before the internet came to be what we know it as today. Connections between computers were largely limited to scientists and a few research organisations in the United States, Europe and Japan.
Most IBM personal computers ran on MS-DOS and data was stored on 5.25-inch floppy disks, which could store 160 kilobyte of files. It was on one such disk that Amjad had copied the ‘Brain Virus’ or, the Pakistani Brain, which became the first viral computer infestation the world had seen.
Somehow a copy of that floppy found its way to the United States.
The self-replicating virus that automatically copied onto the disks spread like wildfire. Students came across it on disks in the universities of Pittsburgh, Pennsylvania, Delaware and George Washington University.
It slowed systems at the Providence Journal-Bulletin newspaper and popped up in trading terminals in Hong Kong. Users found it on their personal computers in places as far as Australia.
Some estimates suggest that between 1986 and 1989, the Brain Virus hit more than 100,000 computers — 10,000 of them at Washington DC’s Georgetown University alone.
Everyone knew the name of the culprit because Amjad had put his address and phone number in between the code along with this message:
“WELCOME TO DUNGEON...Beware of this Virus...Contact Us for Vaccination”
Brain was a benign virus as it wasn’t written to erase data or damage hardware. However, within a few months it opened the floodgates for newer variants and copycats which applied the same logic as Amjad’s to infiltrate computers and cause widespread damage.
Viral computer infestations jumped tenfold from 3,000 in the first two months of 1988 to around 30,000 in its last two months, a US-based software trade organisation noted at the time.
“We were just showing off our skills to each other and trying to identify vulnerability in the DOS system. I didn’t think it would become so big,” says Amjad.
But big it became. In September 1988, the Alvi brothers were featured in a Time magazine cover story and tech historians still regard their virus as one of the most sophisticated of its time.
No history of computer viruses is complete without mention of the Pakistani Brain. It was the Brain that gave the idea to some programmers to write the first anti-virus software.
Among the people who were awed by the novelty of its code was a software engineer named John McAfee, the eccentric US millionaire and guru of the anti-virus industry. And he called the Alvi brothers geniuses.
“I read a story in San Jose Mercury News and I go ‘how the hell did they do that?’"
“Nobody had ever thought about using software to act like bacteria and viruses. That’s a genius idea,” he told TRT World in a recent Skype interview.
McAfee, who at the time was running a computer firm Interpath, studied Brain and wrote a programme to counter it.
“I posted it on my electronic bulletin board and two weeks later I had a million users.”
That’s how the famed McAfee, the first commercial antivirus software, was born.
But how did two Pakistanis from Lahore, famous for its food and hospitality, come up with the idea in the first place? How did a young man with no formal education in information technology and no mentor to guide him figure out a complex process to infiltrate computers undetected?
The boy who bunked school
When it’s time to have fun, most boys in Lahore head to their rooftops to fly kites. Others would go out to play Pakistan’s most popular sport, street-cricket. Amjad Alvi, however, stayed in his room and tinkered with electronic gadgets.
Born in 1962 in a middle-income family, Amjad was the second-youngest of Muhammad Farooq Alvi’s six children. Senior Alvi was a medical doctor who encouraged his kids from an early age to read books and magazines.
“My father wanted me to become a fighter pilot. When I was 10 years old he bought me two books. One was about airplanes and the other about electronic experiments. I just got into electronics,” Alvi explains.
He vividly recalls the first time he took details and sketches from a how-to book to put together a crystal radio.
“It needed a coil, a gang capacitor, a diode and a headphone. It didn’t need a battery. You just give it earth, attach a long antenna and it catches local transmission,” he told TRT World.
“Same thing prisoners of war made during WWII to know what was happening outside.”
From improvised radios, Amjad moved on to experimenting with walkie-talkies and music synthesisers that involved the use of transistors.
“OC-72. I still remember the transistor number. Finding the components was not always easy.”
Often after school he would scavenge through the narrow lanes of Lahore’s Hall Market where scores of stores sell parts ranging from capacitors to electric switches.
In the 1970s it was a struggle to find electronic parts and even more difficult to get a hold of the right instruction manuals. That’s where the Alvi siblings were lucky.
They had a library membership of the British Council, an initiative of the United Kingdom to impart education in mostly developing countries. That gave Amjad access to journals such as Wireless World and Practical Electronics.
“They didn’t allow you to take anything home from the library. I spent hours copying the descriptions and drawings.”
He often bunked school to come to the library. “That didn’t go down well with my parents once they found out. I was banned from visiting the library for a while.”
In his own words, Amjad was “always a third class student” and failed a calculus exam in college. The method he used to solve an integration problem didn’t go down well with his evaluator. It was not that he didn’t know the answer, he just did it in another way.
Students were supposed to attempt the question based on the standard course book. Amjad relied on a reference from an American book he had come across at the library.
Why else would he fail, he wondered. After all, he never forgot his fifth grade teacher at Saint Andrews school, Miss Benjamin, telling the class on their first day: “Mathematics is the mother of all sciences.”
If you knew that, if you knew the logic that goes into solving a problem, if you had learned about the flip flop in electronic circuitry on your own and you also had a computer, then the possibilities to make things were endless, he says.
“Do you see what I mean by that? With limited resources in Pakistan where it’s difficult to get hold of components, if you had a computer and a bit of imagination, you can do anything."
Love at first sight
Amjad eventually completed his masters in physics from University of Punjab. But having read everything about computers from all the magazines he could get his hands on, he fell in love with the machines.
In the early 80s he came across an advertisement in a newspaper about a local distributor who was selling Sinclair computers.
The Sinclair ZX80 was launched in 1980 by a British company, Science of Cambridge. Though it wasn’t the first personal computer and left users annoyed over its display issues, it came with a price tag of 99 pounds or around $230, the cheapest personal computer to hit the stores.
“That was my first computer. A good thing about it was that it was sold as a do-it-yourself kit. So you’d get to know the ins and outs of the computer,” says Amjad.
Like elsewhere in the world, personal computers such as the IBMs, Commodore 64, RadioShack and Atari were slowly becoming common in Pakistan. Yet there were just a handful of technicians who knew how to repair them.
That’s where Amjad put his electronic know-how to use and carved out a niche market for himself. He opened a makeshift computer repair shop within the premises of his father’s clinic in mid-80s. The business was named Brain Services.
“We’d say Amjad was a brainy kid. That’s how the name stuck,” says Basit, who was 17 at the time.
Very soon the distributors of Sinclair and other brands were referring broken computers to Amjad. “I still have the logs — the record of the computers I serviced. I made good money with that.”
Over the years, while the story of Brain virus has been told many times, the narrative has missed some key points. Amjad was a pioneer in key IT-related developments in Pakistan.
In 1987, he set up a shop in Singapore to buy monitors, power supply units, processors and motherboards from different companies and assembled them as clones, making Brain among the first suppliers of custom-made computers.
The availability of clones helped many people buy their first computers as they cost much less than branded machines, which were out of reach of many Pakistanis.
Along the way, Amjad honed his programming skills, reading ever-more advanced books and articles in professional journals, mostly to work on mathematical functions.
The first programme to make him money was one designed to convert measuring units. Jewellers and goldsmiths in Lahore had electronic scales which displayed weight in grams and milligrams. But in their daily dealings they relied on Indian units of tola, ratti, and masha.
“I didn’t design the system. I took the idea from somewhere and then built the electronic interface including the port and everything myself,” he said.
By the early 1990s, Brain Services had transformed into Brain NET. Amjad, Basit and their elder brother, Shahid, pitched in whatever capital they had to expand the enterprise. The obvious transition to make was to Bulletin Board Services, which were a sort of an online community before the arrival of the World Wide Web.
They also introduced Pakistan’s first email service around that time. However, the potential customers, who were mostly factory owners, were content with fax machines.
“Our customers would often say, ‘We don’t need to send any communication outside the country, so why bother with email?’ So we built servers and nodes in all the major cities and laid a domestic communication infrastructure. It worked,” says Amjad.
Brain Net would eventually become one of the first internet service providers in Pakistan.
But what Amjad is remembered for is the computer virus.
The making of the Brain
The jury is still out on the question of who wrote the first computer virus.
Most researchers say it was Richard Skrenta who in 1982 as a 15-year-old high school student pranked his friends with Elk Cloner, probably the first self-replicating programme.
Elk Cloner spread via gaming disks, which Skrenta, who is now a tech entrepreneur, loaned to his friends. It slowed down their Apple IIs or abruptly shut the systems.
The moniker, virus, was conceived a year later in 1983 by professor Len Adleman for a programme that his student Fred Cohen wrote.
Cohen demonstrated the ability of his code at a security conference in Pennsylvania. That virus, which could spread through bulletin boards, was able to give Cohen control of a mainframe computer within minutes. His experiment is well documented.
There’s also Creeper and the famous Core War game from the mid-1970s, which was famously featured in Scientific American and gave the world a peek into what the rogue programmes can do.
Like the crystal radio and the unit programme, Amjad says he took the concept to stealthily insert a code into a computer from other programmers and tweaked it a bit.
In the late 1960s, students at the Massachusetts Institute of Technology wrote a computer programme they called the “Cookie”. Computer users would be interrupted by the word cookie that kept flashing on their screen until you type the word ‘cookie’ for it to go away.
Amjad says before writing Brain, he and some of his friends had modified Cookie into a programme which told stories if the computer was left idle for a few minutes.
If a programme can run in the background like this, then why not use it as a harmless virus, he asked himself.
“Initially DOS didn’t give you the option of multitasking. Then they included a new procedure in the code called Terminate and Stay Resident, which basically allowed you to push a programme to the background and pull it back without terminating it,” said Amjad.
Brain was a BOOT Sector Virus and loaded onto the computer from the infected floppy when it was switched on — without the user ever finding out.
What made Brain unique was its ability to load into the computer even before the operating system.
“It was seen as sophisticated for its time by the use of relocation of the boot sector rather than overwriting it, and by marking the moved boot sector as unavailable on the disk,” Gene Spafford, a cyber security expert, told TRT World.
The Brain in its original form was not meant to erase data or even slow down machines. It was simply a way for Amjad and his brother to keep track of who was using their software.
“An NGO wanted us to write a patient management programme. But they were paying us very little. So I copied Brain on to their floppy and explicitly told them not to give it to anyone,” says Amjad.
Despite his warning the infected floppy was apparently shared, copied and the virus started to move and take on a life of its own.
Brain was quickly followed by far more lethal programmes and the Alvi brothers moved on to focus on their internet service and telecommunication applications.
McAfee doesn’t believe that Elk Cloner or Cohen’s virus were the first. He made a fortune from McAfee AntiVirus and was estimated to be worth $100 million before the 2007 financial crash.
He has done a lot over the years — built mansions in the US, tried to make natural antibiotics, ran a cybersecurity firm and ventured into the business of cryptocurrencies.
But his view on the Brain hasn’t altered.
“(The) first virus was the Pakistani Brain. Trust me. There were no viruses before. The word had not even been invented. No one was discussing it or writing about it or considering it. It was not an idea that could come into your brain if you had not seen it.”