ail-typo-squatting 是一个 Python 库,用于通过域名置换引擎生成潜在域名拼写错误(typo squatting)列表,以馈送给 AIL 及其他系统。
该工具既可以作为独立工具使用,也可以用于向其他系统提供数据。
如果你不想使用该 Python 库,https://typosquatting-finder.circl.lu/ 是一个在线服务,它正是基于该库构建的。
Python 3.6+
inflect 库
ail-typo-squatting 可以通过 poetry 安装。如果你尚未安装 poetry,可以执行以下命令 curl -sSL https://install.python-poetry.org | python3 -。
$ poetry install
$ poetry shell
$ cd ail-typo-squatting
$ python typo.py -h
$ pip3 install ail-typo-squatting
dacru@dacru:~/git/ail-typo-squatting/bin$ python3 typo.py --help
usage: typo.py [-h] [-v] [-dn DOMAINNAME [DOMAINNAME ...]] [-fdn FILEDOMAINNAME] [-o OUTPUT] [-fo FORMATOUTPUT] [-br] [-dnsr] [-dnsl] [-l LIMIT] [-var] [-ko] [-a] [-om] [-repe] [-repl] [-drepl] [-cho]
[-add] [-md] [-sd] [-vs] [-ada] [-hg] [-ahg] [-cm] [-hp] [-wt] [-wsld] [-at] [-sub] [-sp] [-cdd] [-addns] [-uddns] [-ns] [-combo] [-ca]
optional arguments:
-h, --help show this help message and exit
-v verbose, more display
-dn DOMAINNAME [DOMAINNAME ...], --domainName DOMAINNAME [DOMAINNAME ...]
list of domain name
-fdn FILEDOMAINNAME, --filedomainName FILEDOMAINNAME
file containing list of domain name
-o OUTPUT, --output OUTPUT
path to ouput location
-fo FORMATOUTPUT, --formatoutput FORMATOUTPUT
format for the output file, yara - regex - yaml - text. Default: text
-br, --betterregex Use retrie for faster regex
-dnsr, --dnsresolving
resolve all variation of domain name to see if it's up or not
-dnsl, --dnslimited resolve all variation of domain name but keep only up domain in final result json
-l LIMIT, --limit LIMIT
limit of variations for a domain name
-var, --givevariations
give the algo that generate variations
-ko, --keeporiginal Keep in the result list the original domain name
-a, --all Use all algo
-om, --omission Leave out a letter of the domain name
-repe, --repetition Character Repeat
-repl, --replacement Character replacement
-drepl, --doublereplacement
Double Character Replacement
-cho, --changeorder Change the order of letters in word
-add, --addition Add a character in the domain name
-md, --missingdot Delete a dot from the domain name
-sd, --stripdash Delete of a dash from the domain name
-vs, --vowelswap Swap vowels within the domain name
-ada, --adddash Add a dash between the first and last character in a string
-hg, --homoglyph One or more characters that look similar to another character but are different are called homogylphs
-ahg, --all_homoglyph
generate all possible homoglyph permutations. Ex: circl.lu, e1rc1.lu
-cm, --commonmisspelling
Change a word by is misspellings
-hp, --homophones Change word by an other who sound the same when spoken
-wt, --wrongtld Change the original top level domain to another
-wsld, --wrongsld Change the original second level domain to another
-at, --addtld Adding a tld before the original tld
-sub, --subdomain Insert a dot at varying positions to create subdomain
-sp, --singularpluralize
Create by making a singular domain plural and vice versa
-cdd, --changedotdash
Change dot to dash
-addns, --adddynamicdns
Add dynamic dns at the end of the domain
-uddns, --updatedynamicdns
Update dynamic dns warning list
-ns, --numeralswap Change a numbers to words and vice versa. Ex: circlone.lu, circl1.lu
-combo Combine multiple algo on a domain name
-ca, --catchall Combine with -dnsr. Generate a random string in front of the domain.
ail-project.org 和 circl.lu 生成变体,使用所有算法。dacru@dacru:~/git/ail-typo-squatting/bin$ python3 typo.py -dn ail-project.org circl.lu -a -o .
dacru@dacru:~/git/ail-typo-squatting/bin$ python3 typo.py -fdn domain.txt -co -sub -hyp -o . -fo yara
ail-project.org 和 circl.lu 生成变体,使用所有算法并启用 DNS 解析。dacru@dacru:~/git/ail-typo-squatting/bin$ python3 typo.py -dn ail-project.org circl.lu -a -dnsr -o .
ail-project.org 生成变体,并给出生成该变体的算法(仅限文本格式)。dacru@dacru:~/git/ail-typo-squatting/bin$ python3 typo.py -dn ail-project.org -a -o - -var
from ail_typo_squatting import runAll
import math
resultList = list()
domainList = ["google.com"]
formatoutput = "yara"
pathOutput = "."
for domain in domainList:
resultList = runAll(
domain=domain,
limit=math.inf,
formatoutput=formatoutput,
pathOutput=pathOutput,
verbose=False,
givevariations=False,
keeporiginal=False
)
print(resultList)
resultList = list()
from ail_typo_squatting import formatOutput, omission, subdomain, addDash
import math
resultList = list()
domainList = ["google.com"]
limit = math.inf
formatoutput = "yara"
pathOutput = "."
for domain in domainList:
resultList = omission(domain=domain, resultList=resultList, verbose=False, limit=limit, givevariations=False, keeporiginal=False)
resultList = subdomain(domain=domain, resultList=resultList, verbose=False, limit=limit, givevariations=False, keeporiginal=False)
resultList = addDash(domain=domain, resultList=resultList, verbose=False, limit=limit, givevariations=False, keeporiginal=False)
print(resultList)
formatOutput(format=formatoutput, resultList=resultList, domain=domain, pathOutput=pathOutput, givevariations=False)
resultList = list()
输出文件有 4 种 可用格式:
对于 Text 文件,每一行是一个变体。
ail-project.org
il-project.org
al-project.org
ai-project.org
ailproject.org
ail-roject.org
ail-poject.org
ail-prject.org
ail-proect.org
ail-projct.org
ail-projet.org
ail-projec.org
aail-project.org
aiil-project.org
...
对于 Yara 文件,每条规则是一个变体。
rule ail-project_org {
meta:
domain = "ail-project.org"
strings:
$s0 = "ail-project.org"
$s1 = "il-project.org"
$s2 = "al-project.org"
$s3 = "ai-project.org"
$s4 = "ailproject.org"
$s5 = "ail-roject.org"
$s6 = "ail-poject.org"
$s7 = "ail-prject.org"
$s8 = "ail-proect.org"
$s9 = "ail-projct.org"
$s10 = "ail-projet.org"
$s11 = "ail-projec.org"
condition:
any of ($s*)
}
对于 Regex 文件,每个变体被转换为正则表达式,并与其他变体拼接成一个大的正则表达式。
ail\-project\.org|il\-project\.org|al\-project\.org|ai\-project\.org|ailproject\.org|ail\-roject\.org|ail\-poject\.org|ail\-prject\.org|ail\-proect\.org|ail\-projct\.org|ail\-projet\.org|ail\-projec\.org
对于 Sigma 文件,所有变体列在 variations 键下。
title: ail-project.org
variations:
- ail-project.org
- il-project.org
- al-project.org
- ai-project.org
- ailproject.org
- ail-roject.org
- ail-poject.org
- ail-prject.org
- ail-proect.org
- ail-projct.org
- ail-projet.org
- ail-projec.org
如果选择了 DNS 解析,将会额外生成一个 JSON 格式的文件。
每个键都是一个变体,并且如果该域名已被解析,则可能包含 "ip" 字段。"NotExist" 字段每次都会出现,其布尔值用于判断该域名是否存在。
{
"circl.lu": {
"NotExist": false,
"ip": [
"185.194.93.14"
]
},
"ircl.lu": {
"NotExist": true
},
"crcl.lu": {
"NotExist": true
},
"cicl.lu": {
"NotExist": true
},
"cirl.lu": {
"NotExist": true
},
"circ.lu": {
"NotExist": true
},
"ccircl.lu": {
"NotExist": true
},
"ciircl.lu": {
"NotExist": true
},
...
}

