Find shortcuts of hidden files in the same directory.

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Bob McCoy Bob McCoy 1 year, 1 month ago.

  • Author
  • #29366
    Profile photo of Simon Bruce
    Simon Bruce

    We have found a Shylock botnet on one of our servers and one of the symptoms is it replaces all files in a share with identically named shortcuts and then hiding the original files.
    I need to be able to run a script to see which directories have these shortcuts in.
    So there will be a logmein.exe and logmein shortcut in the same location.
    Please help!

  • #29377
    Profile photo of Curtis Smith
    Curtis Smith

    You could use Get-ChildItem to get a Recursive listing of all of your files, excluding those with the .lnk extension. Then use ForEach-Object on the returned list to loop though all the returned files and replace the extension on the FullName property with .lnk and check for the existance of that file. If found. Out-Default that object.

  • #29391
    Profile photo of Wilfredo Perez
    Wilfredo Perez

    Try something like this:

    $dir = Get-ChildItem c:\test -Directory 
    foreach ($Folder in $dir){
       Get-ChildItem $Folder.FullName | where {$_.Extension -eq '.lnk'}
  • #29392
    Profile photo of Bob McCoy
    Bob McCoy

    Keep in mind that Get-ChildItem does not get hidden items by default. To do that you must use the -Force switch.

You must be logged in to reply to this topic.