
What Is Pharming? How Pharming Attacks Work and How to Stop Them
Imagine typing your bank’s web address correctly, letter by letter, and still landing on a fake website. You clicked no suspicious link and opened no strange email. Yet the page looks exactly like your bank, and the moment you log in, criminals steal your password. That is pharming, one of the sneakiest cyberattacks on the internet.
Pharming is dangerous because it does not rely on you making a mistake. Attackers quietly change the directions your computer follows, so even a correctly typed address takes you to a copycat site. This guide explains what pharming is, how it works, how it differs from phishing, the warning signs, real examples, and how to protect yourself and your website.
What Is Pharming?
Pharming is a cyberattack that redirects visitors from a real website to a fake one, without them clicking a bad link. The word is a play on “farming” and “phishing”: attackers “farm” large numbers of victims at once by poisoning the system that turns website names into internet addresses. It matches the NIST glossary definition of pharming as using technical means to redirect users to a fake website masquerading as a legitimate one.
Think of the internet as a city. A website name such as yourbank.com is a street address, and the internet address (IP address) is the actual building. The Domain Name System, or DNS, is the phone book that looks up the address and tells your browser which building to visit. Pharming tampers with that phone book. When it gives the wrong building, your browser takes you to the attacker’s fake building instead of the real one.
The fake site is usually a near-perfect copy, with the same logo, colors and login form. Because the address bar still shows the address you typed, most people suspect nothing. They log in as normal, and attackers capture their username, password or card number, then use them to steal money. Pharming most often targets banks and payment services, and one poisoned DNS server can redirect thousands of people at once.
How Does Pharming Work?
A pharming attack has one goal: to make a trusted website name point to the attacker’s server instead of the real one. Attackers do this by poisoning a DNS server or by changing the hosts file on a victim’s device.
1. DNS Poisoning
Every time you visit a website, your computer asks a DNS server, “What is the internet address for this name?” In a DNS poisoning attack, criminals insert a false record into that server’s memory, called its cache. The next time anyone asks for the bank’s address, the poisoned server gives the attacker’s address instead.
Attackers may exploit a weakness in a DNS server, trick it with fake replies, or take over a home or office router and change its DNS settings. Once the router is compromised, every device on that Wi-Fi network can be redirected, even though none of the devices is infected. This is also why pharming is related to an on-path attack, in which an attacker sits between you and the site you want to reach.
2. Hosts File Attacks and Malware-Based Pharming
The second method is smaller and more personal. Every computer has a small text file called the hosts file, which acts as a local phone book. Your computer checks this file before it asks a DNS server, and any entry in it wins. If malware changes the hosts file so that “yourbank.com” points to the attacker’s server, your browser will go to the fake site every time, no matter how carefully you type the address.
This is how most individual victims are hit. The attack usually starts with malware from a malicious download, a fake software update or an infected attachment. Once installed, it quietly edits the hosts file and may also change DNS settings. It shows no pop-ups, so the victim notices nothing until money goes missing.
How a Pharming Attack Works, Step by Step
Here is the sequence of a typical pharming attack:
| Step | What happens | What the victim sees |
|---|---|---|
| 1. Preparation | The attacker builds a fake copy of a bank or login site. | Nothing yet. |
| 2. Poisoning | A DNS server is poisoned, or malware changes the hosts file or router settings. | Nothing. The change is silent. |
| 3. Redirection | The victim types the correct address, but the lookup returns the attacker’s address. | The correct address, and a site that looks real. |
| 4. Deception | The fake site asks the victim to log in or enter card details. | A familiar login page, sometimes with an “account locked” message. |
| 5. Theft | The credentials are sent to the attacker, who logs in to the real site at once. | An error, or a redirect to the real site, so it feels like a glitch. |
| 6. Damage | Money is moved, passwords are changed, or the account is used for further fraud. | Missing money, often found days later. |
Pharming vs Phishing: What’s the Difference?
Pharming and phishing are related, but they work in opposite ways. Phishing tricks you into visiting a fake site; pharming sends you there automatically. In phishing, the criminal sends a fake email or message with a link, and it only works if you click. In pharming, no click is needed, because the redirection happens behind the scenes.
| Feature | Pharming | Phishing |
|---|---|---|
| How you reach the fake site | Automatically redirected, even when you type the correct address | You click a link in a fake email, message or advert |
| Needs you to click? | No | Yes |
| Main technique | DNS poisoning or a changed hosts file | Deceptive messages and lookalike links |
| Who is targeted | Everyone using a poisoned server, router or device | Whoever opens the message and clicks |
| How many victims at once | Thousands, from one poisoned server | One victim per click, unless the message spreads |
| Address bar | Usually shows the correct, trusted address | Often shows a misspelled or lookalike address |
| Warning signs | Certificate errors, odd site behavior, unexpected login prompts | Urgent messages, strange sender, bad spelling |
| Main defense | Secure DNS, updated router and antivirus, HTTPS checks | Think before you click, and verify the sender |
The two attacks are also used together: a phishing email can deliver the malware behind a pharming attack, and pharming often relies on a spoofed copy of a trusted website.
Warning Signs of a Pharming Attack
Pharming is designed to be invisible, but it is not always perfect. Watch for these warning signs, especially on banking and payment sites:
- Browser security warnings. If your browser says the connection is not private or the certificate is invalid, stop.
- No padlock, or “http” instead of “https”. A missing padlock on a login page is a serious red flag.
- Asked to log in again for no reason. If a site you are already signed in to asks for your full password or one-time code, be suspicious.
- A site that looks slightly wrong. Blurry logos, broken images or odd fonts can mean you are on a copy, not the real site.
- Unexpected security alerts. Messages such as “your account is locked” on a site you reached by typing its address are a classic trick.
- Websites that behave strangely. Pages that load slowly, links that go nowhere, or a login that fails and then works can signal redirection.
- Settings you did not change. If your router’s DNS settings or home page have changed on their own, treat it as a possible compromise.
Real-World Examples of Pharming
Pharming is not just a theory. It has been used in large, costly attacks for almost twenty years.
Bank customers redirected in Brazil. In one of the best-known campaigns, attackers compromised home routers in Brazil and changed their DNS settings. Customers who typed their bank’s correct address were sent to fake banking sites. When they logged in, their credentials were stolen and used to drain accounts.
The 2007 pharming wave. In 2007, researchers reported pharming attacks aimed at customers of around 50 financial organizations in the United States, Europe and Asia. The attacks used DNS poisoning and malware to redirect users to fake sites and steal login details.
How to Protect Yourself From Pharming
Use this checklist to make a pharming attack much harder to pull off against you:

- Use your bank’s official app for banking where possible, instead of a browser.
- Check for HTTPS and the padlock before entering any password or card number, and never log in on a page with a certificate warning.
- Type addresses yourself, or use a bookmark you created on the real site, not search results or links in messages.
- Turn on two-factor authentication (2FA) on your bank, email and payment accounts, so a stolen password alone is not enough.
- Keep your router secure. Change the default admin password, update its firmware, and check its DNS settings regularly.
- Use a reputable DNS service with DNS-over-HTTPS, which encrypts your DNS lookups.
- Keep your devices updated and run reputable antivirus software, so malware cannot quietly edit your hosts file.
- Watch your accounts. Turn on transaction alerts and review statements regularly, so you can report fraud quickly.
How Website Owners Can Prevent Pharming
If you run a website, your visitors are the ones at risk:
- Use DNSSEC to digitally sign your DNS records, so fake replies are rejected.
- Enforce HTTPS everywhere with a valid certificate and HSTS, so browsers refuse a fake version of your site.
- Lock down your DNS and hosting accounts with strong, unique passwords, 2FA and a registrar lock.
- Monitor your DNS records for unexpected changes, and set up alerts for changes to your domain.
- Patch your servers and DNS software promptly, because pharming often starts with a known vulnerability.
Frequently Asked Questions About Pharming
What is pharming in simple terms?
Pharming is a cyberattack that secretly redirects you from a real website to a fake copy, even when you type the correct address. Attackers tamper with DNS, the system that turns website names into internet addresses, or change the hosts file on your device.
What is the difference between pharming and phishing?
Phishing tricks you into clicking a link to a fake site, usually from a deceptive email or message. Pharming redirects you automatically, with no click needed, by poisoning a DNS server or changing your device’s or router’s settings.
Can pharming happen if I type the website address correctly?
Yes. The redirection happens in the DNS lookup or on your router, before your browser reaches the site. Typing the address correctly does not help if the lookup itself has been poisoned.
How do I know if I have been a victim of pharming?
Look for certificate warnings, a missing padlock, a site that looks slightly wrong, or transactions you did not make. If you suspect pharming, change your passwords from another device, run an antivirus scan, and contact your bank immediately.
How can I protect myself from pharming?
Use official apps for banking, check for HTTPS and a valid certificate, turn on two-factor authentication, keep your router updated, and use a secure DNS service. If a site shows a security warning, close it.
Conclusion
Pharming is a quiet, large-scale attack that turns a trusted address into a trap. Secure your router, use safe DNS, check for HTTPS, turn on two-factor authentication, and keep your devices updated.


