Issue
Below are the few variables examples inside the Test
text file that's going to become the web's subdomains.
with open("dictionaries/Combined.txt") as i:
Test = [line.rstrip() for line in i]
Test = ['cl', 'portal', 'find', 'signin', 'payment', 'update', 'group', 'verification',
'confirm', 'claim', 'summary', 'recovery', 'ssl', 'view', 'support']
delimeters = ['','-', '.']
web = 'web'
subdomain_count = 1
suffix = ['co.id', 'info', 'id', 'com']
output = []
in this code i can control how many subdomains and how many domain name i want to generate
for i in range(100):
outputs = []
for j in range(subdomain_count):
outputs.append(random.choice(Test))
prefix = random.choice(delimeters).join(outputs)
out = random.choice(delimeters).join([prefix, web])
tld = random.choice(suffix)
addr = '.'.join([out, tld])
output.append(addr)
Example.write(addr+'\n')
with open("dictionaries/examples.txt") as f:
websamples = [line.rstrip() for line in f]
To generate the number of output that I want I used this linefor i in range(100):
, and to generate how long the domain name's going to be i used this for j in range(subdomain_count):
this is the example what i mean by how long the domain can be. if i set the subdomain count to 1 then the output would become something like this cl.web.info
if i were to add 2 it will become like this update-cl.web.info
. As you can see the subdomain is now 2 characters longer where the update is now another subdomain has been added into the domain. Here is another example I'll show where i made the subdomain_count = 1
.
From here I got a bit confused, since I have made the web variable at a fixed position where it's always going to be behind the suffix. is there any way where for example I give the subdomain_count = 3
and I want the web variable have more flexibility in its position like this cl.web-update.summary.info
or web-cl.info.update.info
where it doesn't just stay behind the suffix or the TLD (Top Level Domain)
Thank you!
Solution
use random.shuffle
to randomize the items in a list. which gives web
variable more flexibility in the domain.
import random
Test = ['cl', 'portal', 'find', 'signin', 'payment', 'update', 'group', 'verification',
'confirm', 'claim', 'summary', 'recovery', 'ssl', 'view', 'support']
delimeters = ['', '-', '.']
web = 'web'
subdomain_count = 3
suffix = ['co.id', 'info', 'id', 'com']
output = []
for i in range(5):
outputs = []
for j in range(subdomain_count):
outputs.append(random.choice(Test))
data = outputs + [web]
random.shuffle(data)
prefix = random.choice(delimeters).join(data)
out = random.choice(delimeters).join([prefix])
tld = random.choice(suffix)
addr = '.'.join([out, tld])
output.append(addr)
print(output)
>>> ['group-summary-web-signin.info', 'web-recovery-signin-verification.co.id', 'paymentupdatewebpayment.co.id', 'update-verification-update-web.id', 'find-group-web-portal.info']
Answered By - Ramesh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.