Created
June 7, 2016 13:10
-
-
Save Konctantin/f10f75d084712120e65cc187cea14355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def AsByteStr(s, appendZero=True): | |
| return (" ".join("%02X" % x for x in map(ord, s))) + (" 00" if appendZero else "") | |
| def GetClientBuild(): | |
| ref = FindBinary(0, SEARCH_DOWN, AsByteStr("<Version>", False)); | |
| if ref == BADADDR: | |
| raise BaseException("Can't find offset for "+name); | |
| verStr = GetString(ref, -1, ASCSTR_C); | |
| result = re.findall("(\d{5})", verStr); | |
| print(verStr) | |
| if len(result)==0: | |
| raise BaseException("Build not found in: " + verStr); | |
| return result[0]; | |
| def GetSendOffset(): | |
| offs = FindBinary(0, SEARCH_DOWN, "48 89 5C 24 10 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ?? 48 8B D9 48 81 C1 ?? ?? ?? ??") | |
| if offs == BADADDR: | |
| raise BaseException("Can't find Send function") | |
| return offs | |
| def GetRecvOffset(): | |
| offs = FindBinary(0, SEARCH_DOWN, AsByteStr("ClientServices.cpp"), 0) | |
| if offs == BADADDR: | |
| raise BaseException("Can't find Recv function") | |
| prev = PrevHead(offs) | |
| for x in xrange(0, 18): | |
| prev = PrevHead(prev) | |
| offs = Qword(prev) | |
| return offs | |
| def GetLocaleOffset(): | |
| str_offset = FindBinary(0, SEARCH_DOWN, AsByteStr("apft"), 0) | |
| if str_offset != BADADDR: | |
| next = DfirstB(str_offset) # lea rcx, aApft | |
| next = NextHead(next) # call sub_xxxxxxxxx | |
| next = NextHead(next) # or [rbp+var_40], 2 | |
| next = NextHead(next) # mov [rbp+var_34], eax | |
| next = NextHead(next) # call GetLocaleName() | |
| if GetMnem(next) == "call": | |
| funcAddr = GetOperandValue(next, 0) | |
| if funcAddr > 0 and funcAddr < BADADDR: | |
| movOperand = FirstFuncFchunk(funcAddr) | |
| if GetMnem(movOperand) == "mov": | |
| lang = GetOperandValue(movOperand, 1) | |
| if lang > 0 and lang < BADADDR: | |
| return lang | |
| raise BaseException("Incorrect lang addr: %X" % lang) | |
| else: | |
| raise BaseException("Incorrect Instruction: " + GetMnem(next)) | |
| else: | |
| raise BaseException("It's is not func addr: "+str(funcAddr)) | |
| else: | |
| raise BaseException("Incorrect Instruction: " + GetMnem(next)) | |
| else: | |
| raise BaseException("Can't find \"apft\"") | |
| send = GetSendOffset() | |
| recv = GetRecvOffset() | |
| lang = GetLocaleOffset() | |
| print("["+GetClientBuild()+"]") | |
| print("send=0x%08X" % (send-0x140000000)) | |
| print("recv=0x%08X" % (recv-0x140000000)) | |
| print("lang=0x%08X" % (lang-0x140000000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment