hobune Channels Contact About Donate

Reversing WannaCry Part 3 - The encryption component

Back to video page | Download comments jsonl

Comments (archived 2022-07-05 01:58; 68 top, 109 total comments)

Johnny Utah 2020-07-24 18:32:21

Good to know WannaCry cleans up its temporary files. There's nothing worse than ransomware that doesn't clean up after itself!

74 likes
David Bradbury 2020-04-11 17:09:51

As mostly a regular guy, with a bit of programming knowledge... I don’t know why, but I had assumed that the core of the malware would be far less refined than it is. There are checks for things I wouldn’t have considered. It’s like they wanted to make sure they didn’t actually hurt your data... you know... as long as you paid them, I mean.

190 likes
Replies (5)
billigerfusel 2020-04-12 08:08:08

You can't display the ransom messages on a machine that doesn't boot anymore.

64 likes
Kudret Spyrou 2020-04-13 16:22:13

Well, there are rumors that this ransomware was brought by the North Korea, so i guess if it is true, they would want to get some money and "terrorize the western civillization", but they would not want to get a warhead launched to their territory....

3 likes
Jedzia Dex 2020-04-16 12:23:15

@Kudret Spyrou No, I'm sure you're behind it!
Of course, I only say that, so that you notice how damn stupid accusations are without evidence. Of course I have nothing against stupid chatter / a good joke. Keep going.
Well it is a business. A fishy business, but it is a business. So they likely have a quality assurance department.
But there is nothing special or any knowledge that otherwise should be good practice in the industry. That a budget gets cut and the code quality suffers from it is an old hat.
The only thing you can learn from malware authors is that you later have a lot of time in prison to deepen your research. In my opinion, the artistic or interesting examples come from game programmers, anti-piracy measures or the elegant solution of mathematical problems on limited hardware.

8 likes
Jack L 2020-12-01 18:40:25

This series was very interesting, again i myself don't have a lot of programming knowledge, but i understand the systematic sequence of events which is interesting none the less. I have the feeling though that a 4th video would be greatly welcomed where he could go into the "unlocking" mechanics, and how the ransomware verified that you paid the bitcoin "ransom" and if there is a way to spoof it. Also, again correct me if im wrong, but was it said that one of the 2 128bit encryption keys is in the header of every encrypted file? I would like to see more details of how the decryption process worked after a verified payment. Honestly i was hoping he would go into that in this video.

14 likes
Just Kidding 2021-08-10 05:46:22

@JustWasted3HoursHere Yep! because media tells me, means its true

0 likes
abnorm - True Crime 2021-03-08 13:22:14

I can barely make a basic calculator in Python, but for some reason I watched this whole C++ RE video lol. I always found Malware fascinating, and seeing this being taken apart is really cool. Thank you!

4 likes
H 2020-04-11 23:07:58

Great to know even WannaCry is multi threaded

140 likes
The PC Security Channel 2020-04-12 06:29:01

Great to see more RE content on YouTube. Keep it up.

84 likes
Replies (1)
GigantTech Gaming 2021-06-25 13:08:13

Oh hi

0 likes
Filippos Constantinou 2020-04-19 16:11:35

Great vid, I wondering with which program do you make the orchards and the step by step graphs of the malware? I could use something similar for my cases too. Also you are one of the few people which I have seen to cleanly organise the decompiled code than just slapping post it notes next to it, kudos for that.

0 likes
xtdycxtfuv 2020-04-12 14:13:24

you are an inspiration dude. I've always wanted to try software reverse engineering

5 likes
Konstantin Rebrov 2020-04-18 16:24:17

Can you make a video as a guide to Ghidra IDE? A comprehensive tour of overview of all it's features and how to use them on a code sample. Ghidra has a lot of buttons, bells, and whistles, and I don't know what any of them do. So a tutorial about finding your way around the IDE would be great.

14 likes
cubedable 2020-04-12 08:38:41

So the reason for including the embedded RSA key is to facilitate the partial decryption while allowing them to use the same encryption method, just by switching the key? Because it looks to me that using it to just obfuscate a bunch of wannacry files (as seen in 1 of previous parts) is a bit of an overkill.

7 likes
Replies (1)
FracturedPixels 2021-02-03 08:19:21

It could literally just be to obfuscate a bunch of wannacry files. Perhaps they considered those files in particular to be the weak point of the program, and put extra care into encrypting them; just to avoid the chances of it being possible to correctly guess the obfuscation method.

0 likes
Black Hermit 2020-12-11 16:58:16

Finally made it to the end, after so many months. Thanks a lot for this series!

0 likes
epicguy492 2022-03-27 17:49:20

would you ever do a part 4 looking at the decryptor and mainly how the C2 protocol works? I've never seen anyone talk about it, only the worm and the encryptor mainly.

0 likes
Yannick D'Hondt 2021-03-05 20:14:10

Quality content, thank you.

0 likes
Silica 🏳️‍⚧️ 2020-04-18 01:41:17

What does it do if the rand() doesnt execute >10 times? Either by not enough files or just by chance?

It also doesn't seem to count to 10. So maybe more than 10 are acturally decryptable ^^

0 likes
Твой Котейка 2020-04-12 10:18:12

That was great. In the final part, you need to write a program that decrypts files :DDD

52 likes
Replies (4)
Surya Teja K 2020-04-20 08:56:12

yes please do write a program to decrypt wannacry encrypted files!!

3 likes
RandomHumanBeing 2020-05-07 16:40:12

@Surya Teja K wannacry uses aes and rsa to encrypt the files i dont think you will have any hope getting them back

6 likes
H3xad3cimal Dev 2020-12-18 17:54:45

It's most likely not possible unless you read the memory and find the key and used their same algorithm

4 likes
H3xad3cimal Dev 2020-12-30 14:02:14

@:K oh nice! What's it called?

0 likes
Euroliite 2020-04-11 21:54:24

When decrypting the 10 files, how does it differentiate between the embedded key encryption and the regular encryption. I assume it looks at headers. How would it find those 10 files out of all files? Does it do a search of all drives for those files?

7 likes
Replies (1)
Michael Gillespie 2020-04-12 15:40:09 (edited 2020-05-01 13:18:53 )

They can do that a few ways. They can simply keep a list around of those files, mark it in the header, or, RSA also has the property where the padding check will fail when decrypted with the wrong key - so you can just blindly try your private key, and if it fails, you have a way of knowing and aborting. I haven't RE'd this ransomware, but just assuming what could be done based on how many other ransomware do it.

2 likes
XxXMetalHead18xXx 2021-03-29 02:37:40

Make part 4 please, I've been waiting!

1 like
Noah Rotroff 2020-04-13 20:54:41

If you set up a Patreon to help subsidize the time spent creating these videos, I would definitely subscribe.

8 likes
Redpill Commando 2020-04-11 20:53:25

Thank you for posting this. I had all but given up hope.

2 likes
h0x91B 2020-05-05 22:37:01

Why you are not using ENUMs for all of those `filetypes` code becomes much more readable..?

1 like
Cohzi 2021-11-07 11:18:31

How much time do I need to be in this knowledge level

1 like
Pan Duszek 2020-05-01 00:40:27

Awesome video, respect!! How about RE of Petya/MEMZ/CEREBO?

12 likes
traida111 2021-05-15 12:22:50

so where did the key come from and also what were the .onion websites used for?

0 likes
Rocco Ranallo 2021-08-17 03:02:39

Dude you are good, I am trying to get as good as you.

0 likes
Fly Me To The Moon 2021-01-20 12:39:18

i really love this video how you reverse this thing btw can you reverse bonzi buddy too?

0 likes
Keith Douglas 2021-02-24 15:42:17

On the set array to all zero that Ghidra doesn't understand: maybe - function inlining?

0 likes
manstie 2020-05-14 04:59:26 (edited 2020-05-14 04:59:46 )

Would you be able to do something like reverse engineer and patch the Decryptor .exe and make it so that the decrypt button decrypts everything? (without a payment)

0 likes
John Blake 2021-01-02 23:19:52

