start	end	text
0	4440	All right. Thank you all for coming to our last talk of the day today. Next up we have
4440	10560	Vitor Ventura who will be speaking about how to hack or snoop at least all telegram messages.
10960	18040	Thank you. Good afternoon, everyone. Just a little bit about me. I've worked in the
18040	24740	industry for quite a while. And I've worked in all sides of the industry. And one thing I have
24740	29160	to say to everybody, at a certain point, you need to see the light and do research. That's
29160	36820	the most fun of it. So moving on to what really matters. Secure IAM. So there are several types
36820	44300	of secure IAM around. I've picked up a couple of examples. Most of them will share some kind
44300	55840	of protocol. So WhatsApp, Signal will use the Whisper protocol. Facebook also uses it on their
55840	62940	off the record chats. Google also uses it on their own private version of chats. Then we have
62940	71900	telegram which is they have their own protocol. Quick question. Is telegram encrypted by default?
71900	80220	Who think it is? Great. Yeah. That's it. It isn't. And then we have also I picked up also
80220	87720	because they are a zero knowledge secure IAM. So you are supposed to be able to set up a session
87720	93040	without having to give away your phone number. So they are really innovative on what they do.
93140	99360	And they are based on an open source library which is the NACL for cryptography.
100760	107760	So let's focus on telegram which is the main talk. So telegram has a base of 200 million users.
107760	116320	It was created by the Vukov brothers after they sold out the Facebook version. They were kind of
117280	121560	well, they sold it. Maybe they were not very happy about it. But they did sell it.
121560	127560	And in the end, they ended up creating telegram. Telegram has a different architecture than the
127560	134320	others. So they although they are not encrypted by default, they do have the keys which are
134320	140300	spread in several countries in such a way that if you want, if some government wants to get the
140300	144020	keys to the crypt data, they will need to go through the legal process on several different
144020	150920	countries. So until now, they have, they are really proud of the fact that never, that has never
150920	156280	happened before. But in the end, we need to keep in mind that they are not end to end encrypted.
156280	165540	Telegram is used a lot in western countries, in Iran, in Russia, in all of the ex-USSR countries
166760	172300	for several reasons. But mainly because it's easy, it's really easy to use.
172600	180340	So one thing that also to talk about is that this is really important. 200 million users does not
180340	187140	mean that you have 200 million security educated users. That's not the point. They are not
187700	193360	security educated. So when we say that this is secure IM and the users should do this,
193360	198160	we need to remember that among this room, a lot of you knew that telegram was not end to end
198160	204440	encrypted by default. But you are subject matter experts. You need to, we need to think that when
204440	210120	these kind of applications are created, they are not created for people like us, they are created
210120	216060	for people in general. And hence they have 200 million users, but these 200 million users are
216060	222980	not security experts. They don't know better. And this is important. So before going to all
222980	227140	the technicalities, I want to talk a little bit about all the censorship that has been around
227140	235900	on telegram. So there have been several attacks on telegram from Russia, from Iran, from a lot
235900	241700	of countries using different techniques. So there have been attacks that they tried to get the
241700	250240	tokens for the registration. There have been attacks where they have even done BGP hijacking.
250240	255840	So I've published a couple of things on that. So Iran back in 2016 did an attack where they
255840	263920	hijacked all the networks from telegram in order to get the messages using the BGP hijacking.
264620	271280	All of this has been happening for a long time. Again, there was also the thing with Russia
271280	277660	and where Google and Amazon stopped doing the domain fronting. There was a lot of attacks on
277660	283280	them. The most recent one is with all that is happening in Hong Kong. There was an attack
283280	289620	on telegram where the Vukov brothers blamed China. I don't know if it's true or not, I don't know
289620	296100	who did it, but this is what's happening. So they have been really targeted by governments to stop
296100	305400	them. So let's go now into the technicalities. First I should do a disclaimer. Everything that
305400	312460	I will show here from this point on was sent to telegram and we didn't get any response from them.
313300	321720	I don't know why. So one of the things that I also want to mention about telegram is that on the
321720	328100	session management you can clone sessions and you don't need to reestablish them. So on my previous
328100	332820	work what I did was I just picked up a token from a desktop session, copied it to another machine
333460	338460	and I could see all the messages going on. So as simple as that. And that is being exploited in
338460	344880	the wild. So this is an important point. This is session cloning. There's nothing, well, it's just
344880	350940	like cloning a session on a browser, but it's something that is going on and it's not, they're
350940	356800	not doing anything about it. By the way, all of them are subject to this. Signal, WhatsApp,
357600	361620	telegram, all of them are subject to this. They have different responses, they have different
361620	367700	ways of dealing with the problem, but all of them are subject to this. So using any of these
367700	374040	applications on your desktop, it's a bad idea. Again, non-identicated users, they don't, they are not
374040	382360	aware of this. And this is important. So what makes the difference between telegram and all of the
382360	392140	other? It's one specific thing. None of the other applications allows multiple sessions from the
392140	400400	same phone number. So if you try to, if you have a WhatsApp installation on your phone and you try
400400	405840	to install another WhatsApp with the same phone number, it will not work. So the session will
405840	410660	bounce from one side to the other and you will never have two sessions active at the same time,
410660	415920	established at the same time. This is the same thing with signal. And this is because of the way
415920	421960	that the signal protocol works. Now, with telegram, it's different. With telegram, you can, in fact,
421960	431180	have two sessions hooked to the same phone number. So this is one of the main things that allow
431180	437360	you to snoop messages. So I will get back to this in a minute. Another thing that I want to say is
437360	443120	that there is a two-factor, a second-factor authentication that when I started to do my
443120	451320	experiments was not enforced on the same device. Later, it was enforced on the same device. There
451320	456040	was a change somewhere in the time on the different versions. However, it's still not
456040	461020	enforced by default. Again, the regular user will start using telegram. It's okay. They use it.
461020	466000	There's nothing bad there. So if you don't have the second-factor authentication, you can literally
466000	471780	read all the message on an Android phone without rooting the device. And this is one of the things
471780	477300	that this kind of option should be explained to the user and the user should have the choice of
477300	481640	opting out or in when they do the first registration. Instead, it's just they're
481640	489040	hidden and you need to go and look for it. So how do you actually snoop the messages?
490720	507830	Let me just take a little water. Okay. So one of the things that telegram does when you try to
508550	515390	register a second session is that it will send you the token using its own channel. So if you
515390	520290	have a telegram installed on your mobile device and you saw a second version, it will try to send
520290	525710	you a token for the second session over its own channel, which is the safest way to do it.
526030	530310	So one of the first things that you should do when you try to do it like this is basically kill the
530310	535350	background process. This is just a dirty way to do it. But if you do it like this, the user won't
535350	541490	see the message arriving with the token and he won't notice that something is going on. Of course,
541490	547470	if you do this in the morning, it will never know anyway. But okay. It's one approach.
548690	555270	So then what you need to do actually is to send a request. So all of these pieces of code,
555270	560670	it's from the actual telegram client that I changed in order to do the demo. So instead of
560670	566250	coding a whole new thing, I just went into the telegram client and just tweaked the code to do
566250	572850	what I wanted. So I'm kind of lazy to code. So basically what I'm doing is that I'm building a
572850	577790	new request for a completely new registration. One of the things that is really important is
577790	584990	this line. So this line says to telegram server that I don't want to receive a phone call to
584990	589570	register. So if I'm trying to build something that will snoop the messages, it will be really
589570	596550	odd for my target if he receives a call at 2 a.m. from telegram saying your code is 2134.
597210	602270	So that doesn't really work. So what I do is, okay, let me put this allow flash call to false
602270	607890	and when the registration request goes to the server, the server knows that it should not call
607890	615430	me. Okay? So this is basically what it does. The other thing which is interesting and if you are
615430	622490	lucky or if you can manipulate the network enough is that if you are on the correct build of
622490	631410	Android, so with SDK 26 or above, it will use something which is called, yeah, create app
631410	637850	specific SMS token. This is a really specific API and a really fun one if you don't know it.
637850	643990	So this pretty much allows any application to receive an SMS code without the read SMS
643990	649190	permission. So this is something that Google did so that when you want to build an application
649190	655590	and you want to have a confirmation by SMS and that's all you want to do with the SMS, you don't
655590	661610	actually need to give the read SMS permission to the application. Of course, this is fun and it's
661810	667850	a security method that was implemented. In this case, it's a little twisted. Because this way,
667850	673450	I can actually get the token without having the permission to read SMS and I can go all the way
673450	679670	through to do the registration without the user noticing. Again, the server will only actually
679670	686270	does this if it cannot deliver the message on their own check. So if you can manipulate the
686270	692850	network enough, it will be easier. If you can't, well, I will show you how we go next. But this is
692850	698990	just, well, this is a best case scenario, let's face it. So what you do is that you build a
698990	704550	request and then you send it to the server. Another thing is that the protocol says that you
704550	711830	need to wait 31 seconds, well, 30 seconds before you can request a resend. So all of this goes
711830	718230	around manipulating the request process from Telegram in order to do it without the client
718230	723870	ever noticing. So we need to wait 30 seconds because that's the amount of time that the
723870	729450	protocol says that you should wait before requesting a new code. So the code is always the
729450	735690	same, but instead of being delivered by the regular Telegram channel, it will be delivered as
735690	743230	an SMS. But you need to request it. So what we want really is to receive the token as an SMS
743230	748110	because if I can receive the token as an SMS, in the worst case scenario, I need to have the read
748110	753490	permission to get the SMS, put the code in and have a new session. In the best case scenario,
753490	760950	I will receive it directly and I don't need to do anything. So after the 31 seconds, what we do
760950	768010	basically, so this is the code that I did just to wait the seconds and then do the request. Again,
768010	772910	you need to do the request. The request is basically this, which is a new packet where
772910	779590	you just create an object called resend code. In this code, you cannot specify things like I don't
779590	785110	want the flash talk. So this is always tied with the initial code. You cannot at this point, for
785110	792050	instance, the application specific SMS token will not work anymore because it's now the service in
792150	798030	a different state where it's saying, okay, I've sent the code, you didn't read it for some reason
798030	802970	and now you asked me for another code. Well, you asked me for the same code again and I'm
802970	809270	delivering the code with an SMS. So the state is it's a little different. So when you send this,
809270	813850	it's the same code, it will go in and you will receive an SMS with that code. Once you have that
813850	819750	code, you have a new established session. As I said before, you can have two sessions on the same
819750	825330	SIM card and you can have clone sessions. So all of this together allow you to basically read all
825330	832070	the messages from Telegram and you can do it, you can put this on an application, whatever you want
832070	838370	and it will go through and no one will ever notice. So you don't need root. At most, you need
838370	845270	the read permission or you don't, depending if you are lucky or not. And that's pretty much it.
845270	852470	It's as simple as that, really. So just to have a little summary, so I created a cycle to kill the
852470	859470	background message so that the user wouldn't see it. Then I do the request, I wait the 30 seconds,
859470	865930	I send the request for the re-send of the code, I have the SMS code, now I can push it to the
865930	875950	server and I will have access. So it's not, it's about abusing the status. One thing you need to
875950	882010	be careful about is that if you do this, if you try this and if you go wrong, you'll start burning
882130	886630	a lot of phone numbers. So because after a while, Telegram will notice that you are playing with
886630	891050	them and they will block your phone number. So be prepared to have a huge bunch of SIM cards
891050	899010	when you're doing some tests because you'll burn a lot of them. So just a summary. You may
899010	903910	want to kill the background, you may need that permission or not, depending on how you do it.
903910	908850	You have another thing which is great, which is the accessibility API from Android. You can
908850	915150	pretty much use that to hide, click, change whatever you want and the user will hardly
915150	920250	notice it. So it's also a very good API to do that kind of stuff. The two-step verification
920250	926350	is not active by default. Again, if it is active by default, you can always use again the accessibility
926350	936410	API to trick the user when he's using its legit Telegram API. Telegram app, just pop up an overlay
936410	943130	and ask for the pin, something like that. It will work. It allows, what you need is something that
943130	948590	allows the multiple sessions on the same phone number. It does allow it. You don't need to do
948590	953050	it on the same device. So you could be creating your session from another device as long as you
953050	961390	can read the SMS. There's no link between the device and the session. That's when I first said
961390	966750	that you can do it on the desktop. That's also true for mobile phones. So you can do all of this
966750	972530	on a separate machine and you just need the piece that receives the SMS on the device so that you
972530	979210	can create the session. That's the only thing you need. Yeah, you may need or not the read SMS
979210	988090	permission and one thing that you don't need is root. So let me see if my video works.
990190	995250	I did some editing so that we didn't have to wait for 30 seconds. It would be too much.
995250	1006460	So let me just see if this works. Yeah. So yeah, this is the application.
1007540	1014040	This is running a little fast. So at this point I did the request. I'm now supposed to wait for the
1014040	1027270	30 seconds. My SMS has arrived. I'm just filling out the code and now I have the session. So what
1027270	1034410	I will do now is that so beta is my malicious one. It was not a great name, but anyway, it works.
1036050	1040650	And now I have the two applications. This is the legit one. This is the better one,
1040650	1044630	the one that I did. And now I have a third phone where I'm contacting and sending SMS.
1044630	1047830	And now you will see that the messages will appear on both applications.
1060340	1064260	So you see that I sent a hi back from this one and it's already here.
1067240	1076860	And finally, I think I said hello again. Of course, this is a crude proof of concept.
1076860	1081940	You can improve it a lot, but it proves what needs to be proved. And now I'm sending another
1081940	1092640	message from my other phone and it will also appear here. Another thing, yeah, as you see,
1092640	1097000	it's on both applications. So I'm receiving all the messages and I can read messages.
1098220	1103560	You see that sometimes it says you're connecting. The reason why it's saying connecting is because,
1103560	1107460	again, I was a little lazy and I didn't stop the cycle that is constantly killing
1107460	1112640	the background process. So it's still trying to kill it and it's still trying to reconnect.
1116360	1124900	So as a quick wrap up, instant messaging has a lot of value. And this is not just about how
1124900	1131340	you can stop the messages, it's about the value. This is just the price of exploits running on
1131340	1135960	instant messaging. As you can see, it's extremely high. Also some information disclosure, but
1136560	1140700	for WeChat, Viber, Signal, Telegram, everything is extremely high. So there's a huge value
1140700	1148140	in this kind of attacks. And the reason is obvious. So as I showed you before, all the
1148140	1155040	censorship attempts, all of that leads to this. The higher value of these kind of vulnerabilities.
1155100	1160460	So as a conclusion, secure instant messages is not just about end-to-end encryption.
1161220	1167520	So Telegram protocol for on-the-wire communication has never been broken.
1167520	1174160	Just like Signal has never been broken. Sorry, the communication on the wire has never been
1174160	1179680	broken. But that's not the only point that you need to secure. The end point is a problem also.
1179780	1183380	And that's where sometimes some of them are lacking security.
1184140	1191120	And well, Telegram is not safe by default. And if you have any questions...
1192900	1204920	All right. Thank you, Vitor. We'll take Q&A up here by me. Can you come up to the mic, please?
1208500	1213480	Hey, great talk, by the way. Some of these sessions include a notification for when the
1213480	1220120	message has been checked. Some of the messages include notifications for when the messages have
1220120	1225320	been read or checked. If you're viewing those directly on the second session, will that
1225780	1231160	be a problem? No, it won't. They won't notice that the message has been read on the other side.
1231160	1232420	Thank you. Okay.
1233980	1236320	Other questions? Come on up to the mic, please.
1243460	1249560	You mentioned that other secure messaging apps also have to contend with the session hijacking.
1250640	1255400	Could you give a brief overview of what they have done that makes them different from Telegram?
1255500	1259740	Or if they are? Sorry, I had a hard time listening. Sorry.
1259740	1267580	What are other messaging apps like Signal doing that can prevent the session hijacking issue
1267580	1277000	with Telegram? Okay. So WhatsApp, for instance, they have some kind of notification that allows
1277000	1286100	the user to know that the session has been hijacked. However, I did in September last year,
1286100	1292140	I did a post about that. And they denied that that is a security feature. So they didn't fix
1292140	1299560	the work around that. So they have a way to notify users. You can bypass it. But because
1299560	1302900	they don't consider it a security feature, they didn't fix it. So they didn't consider
1302900	1310180	the vulnerability. Signal, they actually, there's a race condition, which is really hard to bypass.
1310240	1313920	So they also have the same problem, but they handle it a little bit better.
1313920	1320580	Telegram, yeah, they don't handle that good. So all of the three,
1320580	1324240	Signal is the one that handles it better. But still, it's vulnerable.
1326140	1332060	So I play with Telegram a little bit. And so if I start a secure messaging conversation with you
1332060	1337320	on my phone, that doesn't show up on, say, if I set it up on the desktop, I would have to start a
1337820	1341000	new session. So how does this proof of concept work in that?
1341000	1348380	So that's about when you start secure sessions, secure chats, they will be end-to-end on the
1348380	1354320	device. So that doesn't cross here. These are the regular ones. However, the interesting fact is
1354320	1359300	that if I create a secure session with my new session, the user will never know. So I can
1359300	1366060	impersonate you all the way, and my victim will never know that I'm talking with your target and
1366060	1372220	the other way around. So you can impersonate anyone that you want, and they will never know.
1372220	1376280	They don't have a way to know because there is absolutely no information going back to them.
1378060	1379680	Other questions?
1382040	1384680	So always use secure chats.
1385000	1394110	Does this show up in the Telegram session manager?
1395180	1399040	So if you go to your settings, you can see all active sessions.
1399040	1402800	Yeah, it will show there, but it will show there has a session from the same device.
1402880	1408060	So, again, for a regular user, that's not something that you'd consider weird because
1408060	1411100	it's on the same device. It's just another copy of itself.
1411140	1414480	So it would show up as a duplicate on the same device.
1414480	1415480	Yeah, exactly.
1415480	1415880	Interesting.
1419680	1423720	You covered the three, but you didn't mention Threema. Have you done much experimentation
1423720	1425920	or compared those to, say, Signal?
1425920	1431960	So I have Threema there because they are a zero-knowledge secure IM, and that's a really
1431960	1436800	good fact. I did look into their protocol, but I didn't do any testing. But Threema has the
1436800	1441400	advantage, the good side is that you don't need a phone number to initiate any session.
1441580	1446240	So it's a zero-knowledge, absolutely zero-knowledge, not like any of these.
1446300	1449580	And, well, that can be better from the privacy point of view.
1449840	1452120	But I haven't tested the protocol, definitely.
1453740	1457380	We still have a little more time if you have any further questions.
1460120	1463540	All right, one last... oh, one more. He came up.
1466020	1467660	GeigerWy is in the back of my head.
1468780	1474440	Thanks for the talk. What are some more secure options other than Threema?
1476440	1477720	Well, let's...
1478880	1485480	So even Telegram, if you use it with the right settings, it will be more secure,
1485480	1487700	just like Signal or any of the others.
1487700	1491040	So one of the things I would say is don't use desktop apps.
1491220	1494080	You have your phone, use the ones that you have on your phone.
1494080	1496340	Don't root your phone, don't jailbreak your phone.
1496580	1500480	When you're using Telegram, use the secure chats.
1500520	1501500	Those are end-to-end.
1501500	1505140	You won't be able to see them on the web browser, but you have your phone, right?
1505200	1507700	Use the two-factor authentication all the time.
1508540	1511160	Disable and re-enable sessions whenever you need.
1511780	1514280	All of those features will keep you more safe.
1514280	1516120	They will give you more trouble to use.
1516120	1520260	But that's always the trade-off between privacy and usability.
1521420	1525780	Because as I said, none of these have been broken on the wire.
1525820	1529920	So as long as your device is safe, you should be okay.
1529920	1534520	But an Android device, if you install software that comes from the wrong side of the table,
1534520	1536940	or unsafe software, well, you know what it is.
1536940	1537760	It's Android.
1538680	1538980	All right.
1538980	1540460	We have time for one more question.
1542220	1544640	What about the safety of the web app?
1544640	1547820	Not just using it on your phone, like through the browser,
1547820	1549980	or using it on the browser on your computer.
1549980	1550320	Is that...
1550320	1551680	Don't use the web app.
1553800	1555120	That one is simple.
1556220	1556860	All right.
1556860	1557840	Thank you, Vitor.
1557840	1558120	Okay.
1558120	1559040	Thank you, everyone.
1559920	1560720	Thank you.
