our next speaker, they say you can't cheat time, but he can find foes in yourself with latency tri-territorialization. Our next speaker, let's give her a round of applause. Thank you. Hello, Maze. Thank you for being here and joining me in this talk. My first talk I said about geolocation. You can cheat time is a quote from Dr. Roo, as you can see from the TARDIS next to it. And I'm Lorenzo. Call me Lopoc if you want. And you can find me on Twitter. You can find my code, the code I'm releasing today on my GitHub. And let's talk about geolocation. Geolocation is something that has always been a important for humans and has always been a power driver for progress and technical things like sextant, mechanical clocks, or GPS, too. So very important. And even in our realm, so the cyber realm and Internet is important, too. Now we face some limitation. Almost anyone knows large IP-based geolocation services. I don't want to to name all of them but you can just type some ips and find with a certain precision where they are due to the massive use of cloud provider and cdn so we can no longer use them because you just have one anycast one or more anycast ips and you do not know where they are you maybe find the location of the company that run that subnet nothing more so this is what has driven my work so looking through the cloud cartrain so um so answer the geolocation question in the cloud provider world some theory before we start it's a mathematic and physics don't be scared it's very simple uh this is a this is a simple one distance is a speed per time this is a first time this is a first time this is a first time this is a first time this is a first time order estimation of distance starting from a time so it's something very easy and have to run so keep in mind but it's it's important it's it's very easy another thing is to keep in mind it's obvious but keep in mind the nothing can move faster than speed of light we even if we are hackers we are computer scientists we are antisocial we cannot break this law this is a law of this universe maybe in another one it's another speed but we have to remember that nothing can travel faster than the speed of light even information even things on the internet and some terminology now latencies versus speed we sometimes confuse them maybe the person that knows bad best what is the difference are video gamer because the latency is actually the lag so it's a time measure and it's in a millisecond or more but it's a time measure whereas speed is an amount of data or an amount of whatever over a given amount of time so keep in mind this and remember the speed of light limit latency cannot be arbitrarily low because it's the time information takes from a point to go to another one so you cannot you you cannot make information travel from sydney to san diego in two milliseconds it's impossible this universe doesn't want so obey the rules not relateration it's a well-known and well-known method for estimating at a known position starting from known points so it's it's well it's commonly used for gps for tracking smartphone okay it's not very good use but it's used for or a rogue radio station stations and so on so it's a very well-known methods and we need for this recipe some points fixed points from where we perform our measures and we have to know their exact point exact position so tower radio towers or so on we will discuss what we will use in our for our problem then distances so a method for estimating distances between the unknown target and these points and then obviously the target that is what we are looking for so this is the simple recipe for to the iteration then we have another important powerful tool that is a mathematical tool that is a minimizer and we will use it for providing data we have collected and inferred like points distances and it will some of the best points the target could be so this is something that i will not give into diving to minimizer but you can uh to iteration has been used for tracking people even by uh by dating apps uh it's not actually a knack because uh sharing distances in many dating app is something that is up to the user but has been exploited for tracking people so the system is the same fixed points so where you have your measure points so your client and the target the unknown target and then do some translation well let's do some practice now this is a ping uh almost anyone here have used ping uh at least one time in his life and it's the first approach to latency ping it's the first time measure from a client and a server and it give a give us as output many parameters like the average time and so on and by using it's a very naive measure but by using it we can infer some important information for instance in this example we have the minimum round trip about 55 milliseconds and we can see that the speed of light is at the same level as the speed of light so if we combine it with the upper bound of speed in this universe so the speed of light we can assure we can literally sign with our blood that the target cannot be farther than 8.3 hundred kilometers thousand kilometers so this is a very important things but um okay surprise surprise it's useless it's useless because because two things um services behind clouds are not ip services and so you cannot use icmp protocol for reaching them you we you will only reach the ingress point of the cdn so it's useless and will be the nearest to you second things it's internet it's not linear like speed per time speed per time is a linear function so it's almost useless internet is a large amount of nodes interconnected in every way is possible and governed governed by wave protocol like bgp i love bgp but it's another story and so it's not linear at all ah and all of this is projected over a spherical body in the universe so it's not linear at all we need to find a better model for estimating a distance starting from a latency i've used machine learning so anyone use a machine learning today but i used it for estimating starting from a latency the actual distance more or less machine learning requires many data many data i collected around 40 kilo measure couple of measures source destination each one target with a country code source country code actually um and trained over the distance inferred via computed via other scene functions so the shortest starch between source and destination so we have as features uh country code and we use it has a bag of words for who knows what machine learning data science things works and then latency times and as output the real uh distance i used an svr a support direction model is very simple to use and i will run on this because we are running out of time now recall the recipe we need points the best way to have many points around the world is used is using a cloud provider choose your favorite one and deploy some lines of codes on each of them we are talking about uh cloud front of the services like command and control control so we cannot use ICMP anymore but we have to measure latency on application layers. So I use HTTP, so I use CURL for HTTP and HTTPS protocol. We have to deploy these lines of code on each point we choose. We have to compute latency. It's a simple substraction and it's and read manual of CURL is perfectly explained. And then we have to compute the distance using our machine learning model and at this, yes, and at this point we have two arrays. A point of arrays that are data centers and their coordinates that you have found by OSINT or Googling them or whatever. And distance inferred via machine learning model. And the unknown point we are looking for. Now we have to do the magic with some math and we have to minimize all these things. I will go fast on these two but it's minimizing process over the residual between the hypothetical position and the distance we have collected, we have inferred before with the machine learning model. And I don't know if it's clear. So we have to do the math. Is it clear? Yes. And you will have many outputs. I will use a small set just for make it better to be understood. And this is a cloud of possible points with a centroid on the west of UK. And the server was actually in London. So it works. The yellow, the yellow circle is the upper bound of the speed of light radius. So we know that the point cannot be outside that circle. So it's very good for just latency based method of inferring a position. But let's do something cyber. The main problem, the main things I was working on is command and control behind cloud front. At the moment, anyone who works on threat Intel, they don't have the command and control in case they have fronted command and control or a malicious site for the living malware, raises their hands and say, oh, we cannot do nothing. We cannot say nothing on which part of the world the service is or isn't. Unless you call the cloud provider. But good luck if you have tried. I don't know. Let me know. But surprise, now, and I don't know if it's until now was impossible. I arrived to a good result in this method. And this is not precise at all. I could have put an example that was more precise. But I wanted to say that it's not very precise. It's not a kilometer precision method. Here we have a real service behind the cloud front located in a room. And using only latency measures and no more than a dozen point of measures, we have this fancy heat map and an error of 600 kilometers. That in Europe is a lot. But imagine the rest of the world. I think it's a good result. Please appreciate it. Something more that we can use this method for is sandbox detection. Sandbox detection is a method that we can use for a lot of things. It's many times as a fake net behind. So a system that mimics the real behavior of a network of the internet. But it's very difficult to cheat time or mimic the behavior of latency versus some points. So we have just we can embed our model inside the malware and a number of fixed points inside it. Embedded in it with a target country and what I've said before. And in presence of fake net, latencies will be only a few milliseconds. So the result will be something that graphically is a non-overlapping circle. So it's an impossible mathematically solution. It's impossible. It's impossible. There's no point that minimizes the function that we've seen before. . We can even add some random latency in fake net. But I don't know if someone will work for it. We could try. But I don't think it will work better. It will work better than a real network. And the other thing, similar to the sandbox detection, is a malware self geolocation. And you can ship a malware with inside this model some fixed points and some other things. So it's a very automatic process for determining which area of the world is running and then turning on or turning off some features or the malware itself. So I think it's nice things to do. Is it at the moment perfect? No. Is it bulletproof? Absolutely not. But promising. I'm very clear. I don't want a wow effect. It's an early stage research. So I'm very, very frank. Then I have a demo. And here it is. Is it in full screen? No? Okay. Sorry. Okay. This is the notebook, Jupyter notebook that you will find on my GitHub. It's POC for this. And I ship it with my pre-trained model. But I will have to retrain it again. It starts with measures. That is a long process. And then it starts estimating an offset. That is important because of the inner latency of the computation due to the computational time of the server we are reaching. So we first determine an offset for the network. And then we start estimating an offset for the network. For all the latency measures, we subtract them to the measured latencies. And then we have to estimate distance with our machine learning model. And these are the distances. This is the main process. Trilateration is done with a method that we can discuss of the records for avoiding some outlier and so on. And then we already have the heat map now, but it's not plotted. We find a cluster, the largest cluster of these points. And we compute even an estimation of the error. And then the plotting time. And here it is. No popping calc like my exploit friends, but it's nice. Wait. Okay. So this is the one of the example in the slides. So it's an actual one. And thank you for this. Then I'm done with two minutes earlier. So if some of you want to make some questions. How long does the HTML model stay accurate with unique graphs changing the method? Okay. BGP is a big mystery for me and for almost anyone. But I came across the fact that the BGP is more stable than what we're used to. And the machine learning, due to the fact that it's a large amount, not an enormous amount of data, but it's a large amount of data collected, it responds very well. Even during a few months or a few weeks. So maybe combining it with a looking glass, BGP status and so on would be even better. But I assure you that it's more stable than I expected. Oh, sorry. I cannot. Okay. Artificial latency. Yes, you can introduce in your services or an artificial latency. But it would be useful. But if you collect a large amount of measures, not just one, you will find the main value. So you will have a distribution like a Gaussian one with a random latency, artificially introduced. In any service or so on. And then you can use all the smallest one or the main value. And you can use the system in the same way. Just with a slightly modified check preconditioning of the data. Oh. . . . . . . . . . . . . . . . . . . . . . . . Thank you.