8:40 , can't we use this knowledge in order to put some very important files inside these folders to protect them against ransomware?

0 likes
Replies (2)
Ivan Heinzer 2021-01-05 13:40:55

If all ransomeware work the same 😅🤷‍♂️
But I think it would not be a bad approch because the system needs files to run. If you place them between those the ransomeware first needs a logic to decide which are essential and which aren't

1 like
John Blake 2021-01-05 18:46:12

​@Ivan Heinzer I thought more about it, and I think it would be a nice idea to make your device give off "Virtual Machine" vibes while it's actually not, so malwares get spooked and stop running. (I actually don't know how you can fake being a virtual machine though)

0 likes
T-GVNG 2021-01-25 15:39:38

Could you reverse the musallat.exe virus for the next serie?

0 likes
Redpill Commando 2020-04-11 20:52:17

Does anyone know where I can find the wannacry binary. I would like to play along at home. Yes I know this is really bad software but I have an air gaped computer with virtualbox installed on it for just this kind of experimentation.

3 likes
Replies (3)
stacksmashing 2020-04-11 20:57:53

It’s linked in the description of part 1!

3 likes
Redpill Commando 2020-04-11 21:00:00

@stacksmashing Oops, sorry, I already found it on my own. Thank you for the quick response and thank you for the video.

3 likes
stacksmashing 2020-04-11 21:00:26

No worries, glad you like it!

3 likes
Fideria Jeseline 2020-12-16 19:00:27

can you disassemble the ex4_to_mq4 decompiler :)

0 likes
ywanHK 2020-04-11 18:10:28

OMG i am waiting for this for sooooooooooooo long !!!!

6 likes
HyDejel 2020-04-11 16:47:52

Great Video! :D

3 likes
Colin Liew 2020-06-20 02:38:10 (edited 2020-06-20 02:38:30 )

part4!!!! I want to see a key decrypt generator

0 likes
ManMartin 2021-04-09 22:20:57

So, is It possible to write a code to unencript all the files?

0 likes
Gabriel Accerboni 2020-05-07 20:13:33

Legend has it that some executables can detect that you are decompiling them and at the same time run some defensive script or destruction command. Would you have an example of this? How can we avoid the first trap?

1 like
Replies (4)
stacksmashing 2020-05-09 16:29:30

Detecting decompiling is as such not possible, as the binary is never executed. The only way this would work is if the executable contained an exploit for whatever tool you are loading it in.

6 likes
Gabriel Accerboni 2020-05-09 18:56:48

233/5000
Thanks for your answer, just two last questions... If someone is logically monitoring us (Rat), they will use a port that we could realize by monitoring the established connections. Is it possible that the attacker could hide that? Same question for a Man in the middle attack.

0 likes
Solomon Ucko 2020-09-01 21:43:58

FWIW, there is sometimes anti-debugging code, since the debuggers need to actually run the code.

1 like
Gabriel Accerboni 2020-09-02 22:45:53

Yes, I found some information in the book of the Cat (Tamper proof). This led me to read about kernels, compilers, malware analysis. I finally ended up in computer forensics but there isn't much on this. In my country it is a concept born only two years ago. I don't know anyone in the business, I must be one of the few. Thanks for sharing these videos. They are my best school.

0 likes
God Fire 2021-04-10 21:05:17

How to reverse WannaCry:make CTRL+I !

0 likes
Chidi Obum 2020-04-11 17:02:04

Nice one!

2 likes
Bill.Zhanxg 2021-05-17 12:27:22

Reverse engineering is so hard lol

0 likes
AdamBast 2021-01-31 10:36:35

