Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(permute): add support for character insertion between two vowels #75

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,6 @@ async fn main() {
- Exceptionally fast end-to-end results
- Core library allowing easy extensions (i.e. CLI, API & streams)

#### Permutation Modes

- [x] Addition
- [x] Bit Squatting
- [x] Homoglyph
- [x] Hyphenation
- [x] Insertion
- [x] Omission
- [x] Repetition
- [x] Replacement
- [x] Sub-domain
- [x] Transposition
- [x] Vowel-swap
- [x] Dictionary
- [x] TLD addition

#### Domain Enrichment Features

- [x] DNS lookup
- [x] MX parsing
- [ ] SMTP Banner
- [x] HTTP Banner
- [x] GeoIP Lookup (Cached)
- [x] WhoIs Lookup

#### Miscellaneous
- [x] [Blog post](https://blog.digital-horror.com/twistrs)
- [x] [HaveIBeenSquatted](https://haveibeensquatted.com/)
Expand Down
48 changes: 47 additions & 1 deletion twistrs/src/permutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub enum PermutationKind {
Subdomain,
Transposition,
VowelSwap,
DoubleVowelInsertion,
Keyword,
Tld,
Homoglyph,
Expand Down Expand Up @@ -148,6 +149,7 @@ impl Domain {
.chain(self.subdomain())
.chain(self.transposition())
.chain(self.vowel_swap())
.chain(self.double_vowel_insertion())
.chain(self.keyword())
.chain(self.tld())
.chain(self.homoglyph()?))
Expand Down Expand Up @@ -496,7 +498,7 @@ impl Domain {
.chars()
.enumerate()
.filter_map(move |(i, c)| {
if VOWELS.contains(&c) {
if VOWELS.contains(&c.to_ascii_lowercase()) {
Some(VOWELS.iter().filter_map(move |vowel| {
let permutation =
format!("{}{}{}", &self.fqdn[..i], vowel, &self.fqdn[i + 1..]);
Expand All @@ -519,6 +521,37 @@ impl Domain {
.flatten()
}

/// Permutation method that inserts every lowercase ascii character between
/// two vowels.
pub fn double_vowel_insertion(&self) -> impl Iterator<Item = Permutation> + '_ {
self.fqdn
.chars()
.enumerate()
.tuple_windows()
.filter_map(move |((i1, c1), (i2, c2))| {
if VOWELS.contains(&c1.to_ascii_lowercase())
&& VOWELS.contains(&c2.to_ascii_lowercase())
{
Some(ASCII_LOWER.iter().filter_map(move |inserted| {
let permutation =
format!("{}{inserted}{}", &self.fqdn[..=i1], &self.fqdn[i2..]);

if let Ok(domain) = Domain::new(permutation.as_str()) {
Some(Permutation {
domain,
kind: PermutationKind::DoubleVowelInsertion,
})
} else {
None
}
}))
} else {
None
}
})
.flatten()
}

/// Permutation mode that appends and prepends common keywords to the
/// domain in the following order:
///
Expand Down Expand Up @@ -770,4 +803,17 @@ mod tests {
assert!(!permutations.is_empty());
}
}

#[test]
fn test_domains_double_vowel_insertion() {
let domain = Domain::new("exampleiveus.com").unwrap();
let expected = Domain::new("exampleivesus.com").unwrap();

let results: Vec<Permutation> = domain
.double_vowel_insertion()
.filter(|p| p.domain.fqdn == expected.fqdn)
.collect();

assert_eq!(results.len(), 1);
}
}
Loading