Sub topic 5
Lookalike domains, punycode, and malicious search ads
This chapter assumes you know how a URL is built (scheme, hostname, path) and that you have signed in to an exchange or wallet website before. It also assumes you have read the earlier chapter on phishing messages and fake login pages. Here you will learn how attackers make a fake site look like the real one, and how to check a hostname without trusting your eyes.
Why the hostname is the only part that matters
A URL has several parts, and attackers rely on you reading the wrong one. Consider this address:
https://coinbase.com.login-verify.example/signin
Browsers read the hostname from right to left, in groups separated by dots. The registered domain here is login-verify.example. Everything to its left, including coinbase.com, is a subdomain chosen by whoever owns login-verify.example. That owner can create any subdomain for free. The page therefore belongs to the attacker, even though the brand name appears first.
| URL | Real owner of the page |
|---|---|
| `https://www.coinbase.com/` | coinbase.com |
| `https://coinbase.com.login-verify.example/` | login-verify.example |
| `https://[email protected]/` | login-verify.example (the part before `@` is a username) |
| `https://login-verify.example/coinbase.com` | login-verify.example (the brand is only in the path) |
Padlock icons do not help. A padlock means the connection to the site is encrypted. Attackers get free TLS certificates for their own domains, so a fake site can show the padlock.
Common lookalike techniques
Attackers use a small set of tricks. Learn to recognize each one.
- Typosquatting. The domain is a misspelling:
coinbaes.com,binanse.com,metamsk.io. - Added words. The real name plus a plausible word:
binance-support.com,ledger-verify.net,uniswap-claim.org. - Different top-level domain. The same name under another ending:
coinbase.coorkraken.helpinstead of the real domain. - Subdomain tricks. The brand sits in a subdomain, as in the table above.
- Character swaps.
rnlooks likem, a capitalIlooks like a lowercaselin some fonts, and a zero replaces ano. - Homograph domains. Letters from another alphabet that look identical to Latin ones. These use punycode, covered next.
Punycode and homograph attacks
Domain names were originally limited to ASCII letters, digits, and hyphens. Internationalized domain names (IDNs) allow other scripts, such as Cyrillic or Greek. To keep the underlying system ASCII-only, a non-ASCII label is converted to punycode. This is an ASCII encoding that always starts with xn--.
The Cyrillic letter а (U+0430) looks the same as the Latin a (U+0061) in most fonts. A domain made with the Cyrillic letter is a different domain, and an attacker can register it. If your browser displays it in Unicode, you see what looks like the real brand. Underneath, the name is xn--....
The following program converts such a name to punycode and lists the scripts in each character:
import unicodedata
def describe(label: str) -> None:
print("display form :", label)
print("ascii form :", label.encode("idna").decode("ascii"))
for ch in label:
if ord(ch) > 127:
print(f" non-ASCII character {ch!r}: {unicodedata.name(ch)}")
# The first letter is CYRILLIC SMALL LETTER A, not the Latin "a".
describe("\u0430pple.com")The ASCII form begins with xn--, and the character list names the Cyrillic letter. Modern browsers reduce the risk by showing punycode when a label mixes scripts. They do not catch every case, especially a label written entirely in one foreign script. Do not rely on the browser alone.
Checking a hostname in code
A reliable check compares the exact hostname against a short list of known-good hosts. It does not look for the brand name inside the URL, because attackers put the brand name in the URL on purpose.
from urllib.parse import urlparse
OFFICIAL_HOSTS = {"coinbase.com", "www.coinbase.com"}
def check_url(url: str) -> str:
host = (urlparse(url).hostname or "").lower()
if host in OFFICIAL_HOSTS:
return "matches an official host"
if host.startswith("xn--") or ".xn--" in host:
return "punycode label: possible lookalike characters"
return "not on the allowlist: do not sign in"
print(check_url("https://www.coinbase.com/"))
print(check_url("https://coinbase.com.login-verify.example/"))The first call prints matches an official host. The second prints not on the allowlist: do not sign in, because the hostname is coinbase.com.login-verify.example, which is not in the set.
Common errors when writing a check like this:
- Using
"coinbase.com" in url. This accepts every URL in the table above. - Using
url.startswith("https://coinbase.com"). This acceptshttps://coinbase.com.login-verify.example/andhttps://coinbase.company-login.example/. - Using
host.endswith("coinbase.com"). This acceptsnotcoinbase.com. If you must allow subdomains, test forhost == d or host.endswith("." + d), with the leading dot. - Forgetting case. Hostnames are case-insensitive, so lowercase before comparing.
The allowlist approach is the point of this chapter. A browser bookmark works the same way: it stores the exact address you verified once.
Malicious search ads
Many people reach an exchange by typing its name into a search engine. Attackers buy search ads for the same keywords. The ad appears above the real result and often displays the real brand's domain as its visible text. The link behind the ad points elsewhere, sometimes through a redirect or a "cloaked" landing page that shows a harmless page to reviewers and the fake login page to real victims.
Typical patterns:
- The victim searches "ledger live download" or "metamask wallet."
- The top result is an ad, labeled "Sponsored" or "Ad."
- The link leads to a cloned site that asks for a seed phrase, a login, or a software download.
- The victim enters the details, and the attacker uses them within minutes.
The risk is greater for wallet software. A fake download page may offer a trojanized app that looks normal but steals keys or swaps addresses. Fake "wallet validation" pages ask for a seed phrase, which no legitimate service ever needs.
Habits that defeat lookalike domains
- Bookmark the real sites the first time you reach them from a trusted source, such as the project's official social account verified through several independent channels. Then open them only from the bookmark.
- Skip sponsored results for financial and wallet sites. Scroll to the organic result, or better, use the bookmark.
- Read the hostname, not the page. Page design is easy to copy. In the address bar, find the first single slash after
https://and read the text just before it, from right to left. - Install software only from the official source linked from the project's own site. Check the publisher and, when offered, a checksum or signature.
- Use a password manager. It fills credentials only on the exact domain you saved. If it offers nothing on a page that "looks right," treat that as a warning.
- Never type a seed phrase into any website. A site that asks for one is a scam regardless of its domain.
- Treat links in emails, direct messages, and ads as untrusted. Urgency is part of the pitch, as covered in the chapter on social engineering.
Edge cases
- Official domains that look odd. Companies sometimes use separate domains for email, status pages, or help centers. Confirm these from the main site, and do not assume that an unfamiliar domain is official or fake.
- Link shorteners and QR codes. Both hide the destination. Expand a shortened link with a preview tool, or avoid it. Treat a QR code as a link you cannot read.
- Mobile browsers. Small screens truncate the address bar, often hiding the end of a long hostname. Tap the address bar to see the full text.
- Redirects. A good domain can redirect to a bad one. Check the hostname you end up on, not only the one you clicked.
Exercise
You search for an exchange and click the top result, which is marked "Sponsored." The address bar shows https://exchange.com.account-review.example/login. The page looks identical to the exchange's login. Which domain owns this page, and what should you do?
Show answer
The page is owned by account-review.example. The text exchange.com is only a subdomain the attacker created. Do not enter credentials. Close the page, open the exchange from your bookmark or a verified address, and report the ad to the search engine if it offers a report option.
Exercise
A coworker writes a check that treats a URL as official when host.endswith("kraken.com") is true. Give one hostname that passes this check but is not Kraken, and write a safer condition.
Show answer
notkraken.com ends with kraken.com and passes. A safer condition is host == "kraken.com" or host.endswith(".kraken.com"), or an exact-match set of full hostnames as in check_url.