-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
domain_gen
executable file
·40 lines (34 loc) · 913 Bytes
/
domain_gen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl
# abstract: generate a valid domain name
use strict;
use utf8;
use open qw(:std :utf8);
open(my $fh, '<', "$ENV{HOME}/usr/share/doc/wordlists/wordlist_swedish.txt");
#open(my $fh, '<', '/usr/share/dict/cracklib-small') or die($!);
#open(my $fh, '<', "$ENV{HOME}/usr/share/doc/wordlists/big.txt");
#open(my $fh, '<', "$ENV{HOME}/usr/share/doc/wordlists/big") or die($!);
my @words = grep{ (length($_) > 4) && lc(chomp($_)) } (<$fh>);
my $tld = (shift // 'se');
my $limit = shift // 50;
my $count = 0;
for my $w( sort{ length($a) <=> length($b) } grep{ m/$tld/ } @words) {
if($count == $limit) {
exit;
}
if($w =~ s{$tld$}{.$tld}) {
if(_not_registred( $w )) {
print "$w\n";
$count++;
}
}
}
sub _not_registred {
my $d = shift;
open(my $fh, '-|', "whois $d") or die($!);
while(<$fh>) {
if($_ =~ m/not found[.]$/) {
return 1;
}
}
return;
}