:( i was hoping that this was going somewhere... what happens if the countdown expires? Is there a way to decrypt without paying? Who do the bitcoin addresses belong to?

0 likes
Neha Tariq 2020-04-12 07:28:51 (edited 2020-04-12 07:28:58 )

place this into playlists as well

8 likes
Replies (1)
stacksmashing 2020-04-12 10:31:19

Completely forgot, thanks!

1 like
Leo Zendo 2020-04-16 17:38:08

Wow just wow.. I'm sure you won't need to pay for any game/software if you decide to spend some time.

0 likes
Gameplayer 55055 2021-01-07 09:46:27

Why decompiled c++ is so dirty?
Especially std::string
I decompiled my own simple program and i can't understand c++ types here.
But C is fine for decompiling, everything is understandable

2 likes
Replies (8)
مقاطع مترجمة 2021-01-09 05:01:23

OOP

0 likes
Gameplayer 55055 2021-01-09 08:42:43

@مقاطع مترجمة
Yes, i also thought it was OOP
But can we decompile it?
We can directly decompile exe file with c# code, cant we do this with c++?

0 likes
مقاطع مترجمة 2021-01-09 12:30:46

@Gameplayer 55055 I think that because .net IS can be decompiled easy to it original functions structure type (there is tools specified to do that), but C++ I don't know maybe it's uses different approach for compile it to machine code make it relies less on the OS, C are much simpler language since it's very close to assembly in many ways, you maybe able to create complex code with C to make it harder to Decompile/read .

1 like
Gameplayer 55055 2021-01-09 12:59:47

Yes, You're right.
but after watching decompiled c++ code i want to write on pure c :)

1 like
مقاطع مترجمة 2021-01-09 13:10:30

@Gameplayer 55055 Lol same, but After I watch how they decompile C# codes, OG

0 likes
Tellow Krinkle 2021-02-08 02:27:53 (edited 2021-02-08 02:33:39 )

It's not the OOP. If it was the OOP, OOAnalyzer would clean it up and make everything nice

The reason things like std::string are dirty, are because they're inlinable. This means that when the compiler is compiling code, it's allowed to copy and paste the contents of std::string's functions directly into your code (which allows more optimizations in some cases, though also leads to more mess). Which means instead of one call to std::string::append(myString, otherString), you now get all the functions std::string::append called pasted straight into your code.

If std::string used OOP, it would be much nicer looking as the compiler would be unable to figure out what std::string::append did, and be unable to copy and paste it into code everywhere

If you're trying to match up the decompiled code to source code, try going into the <string> header, and matching up the decompiled code with the contents of the std::string function you called. You'll probably find that they match very nicely. If you're compiling with clang, add the command `-Xclang -fdump-record-layouts` to your compiler invocation and it'll print the binary layout of classes like std::string for you to copy into Ghidra structure definitions. I do wish there was an automated way to do this though, some clang-ghidra integration plugin where you could write c++ structs in a header and then import them into Ghidra.

2 likes
Gameplayer 55055 2021-02-08 06:07:41

@Tellow Krinkle thanks for complete answer.

I already noticed that std::string functions are copied everywhere.

1 like
Gameplayer 55055 2021-02-08 06:08:20

@Tellow Krinkle thanks for complete answer.

I have already noticed that std::string functions are copied everywhere.

1 like
Irvin Romo 2020-05-05 04:03:26

The only thing that makes me wanna cry is the light theme

40 likes
Matheus Catarino 2020-04-12 14:04:57

It would be interesting if you allow subtitles (human) for better understanding.

2 likes
Replies (3)
stacksmashing 2020-04-12 14:23:48

Yea unfortunately that’s a lot of work - have to look into it

1 like
Matheus Catarino 2020-04-12 14:43:48

@stacksmashing, If you can release the option to add subtitles, if any subscribers are interested in doing so would be very helpful.

1 like
stacksmashing 2020-04-12 14:44:10

Ah i didn’t even know that’s possible! :) let me check that

2 likes
정제훈 2020-04-11 16:54:42

Finally video! Thanks

2 likes
Jake Mai 2020-04-14 12:31:48

Can you please do a series on NotPetya please? :D :D

1 like
mini Crazy 2020-04-16 19:35:13

is Wannacry still available?

0 likes
Emi Del 2020-04-13 15:04:39

Thanks!

1 like
Chris 2020-04-11 18:57:41

so you actually can decrypt your files, if you paid them and this 10 file demo isn't some baiting tactic, to make you pay?

11 likes
Replies (5)
Макс Ф. 2020-04-11 19:26:38

