Добрый день! Ситуация такова имеется ЧПУ станок система ITNC530 последнее время выползло окно с требованием ввести пароль так как прошло 2000 часов его работы, и надо провести его сервисное обслуживание производителем . В связи с санкциями немцы, а они производители станка больно то не хотят с нами общаться. Вообщем решил я попробовать сам добыть пароль сделал бекап системы нашел как я думаю те файлы которые как раз отвечают за проверку пароля . Пароль генерируется по ID ключа он есть. Ну вот дальше привожу код Python 2.7.
Вот вставил участок кода который как я думаю отвечает за проверку пароля, теперь собственно вопросы которые меня пока ставят в тупик и заставили обратится к ВамPHP Code:def setInspektionKey(self, ID, PW):
result = False
ID = int(ID)
myID = ID
listAttr = []
dictAttr = {}
dictAttr['Name'] = "id"
dictAttr['Value'] = str(ID)
listAttr.append(dictAttr)
dictAttr = {}
dictAttr['Name'] = SMARTPW
dictAttr['Value'] = str(PW)
listAttr.append(dictAttr)
#pwInternal = (ID ^(((ID%7)+1)*0x06000000-1))+100000000
#if(pwInternal == int(PW) and (pwInternal > 100000000 or pwInternal < 999999999)):
self.calculateiKey()
if( int(PW) == int(self.m_iKeyPw) ):
result = True
'ID und PW in Konfigdatei schreiben'
node = self.dmgXMLPasre.getNode(IKEYS)
'sichern stelle, ob SmartID in Konfig vorhanden ist'
foundID = False
size = len(self.m_SmartKeyList)
for i in range(size):
SmartKeyData = self.m_SmartKeyList[i]
if(SmartKeyData.m_ID != None and (int(SmartKeyData.m_ID) == int (myID))):
foundID = True
break
if(foundID):
nodeLast, nodeNext = self.dmgXMLPasre.getLastAndNextNode(SMARTKEY, None, str(myID))
self.dmgXMLPasre.repleaseAttribut(node, nodeLast,SMARTKEY, listAttr)
else:
self.dmgXMLPasre.addAttribut(node, SMARTKEY,listAttr)
self.readSmartKeyConfig()
return result
def getIDAndPW(self):
SmartID = None
SmartPw = None
result, pw = self.isInspektionKeyValid()
if(result and pw!=None and self.smartKeyID > 0):
SmartID = self.smartKeyID
SmartPw = pw
elif(result and pw==13 and self.smartKeyID > 0):
'ServiceKey'
SmartID = self.smartKeyID
SmartPw = pw
elif(self.smartKeyID > 0 and ((self.smartKeyID > 10000000) or (self.smartKeyID < 139999999))):
SmartID = self.smartKeyID
else:
size = len(self.m_SmartKeyList) - 1
if(size >= 0):
SmartKeyData = self.m_SmartKeyList[size]
SmartID = SmartKeyData.m_ID
return(SmartID, SmartPw)
def isInspektionKeyValid(self):
result = False
pw = None
'aus Kofig.Datei die eingetragene Password und die zugehГ¶rige ID ermitteln'
size = len(self.m_SmartKeyList)
for i in range(size):
SmartKeyData = self.m_SmartKeyList[i]
if(int(SmartKeyData.m_ID) == self.smartKeyID):
self.calculateiKey()
pw = SmartKeyData.m_PW
if( int(pw) == int (self.m_iKeyPw) ):
result = True
break
if(not result):
skey = str(self.smartKeyID)
index1 = int(string.find(skey, "1", 0))
index2 = int(string.find(skey, "3", 0))
if(SUMULATE_ITNC == 0 and Simulate == 0):
value = (self.smartKeyID ^(((self.smartKeyID%7)+1)*0x06000000-1))+100000000
if((value > 100000000 or value < 999999999)):
if(index1 == 0 and index2 == 1):
result = True
pw = 13
else:
pw = value
else:
if(index1 == 0 and index2 == 1):
result = True
pw = 13
return (result, pw)
def calculateiKey(self):
if(self.m_BTIndex > 0 and self.smartKeyID > 0):
value1 = (self.smartKeyID ^(((self.smartKeyID%7)+1)*0x06000000-1))+100000000
value2 = (65535 ^( self.m_BTIndex*(((self.m_BTIndex%7)+1) + 1000))) * 10000000
self.m_iKeyPw = value1 + value2
else:
self.m_iKeyPw = 0
def CallBackSmartKeyID(self, dict):
if dict != None:
strText = dict[DG_PIT_Unicat_Nummer]
if(len(strText) > 0 and int(strText) > 0):
self.m_SmartKeyActive = True
self.smartKeyID = int(strText)
self.m_MachineCheckView.updateStateOkButton()
def CallBackKeySwitchID(self, dict):
if dict != None:
strText = dict["BG_AKTIVE_BA"]
if(len(strText) > 0):
if(int(strText) == 5 and not self.m_SmartKeyActive):
self.smartKeyID = 130000161
self.m_MachineCheckView.updateStateOkButton()
elif(int(strText) != 5 and not self.m_SmartKeyActive):
self.smartKeyID = 0
self.m_MachineCheckView.updateStateOkButton()
Вот эта функция self.smartKeyID как я понял равна self.smartKeyID = 130000161PHP Code:def calculateiKey(self):
if(self.m_BTIndex > 0 and self.smartKeyID > 0):
value1 = (self.smartKeyID ^(((self.smartKeyID%7)+1)*0x06000000-1))+100000000
value2 = (65535 ^( self.m_BTIndex*(((self.m_BTIndex%7)+1) + 1000))) * 10000000
self.m_iKeyPw = value1 + value2
else:
self.m_iKeyPw = 0
А вот ,что это такое self.m_BTIndex это ID моего ключа?
И еще я не знаю как решить вот эту формулу
value1 = (self.smartKeyID ^(((self.smartKeyID%7)+1)*0x06000000-1))+100000000
value2 = (65535 ^( self.m_BTIndex*(((self.m_BTIndex%7)+1) + 1000))) * 10000000
Мне непонятен вот этот участок (self.smartKeyID ^(((self.smartKeyID%7)+1)*0x06000000
Ну вот вкратце объяснил проблему , да часы переводить на системе пробовал словил глюк, станок начал ощутимо притормаживать. Патчить не вариант .Да прикладываю полностью скрипт .



Reply With Quote
Thanks