sebus

getkeys

Sep 29th, 2012
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.80 KB | None | 0 0
  1. <head>
  2.  <title>Microsoft Product Key Retrieval</title>
  3.  <hta:application
  4.  applicationname="MSKeyRetrieval"
  5.  caption="MSKeyRetrieval"
  6.  contextmenu="no"
  7.  maximizebutton="no"
  8.  minimizebutton="yes"
  9.  navigable="yes"
  10.  showintaskbar="yes"
  11.  singleinstance="yes"
  12.  sysmenu="yes"
  13. >
  14.  </head>
  15.  <script language="VBScript">
  16.  Const HKEY_LOCAL_MACHINE = &H80000002
  17. Const SEARCH_KEY = "DigitalProductID"
  18. Dim foundKeys
  19. Dim iValues
  20. Dim arrDPID
  21. Dim strHTML
  22. Dim arrSubKeys(4,1)
  23. foundKeys = Array()
  24. iValues = Array()
  25. arrSubKeys(0,0) = "Microsoft Windows"
  26. arrSubKeys(0,1) = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
  27. arrSubKeys(2,0) = "Microsoft Office 2010"
  28. arrSubKeys(2,1) = "SOFTWARE\Microsoft\Office\14.0\Registration"
  29. arrSubKeys(1,0) = "Microsoft Office 2003"
  30. arrSubKeys(1,1) = "SOFTWARE\Microsoft\Office\11.0\Registration"
  31. arrSubKeys(3,0) = "Microsoft Office 2007"
  32. arrSubKeys(3,1) = "SOFTWARE\Microsoft\Office\12.0\Registration"
  33. arrSubKeys(4,0) = "Microsoft Exchange Product Key"
  34. arrSubKeys(4,1) = "SOFTWARE\Microsoft\Exchange\Setup"
  35. Sub window_onload
  36.  ' <--------------- Set window Size --------------->
  37.         strComputer = "."
  38.         Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  39.         Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
  40.         For Each objItem in colItems
  41.             intHorizontal = objItem.ScreenWidth
  42.             intVertical = objItem.ScreenHeight
  43.         Next
  44.         intLeft = (intHorizontal - 500) / 2
  45.         intTop = (intVertical - 600) / 2
  46.         window.resizeTo 500,600
  47.  '       window.moveTo intLeft, intTop
  48.  
  49.  ' <--------------- Open Registry Key and populate binary data into an array -------------------------->
  50.  strComputer = "."
  51.  Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
  52.  For x = LBound(arrSubKeys, 1) To UBound(arrSubKeys, 1)
  53.   oReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1), SEARCH_KEY, arrDPIDBytes
  54.   If Not IsNull(arrDPIDBytes) Then
  55.    call decodeKey(arrDPIDBytes, arrSubKeys(x,0))
  56.   Else
  57.    oReg.EnumKey HKEY_LOCAL_MACHINE, arrSubKeys(x,1), arrGUIDKeys
  58.    If Not IsNull(arrGUIDKeys) Then
  59.     For Each GUIDKey In arrGUIDKeys
  60.      oReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1) & "\" & GUIDKey, SEARCH_KEY, arrDPIDBytes
  61.      If Not IsNull(arrDPIDBytes) Then
  62.       call decodeKey(arrDPIDBytes, arrSubKeys(x,0))
  63.      End If
  64.     Next
  65.    End If
  66.   End If
  67.  Next
  68.  If IsNull(foundkeys) Then
  69.   DataArea.InnerHTML = "No Keys Found"
  70.  Else
  71.   DataArea.InnerHTML = strHTML
  72.  End If
  73. End Sub
  74. ' <----------------------- Return the Product Key ------------------------>
  75. Function decodeKey(iValues, strProduct)
  76.  Dim arrDPID
  77.  arrDPID = Array()
  78.  
  79.  ' <--------------- extract bytes 52-66 of the DPID -------------------------->
  80.  For i = 52 to 66
  81.   ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
  82.   arrDPID( UBound(arrDPID) ) = iValues(i)
  83.  Next
  84.  ' <--------------- Create an array to hold the valid characters for a microsoft Product Key -------------------------->
  85.  Dim arrChars
  86.  arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")
  87.  
  88.  ' <--------------- The clever bit !!! (decode the base24 encoded binary data)-------------------------->
  89.  For i = 24 To 0 Step -1
  90.   k = 0
  91.   For j = 14 To 0 Step -1
  92.    k = k * 256 Xor arrDPID(j)
  93.    arrDPID(j) = Int(k / 24)
  94.    k = k Mod 24
  95.   Next
  96.   strProductKey = arrChars(k) & strProductKey
  97.   If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
  98.  Next
  99.  ReDim Preserve foundKeys( UBound(foundKeys) + 1 )
  100.  foundKeys( UBound(foundKeys) ) = strProductKey
  101.  If strProduct = "Microsoft Windows" Then
  102.   strComputer = "."
  103.   Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  104.   Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
  105.   For Each objOperatingSystem in colOperatingSystems
  106.    strOS = objOperatingSystem.Caption
  107.   Next
  108.   strHTML = strHTML & "<h3>" & strOS & "</h3>" & _
  109.     "<h4>" & strProductKey & "</h4><br /><hr /><br />"
  110.  Else
  111.   strHTML = strHTML & "<h3>" & strProduct & "</h3>" & _
  112.     "<h4>" & strProductKey & "</h4><br /><hr /><br />"
  113.  End If
  114. End Function
  115.  
  116. </script>
  117. <body>
  118. <div id="header" style="color:#ffffff; height:100px; text-align:center; font-family:Tahoma;
  119.    filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#0011aa', EndColorStr='#ffffff')">
  120.    <br /><h2>Retrieved Microsoft Product Keys</h2>
  121.  </div><hr />
  122.  <span id="DataArea"></span>
  123.  <br />
  124.  <div id="Print" style="text-align:center;"><input type="button" value="Print" Onclick="print()" ;></div>
  125.  </body>
  126.  </html>
Advertisement
Add Comment
Please, Sign In to add comment