Skip to content

Instantly share code, notes, and snippets.

@carlospolop
Created September 20, 2023 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlospolop/96ecb9e385a4667b9e40b24e878652f9 to your computer and use it in GitHub Desktop.
Save carlospolop/96ecb9e385a4667b9e40b24e878652f9 to your computer and use it in GitHub Desktop.
Down load all macos xpc authorization rights and get the interesting ones
import requests
from bs4 import BeautifulSoup
import json
import re
BASE_URL = "https://www.dssw.co.uk/reference/authorization-rights/"
def get_rights_links():
response = requests.get(BASE_URL)
soup = BeautifulSoup(response.content, 'html.parser')
paths = [a['href'] for a in soup.find_all('a', href=True) if not '/' in a['href'] and not ':' in a['href']]
return paths
def get_right_details(path):
response = requests.get(BASE_URL + path)
soup = BeautifulSoup(response.content, 'html.parser')
# Extracting the JSON details
bad_json_text = soup.find_all('pre')[0].text
return bad_json_text
def main():
rights_paths = get_rights_links()
rights_with_authenticate_user_false = []
rights_with_allow_root_true = []
rights_with_session_owner_true = []
for path in rights_paths:
details = get_right_details(path)
if "'authenticate-user' : 'false'" in details:
if "'allow-root' : 'true'" in details:
group = "run as root"
elif "'session-owner' : 'true'" in details:
group = "session owner"
else:
group = re.search(r"'group' : '([\w\-]+)',", details, re.MULTILINE).group(1)
rights_with_authenticate_user_false.append(f"{path} ({group})")
if "'allow-root' : 'true'" in details:
rights_with_allow_root_true.append(path)
if "'session-owner' : 'true'" in details:
rights_with_session_owner_true.append(path)
print("Rights with 'authenticate-user': 'false':", ", ".join(rights_with_authenticate_user_false))
print("Rights with 'allow-root': 'true':", ", ".join(rights_with_allow_root_true))
print("Rights with 'session-owner': 'true':", ", ".join(rights_with_session_owner_true))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment