Commit dd9931c71726055d74740fa2f706808e497ccfa7

Authored by root
1 parent c405df32

Fixed issue with pefile

Showing 1 changed file with 22 additions and 25 deletions
winver.py
... ... @@ -25,30 +25,25 @@ def getWindowsVersion(path):
25 25 if(os.path.isfile(getWindowsDirectory(path) + "/System32/ntdll.dll")):
26 26 version = ""
27 27 pe = pefile.PE(getWindowsDirectory(path) + "/System32/ntdll.dll")
28   - for entry in pe.FileInfo:
29   - if hasattr(entry, 'StringTable'):
30   - for st in entry.StringTable:
31   - for k, v in st.entries.items():
32   - if k == "ProductVersion":
33   - version = v
34   - if re.match("(3|4)\.",version) != None:
35   - return _WIN_NT
36   - elif re.match("5\.0", version) != None:
37   - return _WIN_2k
38   - elif re.match("5\.1", version) != None:
39   - return _WIN_XP
40   - elif re.match("5\.2", version) != None:
41   - return _WIN_2k3
42   - elif re.match("6\.0", version) != None:
43   - return _WIN_VISTA
44   - elif re.match("6\.1", version) != None:
45   - return _WIN_7
46   - elif re.match("6\.2", version) != None:
47   - return _WIN_8
48   - elif re.match("6\.3", version) != None:
49   - return _WIN_81
50   - elif re.match("10\.", version) != None:
51   - return _WIN_10
  28 + version = str(pe.FileInfo[0].StringTable[0].entries[b'ProductVersion'],'utf-8')
  29 + if re.match("(3|4)\.",version) != None:
  30 + return _WIN_NT
  31 + elif re.match("5\.0", version) != None:
  32 + return _WIN_2k
  33 + elif re.match("5\.1", version) != None:
  34 + return _WIN_XP
  35 + elif re.match("5\.2", version) != None:
  36 + return _WIN_2k3
  37 + elif re.match("6\.0", version) != None:
  38 + return _WIN_VISTA
  39 + elif re.match("6\.1", version) != None:
  40 + return _WIN_7
  41 + elif re.match("6\.2", version) != None:
  42 + return _WIN_8
  43 + elif re.match("6\.3", version) != None:
  44 + return _WIN_81
  45 + elif re.match("10\.", version) != None:
  46 + return _WIN_10
52 47 else:
53 48 if(os.path.isfile(getWindowsDirectory(path) + "/CLASSES.DAT")):
54 49 return _WIN_ME
... ... @@ -84,4 +79,6 @@ def getUserProfiles(path):
84 79 profiles.append(profilepath + "/" + elem)
85 80  
86 81 return profiles
87   - pass
88 82 \ No newline at end of file
  83 + pass
  84 +
  85 +
... ...