Just someone who loves what he doing.

2 likes
Alex Kart 2020-04-12 03:46:58

Yeah. Years ago, one businessman ask me to convert couple of bucks to BTC. He paid to terrorist, and get all files back.

1 like
Kevin Wydler 2020-04-14 18:21:42

No, it's just a bait (as far as I understand it). These 10 files (possibly more) are encrypted with a known private key, so you can decrypt them. But for all other files, the seed is random and there is no functionality to keep track of these random seeds.

Please correct me if I misunderstood this though!

5 likes
GhostOfYoda 2020-05-15 01:34:10

@Kevin Wydler From my understanding of the previous video, the main encryption key pair is generated uniquely to each machine the first time it runs, and the private key (required to decrypt) is then encrypted with a fixed (public) key embedded by the ransomer. Theoretically, the ransomer could take the encrypted private key, decrypt it with their own key, and supply it back to the victim, thus allowing for the decryption of the files.

1 like
GhostOfYoda 2020-05-15 01:37:26

Interestingly (again, to my understanding and I’d love to be corrected with precise details!) a bug/exploit in windows’ implementation of the encryption meant that if you didn’t restart your computer after this was done, there was a chance that the (unencrypted) private key was still somewhere in memory, and thus with the right tools, in some cases it was possible to recover this and hence reverse the effects of the malicious encryption without paying the ransomer.

5 likes
xxMrPHDxx 2020-04-11 16:30:46

Finally!!!!

7 likes
Hoppy 2020-06-13 19:35:24

Part 4 ?

1 like
Saeed Mahmoodi 2021-01-05 22:24:40

where is private key?

1 like
GodAtum 2021-04-10 18:02:23

so you you hack the hacker and decrypt without paying?

0 likes
daniweb90 2020-05-07 18:59:48

Now, does it mean it is possible to decrypt after you've paid the money or does it mean it isn't?

0 likes
𝙳𝚊𝚠𝚗 '𝚗' 𝙳𝚞𝚜𝚔 2020-04-16 05:45:46 (edited 2020-04-16 05:47:05 )

Dude, I have a question
I have a Set top box and to get into it.
Currently the channels limited in it is managed at the box. I want to edit it.
Other channel which i have not paid for should be accessible, when I move over the channels, a small piece of the programm just flashes

0 likes
Слава Україні! 2020-04-12 22:57:47

It's great WannaCry won't encrypt my Minecraft folder

2 likes
lilmayu 2020-04-12 10:58:40

finally!

5 likes
Unbalanced Binary Tree 2020-04-28 15:05:50

You are my Netflix

4 likes
ScienceAndMatter 2021-01-28 15:01:25

Hallo Thomas. Did i read it right?
Grüße aus stuttgart

0 likes
John Hammer 2021-11-09 10:30:13

fasicnating

0 likes
Mete Kaan Aktay 2020-04-11 17:53:09

thx

2 likes
XxXMetalHead18xXx 2021-05-13 09:34:12

When is the next viedooooooooo

0 likes
slendi 2020-04-11 21:36:34

Hell ye

1 like
Tismoineau 2020-10-26 17:24:56

my ghidra is dead because a virus disable my jdk and orale servers is actually down. someone can send me the source code ? T_T

1 like
project21124 2020-04-11 22:59:59

the change in your voice from 10:25 -> 10:26 is incredibly unnerving

5 likes
Replies (2)
stacksmashing 2020-04-12 12:50:30

Yea it was recorded on the next day, had some issues with a cold and had to stop - sorry about that :)

1 like
project21124 2020-04-12 18:28:50

@stacksmashing oh no worries, I figured it was something like that. Great content as always!

1 like
KoryBagel 2020-04-11 17:27:38

yes

2 likes
Laggy boT 2020-04-13 14:24:55

where is the etranalblue code ???? i came for etarnalblue

1 like
Replies (1)
stacksmashing 2020-04-13 14:27:42

I’m sure asking this nicely will help :)

5 likes
Ultra01 2020-04-11 17:44:07 (edited 2020-04-11 17:45:58 )

601th view

1 like