Exemplo n.º 1
0
def test_whoisguard_disable():
	# Comment the return statement below to let this test case run
	return
	api = Api(username, api_key, username, ip_address, sandbox = False)
	#api.debug = False
	xml = api.whoisguard_disable('15558880')
	print("XML:", xml, file=sys.stderr)
Exemplo n.º 2
0
def test_domains_dns_getHosts():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = test_register_domain()
	api.domains_dns_setHosts(
		domain_name,
		[{
			'HostName' : '@',
			'RecordType' : 'URL',
			'Address' : 'http://news.ycombinator.com',
			'MXPref' : '10',
			'TTL' : '100'
		},
		{
			'HostName' : '*',
			'RecordType' : 'A',
			'Address' : '1.2.3.4',
			'MXPref' : '10',
			'TTL' : '1800'
		}]
	)

	hosts = api.domains_dns_getHosts(domain_name)

	# these might change
	del hosts[0]['HostId'] 
	del hosts[1]['HostId'] 

	expected_result = [{'Name': '*', 'Address': '1.2.3.4', 'TTL': '1800', 'Type': 'A', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': ''}, {'Name': '@', 'Address': 'http://news.ycombinator.com', 'TTL': '100', 'Type': 'URL', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': ''}]
	assert_equal(hosts, expected_result)
Exemplo n.º 3
0
def test_domains_dns_getHosts():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = test_register_domain()
	api.domains_dns_setHosts(
		domain_name,
		[{
			'HostName' : '@',
			'RecordType' : 'URL',
			'Address' : 'http://news.ycombinator.com',
			'MXPref' : '10',
			'TTL' : '100'
		},
		{
			'HostName' : '*',
			'RecordType' : 'A',
			'Address' : '1.2.3.4',
			'MXPref' : '10',
			'TTL' : '1800'
		}]
	)

	hosts = api.domains_dns_getHosts(domain_name)

	# these might change
	del hosts[0]['HostId'] 
	del hosts[1]['HostId'] 

	expected_result = [{'Name': '*', 'Address': '1.2.3.4', 'TTL': '1800', 'Type': 'A', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': ''}, {'Name': '@', 'Address': 'http://news.ycombinator.com', 'TTL': '100', 'Type': 'URL', 'MXPref': '10', 'AssociatedAppTitle': '', 'FriendlyName': '', 'IsActive': ''}]
	assert_equal(hosts, expected_result)
Exemplo n.º 4
0
def test_domains_dns_setDefault_on_nonexisting_domain():
    api = Api(username, api_key, username, ip_address, sandbox=True)

    domain_name = random_domain_name()

    # This should fail because the domain does not exist
    api.domains_dns_setDefault(domain_name)
Exemplo n.º 5
0
def test_domains_dns_setDefault_on_nonexisting_domain():
	api = Api(username, api_key, username, ip_address, sandbox = True)

	domain_name = random_domain_name()

	# This should fail because the domain does not exist
	api.domains_dns_setDefault(domain_name)	
Exemplo n.º 6
0
def test_whoisguard_getIdByDomainName():
	# Comment the return statement below to let this test case run
	return
	api = Api(username, api_key, username, ip_address, sandbox = False)
	api.debug = False
	#whoisguardId = api.whoisguard_getIdByDomainName('banteg.tech')
	#whoisguardId = api.whoisguard_getIdByDomainName('kampret.site')
	whoisguardId = api.whoisguard_getIdByDomainName('kingkong.site')
	#assert_equal('15558880', whoisguardId)
	assert_equal('15570269', whoisguardId)
Exemplo n.º 7
0
def test_domains_dns_setHosts():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    domain_name = test_register_domain()
    api.domains_dns_setHosts(domain_name, [{
        'HostName': '@',
        'RecordType': 'URL',
        'Address': 'http://news.ycombinator.com',
        'MXPref': '10',
        'TTL': '100'
    }])
Exemplo n.º 8
0
def test_whoisguard_enable():
	# Comment the return statement below to let this test case run
	return
	api = Api(username, api_key, username, ip_address, sandbox = False)
	api.debug = False
	try:
		xml = api.whoisguard_enable('15558880', '*****@*****.**')
		print("XML:", xml, file=sys.stderr)
	except ApiError as e:
		print("e: ", e.number, type(e.number), file=sys.stderr)
		if e.number != '2011331':
			raise e
Exemplo n.º 9
0
def main():
    global domains_long, domains_short, domains, api, message_queu, backup_restored, domains_types
    digital_ocean_token = config.digital_ocean_token
    message_queu["action1"] = []
    message_queu["action2"] = []
    message_queu["action3"] = []
    message_queu["action4"] = []
    message_queu["action5"] = []
    message_queu["action6"] = []
    message_queu["action7"] = []

    if config.namecheap_key == "":
        print(f"{bcolors.FAIL}[+] Namecheap API Key missing{bcolors.ENDC}")
        sys.exit()
    if config.apivoid_key == "":
        print(f"{bcolors.FAIL}[+] APIVoid API Key missing{bcolors.ENDC}")
        sys.exit(0)

    api = Api(config.namecheap_username,
              config.namecheap_key,
              config.namecheap_ipaddress,
              sandbox=False)

    for i in config.names:
        domains_types[i] = config.names[i]

    temp_domains = list(api.domains_getList())
    backup_restored = check_backup()
    for i in temp_domains:
        domains.append(i['name'])

    check_names = True
    for i in config.names:
        if len(config.names[i]) == 0:
            check_names = False
            break
    if check_names == False:
        check_names = True
        for i in domains_types:
            if len(domains_types[i]) == 0:
                print("[+] No domains found in haul " + i)
                check_names = False
        if check_names == False:
            restricted_menu()

    thread = Thread(target=set_and_check)
    thread.start()
    thread2 = Thread(target=menu)
    thread2.start()

    thread.join()
    thread2.join()
Exemplo n.º 10
0
def test_domains_dns_setHosts():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = test_register_domain()
	api.domains_dns_setHosts(
		domain_name,
		[{
			'HostName' : '@',
			'RecordType' : 'URL',
			'Address' : 'http://news.ycombinator.com',
			'MXPref' : '10',
			'TTL' : '100'
		}]
	)
Exemplo n.º 11
0
def test_whoisguard_getList():
	# Comment the return statement below to let this test case run
	return
	api = Api(username, api_key, username, ip_address, sandbox = False)
	#api.debug = False
	whoisguard_list = api.whoisguard_getList(Page=1, PageSize=20)
	try:
		i = 1
		while True:
			whoisguard = whoisguard_list.next()
			print("WHOISGUARD: ", i, whoisguard['ID'], whoisguard['DomainName'], file=sys.stderr)
			i += 1
	except StopIteration as e:
		pass
Exemplo n.º 12
0
def test_domains_dns_bulkAddHosts():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    api.payload_limit = 3
    domain_name = test_register_domain()
    api.domains_dns_setHosts(domain_name,
                             [{
                                 'HostName': '@',
                                 'RecordType': 'URL',
                                 'Address': 'http://news.ycombinator.com'
                             }])
    for i in range(1, 10):
        api.domains_dns_addHost(
            domain_name, {
                'Name': "test" + str(i),
                'Type': 'A',
                'Address': '1.2.3.4',
                'TTL': '60'
            })

    hosts = api.domains_dns_getHosts(domain_name)

    if len(hosts) == 10:
        return True

    return False
Exemplo n.º 13
0
def test_register_domain():
    api = Api(username, api_key, username, ip_address, sandbox=True)

    # Try registering a random domain. Fails if exception raised.
    domain_name = random_domain_name()
    api.domains_create(DomainName=domain_name,
                       FirstName='Jack',
                       LastName='Trotter',
                       Address1='Ridiculously Big Mansion, Yellow Brick Road',
                       City='Tokushima',
                       StateProvince='Tokushima',
                       PostalCode='771-0144',
                       Country='Japan',
                       Phone='+81.123123123',
                       EmailAddress='*****@*****.**')
    return domain_name
Exemplo n.º 14
0
def test_register_domain():
	api = Api(username, api_key, username, ip_address, sandbox = True)

	# Try registering a random domain. Fails if exception raised.
	domain_name = random_domain_name()
	api.domains_create(
		DomainName = domain_name,
		FirstName = 'Jack',
		LastName = 'Trotter',
		Address1 = 'Ridiculously Big Mansion, Yellow Brick Road',
		City = 'Tokushima',
		StateProvince = 'Tokushima',
		PostalCode = '771-0144',
		Country = 'Japan',
		Phone = '+81.123123123',
		EmailAddress = '*****@*****.**'
	)
	return domain_name
Exemplo n.º 15
0
def test_domains_create_with_whoisguard():
	# Comment the return statement below to let this test case run
	return
	api = Api(username, api_key, username, ip_address, sandbox = False)
	#api.debug = False
	api.domains_create(
		#DomainName = 'kampret.site',
		DomainName = 'kingkong.site',
		FirstName = 'Jack',
		LastName = 'Trotter',
		Address1 = 'Ridiculously Big Mansion, Yellow Brick Road',
		City = 'Tokushima',
		StateProvince = 'Tokushima',
		PostalCode = '771-0144',
		Country = 'Japan',
		Phone = '+81.123123123',
		EmailAddress = '*****@*****.**',
		whoisguardActivated = True,
	)
Exemplo n.º 16
0
 def get_client(self, NamecheapConfig):
     if NamecheapConfig.api_key == '' or NamecheapConfig.username == '':
         print(
             f'{color.red}[!] Add Namecheap configs to config file{color.end}'
         )
         exit()
     return Api(NamecheapConfig.username,
                NamecheapConfig.api_key,
                NamecheapConfig.username,
                NamecheapConfig.ip_address,
                sandbox=False)
Exemplo n.º 17
0
def check_availability(domains, retry_count=0):
    if retry_count > 5:
        return []
    print('Try %s' % (retry_count + 1))
    client_ip = get_current_machine_public_ip()
    api = Api(configs.username,
              configs.api_key,
              configs.username,
              client_ip,
              sandbox=False,
              debug=False)
    try:
        domain_statuses = api.domains_check(domains)
        result = []
        for domain, status in domain_statuses.iteritems():
            result.append([domain, status])
    except Exception as error:
        print(error)
        time.sleep(10)
        result = check_availability(domains, retry_count + 1)
    return result
Exemplo n.º 18
0
def test_list_of_dictionaries_to_numbered_payload():
    x = [{'foo': 'bar', 'cat': 'purr'}, {'foo': 'buz'}, {'cat': 'meow'}]

    result = Api._list_of_dictionaries_to_numbered_payload(x)

    expected_result = {
        'foo1': 'bar',
        'cat1': 'purr',
        'foo2': 'buz',
        'cat3': 'meow'
    }

    assert_equal(result, expected_result)
Exemplo n.º 19
0
def create_a_records(user, key) -> None:
    ip = requests.get('http://ifconfig.me')
    for i in tqdm(range(len(services))):
        record = {
            "Type": "A",
            "Name": services[i],
            "Address": ip,
            "TTL": "1799",
        }
        api = Api(user,
                  key,
                  user,
                  ip.text,
                  sandbox=False,
                  attempts_count=3,
                  attempts_delay=0.1)
        import sys
        sys.stdout = None
        api.domains_dns_addHost(os.environ['DOMAIN'], record)
        sys.stdout = sys.__stdout__

    print(f'✅ SUCCESS: {len(services)} A Record(s) successfully created!')
Exemplo n.º 20
0
def test_list_of_dictionaries_to_numbered_payload():
	x = [
		{'foo' : 'bar', 'cat' : 'purr'},
		{'foo' : 'buz'},
		{'cat' : 'meow'}
	]

	result = Api._list_of_dictionaries_to_numbered_payload(x)

	expected_result = {
		'foo1' : 'bar',
		'cat1' : 'purr',
		'foo2' : 'buz',
		'cat3' : 'meow'
	}

	assert_equal(result, expected_result)
Exemplo n.º 21
0
def test_domains_dns_bulkAddHosts():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    api.payload_limit = 3
    domain_name = test_register_domain()
    api.domains_dns_setHosts(
        domain_name,
        [{
            'HostName': '@',
            'RecordType': 'URL',
            'Address': 'http://news.ycombinator.com'
        }]
    )
    for i in range(1, 10):
        api.domains_dns_addHost(
            domain_name,
            {'Name': "test" + str(i), 'Type': 'A', 'Address': '1.2.3.4', 'TTL': '60'}
        )

    hosts = api.domains_dns_getHosts(domain_name)

    if len(hosts) == 10:
        return True

    return False
Exemplo n.º 22
0
def record_add(record_type, hostname, address, ttl=300):
    record = {
        "Type": record_type,
        "Name": hostname,
        "Address": address,
        "TTL": str(ttl)
    }
    api.domains_dns_addHost(domain, record)


args = get_args()

domain = args.domain
print("domain: %s" % domain)

api = Api(username,
          api_key,
          username,
          ip_address,
          sandbox=args.sandbox,
          debug=args.debug)

if args.add:
    record_add(args.type, args.name, args.address, args.ttl)
elif args.delete:
    record_delete(args.name, args.address, args.type)
elif args.list:
    for line in list_records():
        print("\t%s \t%s\t%s -> %s" %
              (line["Type"], line["TTL"], line["Name"], line["Address"]))
Exemplo n.º 23
0
def test_domain_available():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    domain_name = random_domain_name()
    assert_equal(api.domains_check(domain_name), True)
Exemplo n.º 24
0
from namecheap import Api
api = Api(esskenner, c8e5856fe3f847c1abc9a9ba5e100569, esskenner)
Exemplo n.º 25
0
def test_domains_dns_setDefault_on_existing_domain():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = test_register_domain()
	api.domains_dns_setDefault(domain_name)	
Exemplo n.º 26
0
# sudo apt-get install python3-requests
from namecheap import Api, ApiError
import pprint
from credentials import api_key, username, ip_address

badnames = "parkingpage.namecheap.com."  # newipv6
githuba = "192.30.252.153"
githubb = "192.30.252.154"
from yaml import load, dump

try:
    from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
    from yaml import Loader, Dumper

api = Api(username, api_key, username, ip_address, sandbox=False, debug=False)

dlist = api.domains_getList()
from yaml import load, dump

l = {}
for x in dlist:

    domain_name = x["Name"]

    #        print (domain_name)

    # try:
    #         x['hosts']=api.domains_dns_getHosts(domain_name)
    # except Exception as e:
    #         print (e)
Exemplo n.º 27
0
def test_domains_getList():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	api.domains_getList()
Exemplo n.º 28
0
def test_domain_available():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = random_domain_name()
	assert_equal(api.domains_check(domain_name), True)
Exemplo n.º 29
0
def test_domain_taken():
	api = Api(username, api_key, username, ip_address, sandbox = True)
	domain_name = "google.com"
	assert_equal(api.domains_check(domain_name), False)
Exemplo n.º 30
0
def test_domain_taken():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    domain_name = "google.com"
    assert_equal(api.domains_check(domain_name), False)
Exemplo n.º 31
0
def test_domains_getList():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    iter(api.domains_getList())
Exemplo n.º 32
0
def get_api() -> Api:
    return Api(username, api_key, ip_address, sandbox=True, debug=True)
Exemplo n.º 33
0
def test_domains_dns_setDefault_on_existing_domain():
    api = Api(username, api_key, username, ip_address, sandbox=True)
    domain_name = test_register_domain()
    api.domains_dns_setDefault(domain_name)
Exemplo n.º 34
0
from namecheap import Api, ApiError
import config

api = Api(config.namecheap_username,
          config.namecheap_key,
          config.namecheap_ipaddress,
          sandbox=False)

contact_details = dict(FirstName='Jack',
                       LastName='Trotter',
                       Address1='Ridiculously Big Mansion, Yellow Brick Road',
                       City='Tokushima',
                       StateProvince='Tokushima',
                       PostalCode='771-0144',
                       Country='Japan',
                       Phone="+81.123123123",
                       EmailAddress='*****@*****.**')


def set_redirect_records(domain, ip):
    info = api.list_records(domain)
    for i in info:
        type = i["type"]
        name = i["name"]
        address = i["address"]
        api.delete_record(domain, type, address, name)
    api.add_record(domain, 'A', ip)

    api.add_record(domain, 'A', ip, 'www')