Skip to content

Commit 8c74c68

Browse files
committed
Add private domain switching and change mail providers!
1 parent f619ed6 commit 8c74c68

2 files changed

Lines changed: 87 additions & 120 deletions

File tree

domain92/__main__.py

Lines changed: 86 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
from importlib.metadata import version
1818
import lolpython
1919
import time
20-
20+
import random_header_generator
21+
import temp_mails
22+
headergen = random_header_generator.HeaderGenerator()
2123
parser = argparse.ArgumentParser(
2224
description="Automatically creates links for an ip on freedns"
2325
)
@@ -52,7 +54,7 @@
5254
)
5355
parser.add_argument(
5456
"--pages",
55-
help="range of pages to scrape, see readme for more info (default is first ten)",
57+
help="range of pages to scrape, see wiki for more info (default is first ten)",
5658
type=str,
5759
)
5860
parser.add_argument(
@@ -66,6 +68,7 @@
6668
help="uses tesseract to automatically solve the captchas. tesseract is now included, and doesn't need to be installed seperately",
6769
action="store_true",
6870
)
71+
parser.add_argument("--domain_type", help="Force only public or only private domains, `public` or `private`", type=str)
6972
parser.add_argument("--single_tld", help="only create links for a single tld", type=str)
7073
args = parser.parse_args()
7174
ip = args.ip
@@ -120,39 +123,48 @@ def get_data_path():
120123

121124
def getpagelist(arg):
122125
arg = arg.strip()
123-
if "," in arg:
124-
arglist = arg.split(",")
125-
pagelist = []
126-
for item in arglist:
127-
if "-" in item:
128-
sublist = item.split("-")
129-
if len(sublist) == 2:
126+
if not arg:
127+
checkprint("Empty page range")
128+
sys.exit(1)
129+
130+
pagelist = []
131+
parts = [p.strip() for p in arg.split(",") if p.strip() != ""]
132+
133+
for item in parts:
134+
if "-" in item:
135+
sublist = item.split("-")
136+
if len(sublist) == 2:
137+
try:
130138
sp = int(sublist[0])
131139
ep = int(sublist[1])
132-
if sp < 1 or sp > ep:
133-
checkprint("Invalid page range: " + item)
134-
sys.exit()
135-
pagelist.extend(range(sp, ep + 1))
136-
else:
140+
except ValueError:
141+
checkprint("Invalid page number: " + item)
142+
sys.exit(1)
143+
if sp < 1 or sp > ep:
137144
checkprint("Invalid page range: " + item)
138-
sys.exit()
139-
return pagelist
140-
elif "-" in arg:
141-
pagelist = []
142-
sublist = arg.split("-")
143-
if len(sublist) == 2:
144-
sp = int(sublist[0])
145-
ep = int(sublist[1])
146-
if sp < 1 or sp > ep:
147-
checkprint("Invalid page range: " + arg)
148-
sys.exit()
149-
pagelist.extend(range(sp, ep + 1))
145+
sys.exit(1)
146+
pagelist.extend(range(sp, ep + 1))
147+
else:
148+
checkprint("Invalid page range: " + item)
149+
sys.exit(1)
150150
else:
151-
checkprint("Invalid page range: " + arg)
152-
sys.exit()
153-
return pagelist
154-
else:
155-
return [int(arg)]
151+
try:
152+
p = int(item)
153+
except ValueError:
154+
checkprint("Invalid page number: " + item)
155+
sys.exit(1)
156+
if p < 1:
157+
checkprint("Invalid page number: " + item)
158+
sys.exit(1)
159+
pagelist.append(p)
160+
161+
seen = set()
162+
result = []
163+
for p in pagelist:
164+
if p not in seen:
165+
seen.add(p)
166+
result.append(p)
167+
return result
156168

157169

