Exemple #1
0
def get_public_suffix_list():
    """Initialize Public Suffix List"""
    try:
        psl_file = fetch()
        psl = PublicSuffixList(psl_file=psl_file)
    except Exception:
        psl = PublicSuffixList()
    return psl
Exemple #2
0
def get_public_suffix_list() -> PublicSuffixList:
    # Initialize Public Suffix List
    try:
        psl_file = fetch()
        psl = PublicSuffixList(psl_file=psl_file)
    except Exception as e:
        logging.getLogger(__name__).warning(f'Unable to fetch the PublicSuffixList: {e}')
        psl = PublicSuffixList()
    return psl
def issDotCom(inputDomain):
    cert=readDomain(inputDomain)
    x509_One=crypto.load_certificate(crypto.FILETYPE_PEM, cert)
	psl = PublicSuffixList(idna=True)
	Issuer_is_com= False
	j= 'com'
	if j in psl.get_tld(cert.get_issuer().CN):
		Issuer_is_com = True
	else:
		Issuer_is_com = False
	return Issuer_is_com 
def subDotCom(inputDomain):
    cert=readDomain(inputDomain)
    x509_One=crypto.load_certificate(crypto.FILETYPE_PEM, cert)
	psl = PublicSuffixList(idna=True)
	Subject_is_com= False
	j= 'com'
	if j in psl.get_tld(cert.get_subject().CN):
		Subject_is_com = True
	else:
		Subject_is_com = False
	return  Subject_is_com 
Exemple #5
0
def issueriscom():
	psl = PublicSuffixList(idna=True)
	x509 = readCert()
	Issuer_is_com=[]
	for cert in x509:
		k= False
		j= 'com'
		if j in psl.get_tld(cert.get_issuer().CN):
				 k = True
		else:
				 k=False
		Issuer_is_com.append(k)
	return Issuer_is_com
Exemple #6
0
def subjectiscom():
	psl = PublicSuffixList(idna=True)
	x509 = readCert()
	Subject_is_com=[]
	for cert in x509:
		i= False
		j= 'com'
		if j in psl.get_tld(cert.get_subject().CN):
				 i = True
		else:
				 i=False		 
		Subject_is_com.append(i)
	return Subject_is_com
Exemple #7
0
 def __init__(self) -> None:
     """Initialise information probes."""
     self.psl = PublicSuffixList()
     self.reg = RegistryProbe()
     self.dns = DnsProbe()
     self.hosts = HostsProbe()
Exemple #8
0
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import urllib.parse
import warnings

try:
    from publicsuffix2 import PublicSuffixList
    psl = PublicSuffixList(idna=False)
except ImportError:
    warnings.warn("Unable to import the nodule 'publicsuffix2'. "
                  "Will be unable to parse domain names.")
    psl = None


urlparse_edge = {
    'color': {
        'color': '#4d4d4d'
    },
    'title': 'URL Parsing Functions',
    'label': 'u'
}

Exemple #9
0
    from urllib import unquote as urllib_unquote

try:
    unicode
    str = unicode
except NameError:
    unicode = str

# Python versions
_sys_v0 = sys.version_info[0]
py2 = _sys_v0 == 2
py3 = _sys_v0 == 3

# For publicsuffix utilities
from publicsuffix2 import PublicSuffixList
psl = PublicSuffixList()

# Come codes that we'll need
IDNA = codecs.lookup('idna')
UTF8 = codecs.lookup('utf-8')
ASCII = codecs.lookup('ascii')
W1252 = codecs.lookup('windows-1252')

# The default ports associated with each scheme
PORTS = {'http': 80, 'https': 443}


def parse(url):
    '''Parse the provided url string and return an URL object'''
    return URL.parse(url)
Exemple #10
0
def get_org_domain(domain):
    fn = get_suffix_list_file_name()
    with open(fn) as suffixList:
        psl = PublicSuffixList(suffixList)
        return psl.get_public_suffix(domain)
Exemple #11
0
from publicsuffix2 import PublicSuffixList

psl = PublicSuffixList(psl_file="/tmp/public_suffix_list.dat")
for domain in [
    "www.google.co.jp",
    "foo.bar.yokohama.jp",
    "bar.yokohama.jp",
    "yokohama.jp",
    "jp",
    "foo.bar.platform.sh",
    "bar.platform.sh",
    "platform.sh",
    "sh",
    "foo.s3.amazonaws.com",
    "s3.amazonaws.com",
    "foo.s1.amazonaws.com",
    "s1.amazonaws.com",
    "amazonaws.com",
]:
    print(f"[{domain}]")
    print(f"root: {psl.get_public_suffix(domain)}")
    print(f"public suffix: {psl.get_tld(domain)}")
    print()