Skip to content

Commit

Permalink
Add missing win_util file
Browse files Browse the repository at this point in the history
Fix windows agent not working due to this file missing
  • Loading branch information
morellexf13 committed Jun 22, 2024
1 parent 5f5f6f8 commit d4683c7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
62 changes: 62 additions & 0 deletions pymobiledevice3/osu/win_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import datetime
import os
import socket
from pathlib import Path
from typing import List, Tuple

import win32security
from ifaddr import get_adapters

from pymobiledevice3.osu.os_utils import DEFAULT_AFTER_IDLE_SEC, DEFAULT_INTERVAL_SEC, OsUtils
from pymobiledevice3.usbmux import MuxConnection


class Win32(OsUtils):
@property
def is_admin(self) -> bool:
""" Check if the current OS user is an Administrator or root.
See: https://github.com/Preston-Landers/pyuac/blob/master/pyuac/admin.py
:return: True if the current user is an 'Administrator', otherwise False.
"""
try:
admin_sid = win32security.CreateWellKnownSid(win32security.WinBuiltinAdministratorsSid, None)
return win32security.CheckTokenMembership(None, admin_sid)
except Exception:
return False

@property
def usbmux_address(self) -> Tuple[str, int]:
return MuxConnection.ITUNES_HOST, socket.AF_INET

@property
def bonjour_timeout(self) -> int:
return 2

@property
def loopback_header(self) -> bytes:
return b'\x00\x00\x86\xdd'

@property
def access_denied_error(self) -> str:
return 'This command requires admin privileges. Consider retrying with "run-as administrator".'

@property
def pair_record_path(self) -> Path:
return Path(os.environ.get('ALLUSERSPROFILE', ''), 'Apple', 'Lockdown')

def get_ipv6_ips(self) -> List[str]:
return [f'{adapter.ips[0].ip[0]}%{adapter.ips[0].ip[2]}' for adapter in get_adapters() if
adapter.ips[0].is_IPv6]

def set_keepalive(self, sock: socket.socket, after_idle_sec: int = DEFAULT_AFTER_IDLE_SEC,
interval_sec: int = DEFAULT_INTERVAL_SEC, **kwargs) -> None:
sock.ioctl(socket.SIO_KEEPALIVE_VALS, (1, after_idle_sec * 1000, interval_sec * 1000))

def parse_timestamp(self, time_stamp) -> datetime:
return datetime.datetime.fromtimestamp(time_stamp / 1000)

def chown_to_non_sudo_if_needed(self, path: Path) -> None:
return

def wait_return(self):
input('Press ENTER to exit>')
1 change: 0 additions & 1 deletion pymobiledevice3/services/mobile_image_mounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ def auto_mount_developer(lockdown: LockdownServiceProvider, xcode: str = None, v
image_mounter.mount(image_path, signature)



def auto_mount_personalized(lockdown: LockdownServiceProvider) -> None:
local_path = get_home_folder() / 'Xcode_iOS_DDI_Personalized'
local_path.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit d4683c7

Please sign in to comment.