Skip to content

Use this in powershell #3

@asmith3006

Description

@asmith3006

I wanted to give you this as your JS is the basis of my Powershell script.

This uses Selenium to iterate through your domain list and get the DNS. This will output a series of .zone files based on your script.

Feel free to use this as you wish.

$Username = ""
$Password = ""

$Script = @"
// CONFIG BEGIN
var defaultTTL = 300;
// CONFIG END
 
var table = document.getElementsByClassName('advanced_dns')[0];
var rows = table.getElementsByTagName('tr');
var i, len, row;
var hostname, type, priority, ttl, destination;
var output = '';
 
//output += '`$TTL ' + defaultTTL + '\n'; // start with default TTL
 
// skip header and last two rows (add new entry, delete all entries)
for (i = 1, len = rows.length - 2; i < len; i++) {
  row = rows[i];
  hostname = row.getElementsByClassName('dns_hostname')[0].innerText;
  type = row.getElementsByClassName('dns_type')[0].innerText;
  priority = row.getElementsByClassName('dns_priority')[0].innerText;
  ttl = row.getElementsByClassName('dns_ttl')[0].innerText || defaultTTL;
  destination = row.getElementsByClassName('dns_data')[0].title;
 
  if (type === 'TXT/SPF') {
    type = 'TXT';
    destination = '"' + destination + '"';
  }
 
  output += [hostname, ttl, 'IN', type, priority, destination].join(' ') + '\n';
}
return output;
"@

$Enter = ([OpenQA.Selenium.Keys]::Enter)


$Driver = Start-SeFirefox
Enter-SeUrl "https://sso.123-reg.co.uk/?app=ott&path=%2Fsecure" -Driver $Driver

Start-Sleep -Seconds 2

$E = Find-SeElement -Driver $Driver -Id "1"
Send-SeKeys -Element $E -Keys $Username

$E = Find-SeElement -Driver $Driver -Id "2"
Send-SeKeys -Element $e -Keys $Password
Send-SeKeys -Element $e -Keys $Enter

$E = Find-SeElement -Driver $Driver -CssSelector ".UPM__PrivacyModal > div:nth-child(1) > form:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(2) > span:nth-child(2) > span:nth-child(1) > button:nth-child(1) > span:nth-child(1)"
Invoke-SeClick -Element $E


$E = Find-SeElement -Driver $Driver -CssSelector ".UDN__Modal > div:nth-child(1) > button:nth-child(2) > img:nth-child(2)"
Invoke-SeClick -Element $E

$E = Find-SeElement -Driver $Driver -Id "dom_select"

$DomainList = [OpenQA.Selenium.Support.UI.SelectElement]::new($E)
$domains = @()
$DomainList.Options | % {
    $Domains += $_.Text    
}
$domains | % {
    Enter-SeUrl "https://www.123-reg.co.uk/secure/cpanel/manage-dns?domain=$($_)" -Driver $Driver
    $use123 = $Driver.ExecuteScript("return `$('#not_use123ns.hidden').length")
    if ($use123 -eq "1") {
        $Driver.ExecuteScript("`$('#advanced-tab').trigger('click')")
        Start-Sleep -Second 2
        $dns = $Driver.ExecuteScript($Script)
        $dns | out-file -FilePath ".\$($_).zone"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions