stephanlinke

Passhashes

Feb 22nd, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #requires -version 4.0
  2. # ___ ___ _____ ___
  3. #| _ \ _ \_   _/ __|
  4. #|  _/   / | || (_ |
  5. #|_| |_|_\ |_| \___|
  6. #  Credential Lister
  7. ###################
  8. #
  9. # What exactly is this?
  10. ###################
  11. # This script shows you all the configured credentials in PRTG (only domain and username).
  12. # This will allow you to discern where a faulty account is stored in case it gets locked due to PRTG
  13. # still using outdated credentials. It will show all types of credentials.
  14. ###################
  15. #
  16. # How does it work?
  17. ###################
  18. # Simply execute the script on your PRTG server and it will show a filterable and sortable list.
  19. # Depending on the size of your configuration, it may take a while, please be patient.
  20. ###################
  21. #
  22. # How do I configure the script itself?
  23. ###################
  24. # The script doesn't need any configuration.
  25. #
  26. # Version History
  27. # ----------------------------
  28. # 1.1        [Bugfix] Groups were discarded and are now included in the view
  29. # 1.0        Initial Release
  30. # # # # # # # # # # # # # # # # # # # # # # # # # #
  31.  
  32. #region configuration
  33. ## PRTG configuration
  34. [string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
  35.    [xml] $configuration = New-Object -TypeName XML;
  36.          $configuration.Load($ConfigurationFilePath)
  37.  
  38. ## nodes
  39. $prtgGroups  = $configuration.SelectNodes("//group")
  40. $prtgDevices = $configuration.SelectNodes("//device")
  41. #endregion
  42.  
  43. #region function
  44. <# Function Section
  45. #################################
  46. All functions of the script are defined here.
  47. ############################### #>
  48.  
  49. <# Function Name: This-GetXMLValue
  50. #################################
  51. Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim
  52. #################################
  53. Parameters:
  54. # [xml]    object - the object that should have it's node extracted
  55. # [string] node   - the node you want retrieved
  56. ################################# #>
  57. function This-GetXMLValue($object,[string]$node){
  58.  
  59.     if( $node -eq "windowsloginpassword" ){  
  60.      try   { $value = $object.data.windowsloginpassword.cell.trim(); }
  61.      catch { $value = "Inherited" }
  62.     }
  63.     else{
  64.      try   { $value = $object.data.$node.trim(); }
  65.      catch { $value = "Inherited" }
  66.     }
  67.     return $value;
  68.  
  69. }
  70. #endregion
  71.  
  72. $Credentials = foreach($prtgGroup in $prtgGroups){
  73.     [pscustomobject]@{
  74.             ID   = $prtgGroup.ID
  75.             Name = $prtgGroup.data.name.Trim()
  76.             Type = "Group"
  77.             "Windows Domain"  = (This-GetXMLValue -node "windowslogindomain" -object $prtgGroup)
  78.             "Windows Login"   = (This-GetXMLValue -node "windowsloginusername" -object $prtgGroup)
  79.             "Windows Passwd"  = (This-GetXMLValue -node "windowsloginpassword" -object $prtgGroup)
  80.             "Linux Login"     = (This-GetXMLValue -node "linuxloginusername" -object $prtgGroup)
  81.             "ESX Login"       = (This-GetXMLValue -node "esxuser" -object $prtgGroup)
  82.             "Database Login"  = (This-GetXMLValue -node "dbuser" -object $prtgGroup)
  83.             "SNMP Community"  = (This-GetXMLValue -node "snmpuser" -object $prtgGroup)
  84.            }
  85. }
  86.  
  87. $Credentials += foreach($prtgDevice in $prtgDevices){
  88.     [pscustomobject]@{
  89.             ID   = $prtgDevice.ID
  90.             Name = $prtgDevice.data.name.Trim()
  91.             Type = "Device"
  92.             "Windows Domain" = (This-GetXMLValue -node "windowslogindomain" -object $prtgDevice)
  93.             "Windows Login"  = (This-GetXMLValue -node "windowsloginusername" -object $prtgDevice)
  94.             "Windows Passwd" = (This-GetXMLValue -node "windowsloginpassword" -object $prtgDevice)
  95.             "Linux Login"    = (This-GetXMLValue -node "linuxloginusername" -object $prtgDevice)
  96.             "ESX Login"      = (This-GetXMLValue -node "esxuser" -object $prtgDevice)
  97.             "Database Login" = (This-GetXMLValue -node "dbuser" -object $prtgDevice)
  98.             "SNMP Username"  = (This-GetXMLValue -node "snmpuser" -object $prtgDevice)
  99.            }
  100. }
  101. #>
  102.  
  103. $Credentials | Out-GridView -Title "PRTG Credentials"
Advertisement
Add Comment
Please, Sign In to add comment