Skip to content

Commit

Permalink
chg: [algo] dynamic dns
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCruciani committed Dec 1, 2023
1 parent 1c0499a commit 6c15e2f
Show file tree
Hide file tree
Showing 8 changed files with 35,224 additions and 141 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ The tool can be used as a stand-alone tool or to feed other systems.
- Python 3.6+
- [inflect](https://github.com/jaraco/inflect) library
- [pyyaml](https://pyyaml.org/wiki/PyYAMLDocumentation)

## Optional
- [tldextract](https://github.com/john-kurkowski/tldextract)

- [dnspython](https://github.com/rthalley/dnspython)

Expand All @@ -37,10 +36,8 @@ $ pip3 install ail-typo-squatting

```bash
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] [-ns] [-combo] [-ca]
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
Expand Down Expand Up @@ -74,8 +71,7 @@ optional arguments:
-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
-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
Expand All @@ -91,9 +87,12 @@ optional arguments:
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.
```
# Usage example
Expand Down
13 changes: 3 additions & 10 deletions ail_typo_squatting/generator/addDynamicDns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .utils.generator_functions import *
from .utils.get_pathetc import get_path_etc

import requests, json
import json

pathEtc = get_path_etc()

Expand All @@ -14,15 +14,8 @@ def addDynamicDns(domain, resultList, verbose, limit, givevariations=False, kee
if verbose:
print("[+] Dynamic DNS")

try:
r = requests.get("https://raw.githubusercontent.com/MISP/misp-warninglists/main/lists/dynamic-dns/list.json")
dynamicdns = r.json()['list']
with open(pathEtc + "/dynamic-dns.json", "w") as write_json:
json.dump(r.json(), write_json, indent=4)
except:
with open(pathEtc + "/dynamic-dns.json", "r") as read_json:
dynamicdns = json.load(read_json)["list"]

with open(pathEtc + "/dynamic-dns.json", "r") as read_json:
dynamicdns = json.load(read_json)["list"]

resultLoc = list()

Expand Down
33 changes: 25 additions & 8 deletions ail_typo_squatting/typo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Import all the modules

## The public libraries
import os, sys, math
import os, sys, math, json, requests

import pathlib, sys
sys.path.append(str(os.path.join(pathlib.Path(__file__).parent)))
Expand Down Expand Up @@ -50,6 +50,18 @@
algo_list = const_get_algo_name_list()


def update_ddns_list():
try:
r = requests.get("https://raw.githubusercontent.com/MISP/misp-warninglists/main/lists/dynamic-dns/list.json")
with open(os.path.join(get_path_etc(), "dynamic-dns.json"), "w") as write_json:
json.dump(r.json(), write_json, indent=4)

print("[+] Dynamic Dns warning list updated")
except:
print("Error during update...")
exit(1)


## [START] Final treatment

def runAll(domain, limit, formatoutput, pathOutput, verbose=False, givevariations=False, keeporiginal=False, all_homoglyph=False):
Expand All @@ -58,8 +70,9 @@ def runAll(domain, limit, formatoutput, pathOutput, verbose=False, givevariation
resultList = list()

for algo in algo_list:
func = globals()[algo]
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal)
if not algo == "addDynamicDns":
func = globals()[algo]
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal)

if verbose:
print(f"Total: {len(resultList)}")
Expand All @@ -77,6 +90,9 @@ def runAll(domain, limit, formatoutput, pathOutput, verbose=False, givevariation
parser = getArguments()
args = parser.parse_args()

if args.updatedynamicdns:
update_ddns_list()

resultList = list()

# Step 2: Assign some variables
Expand Down Expand Up @@ -163,11 +179,12 @@ def runAll(domain, limit, formatoutput, pathOutput, verbose=False, givevariation
print(f"{len(loc_result)}\n")
elif args.all:
for algo in algo_list:
func = globals()[algo]
if algo == "homoglyph":
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal, all=args.all_homoglyph)
else:
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal)
if not algo == "addDynamicDns":
func = globals()[algo]
if algo == "homoglyph":
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal, all=args.all_homoglyph)
else:
resultList = func(domain, resultList, verbose, limit, givevariations, keeporiginal)
else:
for arg in vars(args):
for algo in algo_list:
Expand Down
1 change: 1 addition & 0 deletions ail_typo_squatting/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def getArguments():
parser.add_argument("-sp", "--singularpluralize", help="Create by making a singular domain plural and vice versa", action="store_true")
parser.add_argument("-cdd", "--changedotdash", help="Change dot to dash", action="store_true")
parser.add_argument("-addns", "--adddynamicdns", help="Add dynamic dns at the end of the domain", action="store_true")
parser.add_argument("-uddns", "--updatedynamicdns", help="Update dynamic dns warning list", action="store_true")
parser.add_argument("-ns", "--numeralswap", help="Change a numbers to words and vice versa. Ex: circlone.lu, circl1.lu", action="store_true")
parser.add_argument("-combo", help="Combine multiple algo on a domain name", action="store_true")
parser.add_argument("-ca", "--catchall", help="Combine with -dnsr. Generate a random string in front of the domain.", action="store_true")
Expand Down
Loading

0 comments on commit 6c15e2f

Please sign in to comment.