158170
def getdomains(arg):
@@ -163,24 +175,17 @@ def getdomains(arg):
163175
"https://freedns.afraid.org/domain/registry/?page="
164176
+ str(sp)
165177
+ "&sort=2&q=",
166-
headers={
167-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/jxl,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
168-
"Accept-Encoding": "gzip, deflate, br",
169-
"Accept-Language": "en-US,en;q=0.9",
170-
"Cache-Control": "max-age=0",
171-
"Connection": "keep-alive",
172-
"DNT": "1",
173-
"Host": "freedns.afraid.org",
174-
"Sec-Fetch-Dest": "document",
175-
"Sec-Fetch-Mode": "navigate",
176-
"Sec-Fetch-Site": "none",
177-
"Upgrade-Insecure-Requests": "1",
178-
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
179-
"sec-ch-ua": '"Not;A=Brand";v="24", "Chromium";v="128"',
180-
"sec-ch-ua-platform": "Linux",
181-
},
178+
headers=headergen(),
182179
).text
183-
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=(\d+)>([\w.-]+)<\/a>(.+\..+)<td>public<\/td>"
180+
if args.domain_type == 'private':
181+
checkprint('parsing for private domains')
182+
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=(\d+)>([\w.-]+)<\/a>(.+\..+)<td>private<\/td>"
183+
elif args.domain_type == 'public':
184+
checkprint('parsing for public domains')
185+
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=(\d+)>([\w.-]+)<\/a>(.+\..+)<td>public<\/td>"
186+
else:
187+
checkprint('parsing for both private and public domains')
188+
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=(\d+)>([\w.-]+)<\/a>(.+\..+)<td>(public|private)<\/td>"
184189
matches = re.findall(pattern, html)
185190
domainnames.extend([match[1] for match in matches])
186191
domainlist.extend([match[0] for match in matches])
@@ -193,22 +198,7 @@ def find_domain_id(domain_name):
193198
+ str(page)
194199
+ "&q="
195200
+ domain_name,
196-
headers={
197-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/jxl,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
198-
"Accept-Encoding": "gzip, deflate, br",
199-
"Accept-Language": "en-US,en;q=0.9",
200-
"Cache-Control": "max-age=0",
201-
"Connection": "keep-alive",
202-
"DNT": "1",
203-
"Host": "freedns.afraid.org",
204-
"Sec-Fetch-Dest": "document",
205-
"Sec-Fetch-Mode": "navigate",
206-
"Sec-Fetch-Site": "none",
207-
"Upgrade-Insecure-Requests": "1",
208-
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
209-
"sec-ch-ua": '"Not;A=Brand";v="24", "Chromium";v="128"',
210-
"sec-ch-ua-platform": "Linux",
211-
},
201+
headers=headergen(),
212202
).text
213203
pattern = r"<a href=\/subdomain\/edit\.php\?edit_domain_id=([0-9]+)><font color=red>(?:.+\..+)<\/font><\/a>"
214204
matches = re.findall(pattern, html)
@@ -334,60 +324,49 @@ def login():
334324
image.show()
335325
capcha = input("Enter the captcha code: ")
336326
checkprint("generating email")
337-
stuff = req.get(
338-
"https://api.guerrillamail.com/ajax.php?f=get_email_address"
339-
).json()
340-
email = stuff["email_addr"]
341-
checkprint("email address generated email:" + email)
342-
checkprint(email)
327+
mail = temp_mails.Generator_email()
328+
print('using mail provider: '+ mail.__class__.__name__ )
329+
email = mail.email
330+
checkprint("email address generated email: " + email)
343331
checkprint("creating account")
344-
username = generate_random_string(13)
332+
username = generate_random_string(random.randint(8, 13))
345333
client.create_account(
346334
capcha,
347335
generate_random_string(13),
348336
generate_random_string(13),
349337
username,
350-
"pegleg1234",
338+
'pegleg1234',
351339
email,
352340
)
353341
checkprint("activation email sent")
354342
checkprint("waiting for email")
355-
hasnotreceived = True
356-
while hasnotreceived:
357-
nerd = req.get(
358-
"https://api.guerrillamail.com/ajax.php?f=check_email&seq=0&sid_token="
359-
+ str(stuff["sid_token"])
360-
).json()
361-
362-
if int(nerd["count"]) > 0:
363-
checkprint("email received")
364-
mail = req.get(
365-
"https://api.guerrillamail.com/ajax.php?f=fetch_email&email_id="
366-
+ str(nerd["list"][0]["mail_id"])
367-
+ "&sid_token="
368-
+ str(stuff["sid_token"])
369-
).json()
370-
match = re.search(r'\?([^">]+)"', mail["mail_body"])
371-
if match:
372-
checkprint("code found")
373-
checkprint("verification code: " + match.group(1))
374-
checkprint("activating account")
375-
client.activate_account(match.group(1))
376-
checkprint("accout activated")
377-
time.sleep(1)
378-
checkprint("attempting login")
379-
client.login(email, "pegleg1234")
380-
checkprint("login successful")
381-
hasnotreceived = False
382-
else:
383-
checkprint(
384-
"no match in email! you should generally never get this."
385-
)
386-
checkprint("error!")
387-
343+
text = mail.wait_for_new_email(timeout=30)
344+
if not text:
345+
checkprint("no email received, trying again")
346+
continue
347+
checkprint("email received, getting content")
348+
content = str(mail.get_mail_content(mail_id=text["id"]))
349+
if content:
350+
checkprint("email content found")
351+
if text:
352+
checkprint("email received")
353+
match = re.search(r'\?([^">]+)"', content)
354+
if match:
355+
checkprint("code found")
356+
checkprint("verification code: " + match.group(1))
357+
checkprint("activating account")
358+
client.activate_account(match.group(1))
359+
checkprint("account activated")
360+
time.sleep(1)
361+
checkprint("attempting login")
362+
client.login(email, 'pegleg1234')
363+
checkprint("login successful")
388364
else:
389-
checkprint("checked email")
390-
time.sleep(2)
365+
checkprint(
366+
"no match in email! you should generally never get this."
367+
)
368+
checkprint("error!")
369+
continue
391370
except KeyboardInterrupt:
392371
sys.exit()
393372
except Exception as e:
@@ -433,17 +412,6 @@ def createlinks(number):
433412
createdomain()
434413

435414

436-
def createmax():
437-
login()
438-
checkprint("logged in")
439-
checkprint("creating domains")
440-
createdomain()
441-
createdomain()
442-
createdomain()
443-
createdomain()
444-
createdomain()
445-
446-
447415
def createdomain():
448416
while True:
449417
try:
@@ -576,7 +544,6 @@ def init():
576544
input(
577545
f"Enter the page range(s) to scrape (e.g., 1-10 or 5,8,10-12, default: {args.pages}): "
578546
)
579-
or args.pages
580547
)
581548

582549
if not args.subdomains:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "domain92"
3-
version = "1.3.1"
3+
version = "1.3.2"
44
description = "A totally rad cli tool to automate freedns link creation"
55
authors = ["Cbass92 <contact@cbass92.org>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)