malicious-url-classifier / src /challenge_set.py
DaveyD347's picture
Add malicious URL classifier
84f95cd verified
Raw History Blame Contribute Delete
6.46 kB
"""Write the hand-written challenge set (data/challenge.parquet).
60 URLs written by hand to probe what the templates don't cover: real, well-known benign URLs (including long,
login-ish or download-ish ones) and malicious-style URLs that impersonate REAL brands on made-up domains (the
training data only uses fictional brands). Malicious URLs are invented for this file, not taken from threat feeds,
and are stored defanged like the rest of the dataset.
"""
import argparse
import os
import pandas as pd
from generate_dataset import defang
BENIGN = [
("real_popular", "https://en.wikipedia.org/wiki/Phishing"),
("real_popular", "https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/linear_model/_logistic.py"),
("real_popular", "https://www.amazon.com/gp/your-account/order-history?ref_=ya_d_c_yo"),
("real_login", "https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&flowName=GlifWebSignIn"),
("real_login", "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=4765445b-32c6-49b0-83e6-1d93765276ca&response_type=code&redirect_uri=https%3A%2F%2Fwww.office.com%2Flandingv2&scope=openid%20profile"),
("real_login", "https://www.paypal.com/signin?returnUri=https%3A%2F%2Fwww.paypal.com%2Fmyaccount%2Fsummary"),
("real_login", "https://secure.chase.com/web/auth/dashboard#/dashboard/overview"),
("real_download", "https://www.python.org/ftp/python/3.13.1/python-3.13.1-amd64.exe"),
("real_download", "https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe"),
("real_download", "https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=en-US"),
("real_storage", "https://drive.google.com/drive/folders/1a2B3c4D5e6F7g8H9i0JkLmNoPqRsTuV?usp=sharing"),
("real_storage", "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0"),
("real_tracking", "https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&url=https%3A%2F%2Fdocs.python.org%2F3%2Ftutorial%2F&usg=AOvVaw0"),
("real_tracking", "https://www.linkedin.com/comm/jobs/view/3912345678?trackingId=abcDEF123%3D%3D&refId=xyz&midToken=AQH"),
("real_misc", "https://www.bbc.co.uk/news/technology-68123456"),
("real_misc", "https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do-in-python"),
("real_misc", "https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=42s"),
("real_misc", "https://maps.google.com/?q=Eiffel+Tower"),
("real_misc", "https://huggingface.co/datasets/DaveyD347/synthetic-phishing-emails"),
("real_misc", "https://pypi.org/project/scikit-learn/"),
("real_misc", "https://www.irs.gov/refunds"),
("real_misc", "https://www.gov.uk/check-uk-visa"),
("real_misc", "https://bit.ly/3xYzAbC"),
("real_misc", "https://xn--mnchen-3ya.de/"),
("real_misc", "http://192.168.1.1/"),
("real_misc", "https://username.github.io/portfolio/"),
("real_misc", "https://www.reddit.com/r/netsec/comments/1abcde/new_phishing_kit_targets_banks/"),
("real_misc", "https://support.apple.com/en-us/102568"),
("real_misc", "https://www.nytimes.com/2024/05/14/technology/ai-security-scams.html"),
("real_misc", "https://store.steampowered.com/app/570/Dota_2/"),
]
MALICIOUS = [
("real_brand_sub", "https://paypal.com.account-verify.top/signin"),
("real_brand_sub", "http://appleid.apple.com.secure-id-check.xyz/login"),
("real_brand_sub", "https://login.microsoftonline.com.auth-session.click/common/oauth2"),
("real_brand_combo", "https://netflix-billing-update.com/account/payment"),
("real_brand_combo", "https://amazon-prime-renewal.online/confirm"),
("real_brand_combo", "http://wellsfargo-secure-alert.info/verify.php"),
("real_brand_combo", "https://coinbase-wallet-restore.site/connect"),
("real_lookalike", "https://www.paypa1.com/cgi-bin/webscr?cmd=_login-run"),
("real_lookalike", "https://rnicrosoft-support.com/office365/login"),
("real_lookalike", "https://www.arnazon-orders.net/your-account"),
("real_homoglyph", "https://xn--pple-43d.com/id/verify"),
("real_at", "https://www.google.com@34.102.77.9/drive/shared"),
("real_ip", "http://45.137.21.9/dhl/track/index.php?id=88213"),
("real_freehost", "https://outlook-web-access.web.app/owa/auth/logon.aspx"),
("real_freehost", "https://storage.googleapis.com/wbx38fk2/docusign-review.html#victim@company.com"),
("real_freehost", "https://metamask-sync.pages.dev/restore"),
("real_cms", "http://greenvalleydental.com/wp-content/uploads/2024/chase/online/login.php"),
("real_redirect", "https://www.trustedsite.com/out?url=https%3A%2F%2Fsecure-docs-view.top%2Fsharepoint"),
("real_malware", "http://update-browser-now.xyz/Chrome_Update_2025.exe"),
("real_malware", "http://185.244.25.11/bins/bot.arm7"),
("real_malware", "https://files-share-cdn.com/download/Invoice_88213.pdf.exe"),
("real_malware", "http://whatsapp-plus-download.ml/WhatsApp_Plus_v17.apk"),
("real_malware", "https://drive-docs-files.click/Scan_0042.iso"),
("real_dga", "http://xkqz7v3pm2rt.top/gate.php"),
("real_ddns", "http://office365-mail.duckdns.org/owa/"),
("real_scam", "https://usps-redelivery-fee.com/pay"),
("real_scam", "https://ezpass-toll-balance.info/pay-now"),
("real_scam", "http://windows-defender-alert.live/call?number=18885551234"),
("real_scam", "https://free-robux-generator.online/claim"),
("real_subtle", "https://secure-messaging-portal.com/document/view?id=48213"),
]
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--out", default="data")
args = ap.parse_args()
rows = [(f, u, 0) for f, u in BENIGN] + [(f, u, 1) for f, u in MALICIOUS]
df = pd.DataFrame({"id": [f"c{i:03d}" for i in range(len(rows))], "url": [defang(u) for _, u, _ in rows],
"label": [l for *_, l in rows], "family": [f for f, *_ in rows]})
df["label_name"] = df.label.map({0: "benign", 1: "malicious"})
df["category"] = ["benign" if l == 0 else "mixed" for l in df.label]
df["variant_id"] = "challenge/" + df.family
os.makedirs(args.out, exist_ok=True)
df[["id", "url", "label", "label_name", "category", "family", "variant_id"]].to_parquet(
f"{args.out}/challenge.parquet", index=False)
print(len(df), "challenge URLs")
if __name__ == "__main__":
main()