该项目由 CEF-TC-2020-2 - 2020-EU-IA-0260 - JTAN - 联合威胁分析网络(Joint Threat Analysis Network)共同资助。
| 算法 | 描述 |
|---|
| AddDash | 通过在字符串第一个和最后一个字符之间添加一个连字符来生成这些拼写错误。 |
| Addition | 通过在域名中添加一个字符来生成这些拼写错误。 |
| AddDynamicDns | 通过在原始域名末尾添加一个动态 DNS 来生成这些拼写错误。 |
| AddTld | 通过在正确的顶级域之前添加一个顶级域来生成这些拼写错误。示例:google.com 变为 google.com.it |
| ChangeDotDash | 通过将点更改为连字符来生成这些拼写错误。 |
| ChangeOrder | 通过更改域名每个部分中字母的顺序来生成这些拼写错误。 |
| Combo | 通过组合多种算法来生成这些拼写错误。例如,circl.lu 变为 cirl6.lu |
| CommonMisspelling | 通过将单词替换为其常见拼写错误来生成这些拼写错误。包含来自维基百科的 8000 多个常见拼写错误。例如,www.youtube.com 变为 www.youtub.com,www.abseil.com 变为 www.absail.com。 |
| Double Replacement | 通过替换域名中相同且连续的字母来生成这些拼写错误。 |
| Homoglyph | 通过将字符替换为外观相似但实际不同的字符来生成这些拼写错误。例如,小写字母 l 看起来与数字 1 相似,即 l 与 1。例如,google.com 变为 goog1e.com。 |
| Homophones | 通过将单词替换为另一个发音相同的单词来生成这些拼写错误。包含超过 450 组发音相同的单词。例如,www.base.com 变为 www.bass.com。 |
| MissingDot | 通过删除域名中的一个点来生成这些拼写错误。 |
| NumeralSwap | 通过将数字替换为单词,反之亦然来生成这些拼写错误。例如,circlone.lu 变为 circl1.lu。 |
| Omission | 通过每次遗漏域名中的一个字母来生成这些拼写错误。 |
| Repetition | 通过重复域名中的一个字母来生成这些拼写错误。 |
| Replacement | 通过替换域名中的每个字母来生成这些拼写错误。 |
| StripDash | 通过删除域名中的一个连字符来生成这些拼写错误。 |
| SingularPluralize | 通过将单数域名变为复数,反之亦然来生成这些拼写错误。 |
| Subdomain | 通过在域名中放置一个点以创建子域名来生成这些拼写错误。示例:google.com 变为 goo.gle.com |
| VowelSwap | 通过交换域名中的元音(首字母除外)来生成这些拼写错误。例如,www.google.com 变为 www.gaagle.com。 |
| WrongTld | 通过将原始顶级域替换为另一个顶级域来生成这些拼写错误。例如,www.trademe.co.nz 变为 www.trademe.co.mz,www.google.com 变为 www.google.org。使用 19 个最常见的顶级域。 |
| WrongSld | 通过将原始二级域替换为另一个二级域来生成这些拼写错误。例如,www.trademe.co.uk 变为 www.trademe.ac.uk,而 www.google.com 仍将为 www.google.com。 |