The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Is this code malicious?

wanderingwandering Russia state-affiliated mediaRegistered User regular
Here’s code for a bat file to hide/unhide folders in Windows. I’ve been asked if it’s malicious. After googling it and looking it over, I can’t find any indication that it is, but I’m code-illiterate, so I turn it over to you fine folks. What do you think?
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==Your-Password-Here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:end:

Posts

  • AiouaAioua Ora Occidens Ora OptimaRegistered User regular
    There's no maliciousness here as in terms of malware or viruses or opening back doors or anything.

    I want to question it's purpose and efficacy... using random system folder GUIDs is a bit sketch and I can't find any real documentation for this one, so who knows what holes or problems might crop up from using it. There's probably a better way to achieve the goal here than his.

    life's a game that you're bound to lose / like using a hammer to pound in screws
    fuck up once and you break your thumb / if you're happy at all then you're god damn dumb
    that's right we're on a fucked up cruise / God is dead but at least we have booze
    bad things happen, no one knows why / the sun burns out and everyone dies
  • bowenbowen Sup? Registered User regular
    Looks like it exploits something in windows to "lock" a folder.

    There are better ways to accomplish this (a zip file with a password for instance).

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    Wow, bat files are still a thing?

    "Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
  • EchoEcho ski-bap ba-dapModerator, Administrator admin
    Wow, bat files are still a thing?

    I HAVE BEEN SUMMONED

  • AngelHedgieAngelHedgie Registered User regular
    Wow, bat files are still a thing?

    Yes, and they will always be a thing when you have a batch job you want to run consistently and you don't have need for a batch scheduler.

    XBL: Nox Aeternum / PSN: NoxAeternum / NN:NoxAeternum / Steam: noxaeternum
  • evilmrhenryevilmrhenry Registered User regular
    Placing the password into the batch file as plain-text isn't very secure. Anyone who can run the batch file can open it up and read the password, or just copy and run the actual command. While I'm not sure what the batch file does, it's not going to protect against anyone who actually knows what they're doing.

  • AiouaAioua Ora Occidens Ora OptimaRegistered User regular
    Placing the password into the batch file as plain-text isn't very secure. Anyone who can run the batch file can open it up and read the password, or just copy and run the actual command. While I'm not sure what the batch file does, it's not going to protect against anyone who actually knows what they're doing.

    studying it further, the password doesn't even do anything to the files themselves

    the folder is 'locked' by renaming it and marking it as system/hidden to match some defined windows system value, presumedly making it so the windows file explorer won't actually open or see it
    the password just blocks you from using the script to undo that naming and marking

    even if you never looked into the batch script all you'd need to do is run the two commands:
    attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
    ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker


    so yeah this script isn't so much locking a file cabinet as it is taking your files and putting them in the microwave

    life's a game that you're bound to lose / like using a hammer to pound in screws
    fuck up once and you break your thumb / if you're happy at all then you're god damn dumb
    that's right we're on a fucked up cruise / God is dead but at least we have booze
    bad things happen, no one knows why / the sun burns out and everyone dies
  • wanderingwandering Russia state-affiliated media Registered User regular
    Thanks for the input, everyone. I didn't think it was that useful or secure (I'm actually pretty sure you can reveal the files that it hides just by clicking 'show hidden files' in Windows explorer?) But that's not my concern - I just wanted to make sure it wasn't, like, a virus/malware.

  • see317see317 Registered User regular
    I'm guessing that it's not something you wrote, can I ask where you got it?

  • ArbitraryDescriptorArbitraryDescriptor Registered User regular
    see317 wrote: »
    I'm guessing that it's not something you wrote, can I ask where you got it?

    The BAT is at least 11 years old.

    A cursory google suggests that the trick it's using, turning the folder into a link to the control panel, is older still, and I'm curious if it still works.

    (That thread suggests a win7 update)

Sign In or Register to comment.