-
Notifications
You must be signed in to change notification settings - Fork 0
/
findExtensions.py
executable file
·40 lines (33 loc) · 1.18 KB
/
findExtensions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import os
import glob
from urllib.parse import urlparse
import re
from extension import Extension
def findLinks(filename):
with open(filename,"r",encoding='utf8') as file:
output=file.read()
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', output)
return(urls)
def findDomains(filename):
urls = findLinks(filename)
domains = [urlparse(url)[1].split('/') for url in urls]
return(domains)
if __name__ == '__main__':
if os.name=="posix":
path=os.path.expanduser("~/.config/google-chrome/Default/Extensions/*")
elif os.name=="nt":
path=os.path.expanduser(r"~/AppData/Local/Google/Chrome/User Data/Default/Extensions/*")
# result=os.listdir(path)
extensions=[]
extensionPaths=glob.glob(path)
for extensionPath in extensionPaths:
try:
extensions.append( Extension(extensionPath) )
except ValueError:
pass
for extension in extensions:
print(extension.manifest["name"])
for path in filter(lambda x: x.endswith('.js'), extension.filelist):
# print(path)
print(findLinks(path))