Well, hello everybody. My name is Manuel Rabade and I am going to present a small pocket of bits that can save or destabilize a city. Thank you very much for coming in. I'm very happy to present this. So what we are going to see, we are going to talk about the systems that send alerts before danger using wireless methods. So we are going to explore how they work, their limitations, and why everybody can generate these signals. This talk is not only technical, it's also about my journey into this kind of project and what I consider to be the core of hacking. The curiosity to understand how things work, explore their boundaries, and share that information. So what we are going to talk about first, we are going to talk about the Mexican seismic alert system. Radio frequency plays a key role here, not only for sending the alerts, but for the core of the system. It's something like pretty interesting. We are going to talk then about the EAS same system. This is the system that works here in the US to transmit alerts. We are going to see how it works, how the messages are sent, how they are encoded. Then I'm going to show you how you can receive, how can you decode, and how can you generate these signals, these alert messages. And then we will wrap up with some final thoughts about the performance of these systems. First of all, a little bit about me. I started learning computers and electronics in the 90s. I was very heavily involved in the post-community in the 2000s. At the same time I studied computer engineering at the Autonomous National University of Mexico. I have been working 20 years in software engineering, in marketing, start-ups, government, fintech, doing software, hardware, infrastructure, you name it. Recently I have been collaborating with RF Villaje Mexico. It's a new project we have in Mexico City, but also in other cities of Mexico that we are doing on the security events like these ones, or smaller ones. We are doing something like CTF, talks, and well. What I am telling you this because, well, I just want to mention I am not an expert on seismic science, on alert messages, and all that stuff. I am just an enthusiast like many of you that, well, I have found this subject to be very interesting and I have learned and now I am sharing about it. So this story begins in 1985. We had like a very big earthquake in Mexico City. At that time there were 10 million people in Mexico City. And, well, there were about 40,000 casualties. So this was big, like about 400 buildings collapsed, 100,000 homes were affected. So yeah, this mark, like from my generation to older ones, like everybody talks about the 1985 earthquake. So, as you can see, well, for me personally in this picture, you see there used to be like three buildings there. My grandparents used to live in the one that's still standing. So yeah, it was pretty scary. Their home was not demolished, but it was demolished later because the building was not any more usable. So earthquakes are a big thing in Mexico City. So why is Mexico City so affected by earthquakes? There are two reasons. The first reason is the city is built in a lake bed. You see the picture, well, the painting on the left is a painting of what it used to be in Mexico City at the time when the Spanish reached. So on the right of that, it's a picture of almost the same perspective. You see there is no lake anymore. So the problem with this is that the soil amplifies the earthquake. The earthquake is very soft. So that's the first reason why Mexico City is very heavy affected by earthquakes. And the second reason is on the right, you see that Mexico is between the tectonic plate of North America and the Cocos Plate. So the Cocos Plate is pushing the North American plate and it generates in that sector, you see the many points, it generates a lot of seismic activity that becomes earthquakes. So that's the two reasons like Mexico and Mexico City, it's very prone to have big earthquakes. Yeah, like, we have like, each year we have between 10 and 20 earthquakes. Small ones and medium ones. Well, not small. Medium and strong. And each year we have between one and three strong ones. And one time each, in 10 years, we have a very strong one. Like the 1985 one. So the last big one was in 2017. Some buildings collapsed. It was not as hard as 1985. But yeah, we have casualties. And well, it was hard. So after 1985, what happened? Some scientists, engineers, came. I don't know the details of the story, but I imagine that some scientists come to the government and say, OK, we have a very big earthquake, so we have some very cool science like we want to talk to you about. So the earthquake was, 1985, was originated in, you see the little star there. So it was generated 390 kilometers away from Mexico City. And Mexico City is, you can see like the yellow spot and orange in the middle of the country. So the earthquake is 390 kilometers away, but seismic waves travel at about 4.5 kilometers per second. So when the seismic wave, when the earthquake is generated, it takes almost one and a half minutes to reach Mexico City. So what happens, because well, and they see, OK, the radio frequency, what the speed is about 300 kilometers per second. So if we send a signal from where the, when the earthquake happens, it will reach one minute, 24 seconds before the earthquake hits Mexico City. So this is the science, well, this is all science, like I think in the 19th or 18th century, somebody discovered this, the speed of seismic waves. But when they see we have this big earthquake, we can do this. So in 86, Mexico City government, federal government, all the governments, founded the Center for Seismic Implementation and Recording. The CIRES. The first thing they did was to install a network of accelerometers in Mexico City to measure how the earthquakes feel in Mexico City. And they proposed this system we see on the right of the screen. They installed a network of sensors to sense the earthquakes on the coast, where the tectonic plates are hitting, and to send the signals to Mexico City and to process it very fast. And if the seismic activity was worth enough, to send an alert to all the population in Mexico City. So they developed this system that was activated in 91. And well, they developed a sound, a very distinctive sound, like... I will not play it, because people from Mexico City, when you hear that sound, the skin, yeah, you feel it. Like... Yeah, something like that. They invented this sound, and well, this... What happened? In 93, I think it was the first seismic event that was alerted. Yeah, they... And they do the science, like... You can see the publications, like, okay, we got this signal on the coast, and we got this signal in Mexico City, so they verified the science was working. And well, CIRES is an academic engineering organization. It has a lot of scientific and outreach publications. Very interesting. If you want to know more about it, like, they have papers about also the social part of this kind of system, like how they perform, comparing to other systems in the world. Okay? So this is the Mexican Seismic Alert, how it works. You have the sensor stations on the coast. You have a network of concentrators and repeaters, like everything is also sent by RF to these concentrators, and then came to a central station that even the location in the city is secret. Well, it's not published. And well, this central station that runs very interesting software, there are papers about it, like how do you do this prediction of the seismic event, and if it's worth to send the alert, because, well, if you have an alert popping, like, every week or every month, you will lose the fear of this alert. Yeah? So they take it, like, very seriously. So this central station is connected. I don't know how, that's the question I'm asking, to several systems to broadcast this alert. Like the first system was direct links to the Mexican city government, to the subway system, to these organizations of the government. Also, it was sent to radio stations, to television at the beginning. So to schools, I remember my school, when I was a boy, it had a very big radio, like, receive these alerts. So in 2008, they start installing the EAS, same transmitter network. This was 2008, like, not so long ago, we will see. And they start to install receivers for this in government buildings. They started with government buildings, and then commercial buildings. And well, that's why the red square is there, because that's what we will be talking about, right? We will be talking about all the other systems, like, I talk about it because I think it's cool. I'm really happy that we have this, but now we are going to talk about these networks. They are also testing the self-broadcast. I think here it's a little bit more widely used, like, you get the AMBER alerts on your cell phone, but yeah, in Mexico City, they are still testing it. It's not working very well, so like, yeah, yeah, it's not... they have to work with the mobile operators and I haven't received a signal yet. Because, well, in Mexico City, there are two times a year they send a signal, like, to simulacros, I don't know how to say it in English, it's like drills. There are drills two times a year about this. So yeah, it's a pretty big deal. And well, for example, the direct links that are sent to the government, the government of Mexico City has a network of speakers in the city. They don't cover the whole city, but in several parts of the city, you hear this sound, like, wah, wah, wah, wah. So yeah, like, people, it's pretty aware. So if you're in Mexico City and hear this sound, do what the other people do and you will be safe. And you will know how it will hit in a couple of minutes. Not so long. Okay? So yeah, just to wrap up, you can see on the left, it's the current state of the sensors. We start with 12 sensors in Mexico. There are a lot of more. They are expanding this system. And on the right, it's the network of transmitters we have in Mexico. We have about 20, 15, something like that, that covers, doesn't cover all of Mexico, but covers the central part that is the more populated. So like, 30 million of people depends on this system to get alerts about this kind of danger. So even if, as we are going to see, it's an old system, it's pretty relevant still. Like I just see a sticker in another village that says that legacy technology doesn't die, it just becomes critical infrastructure. Something like that we have with these systems. Yeah, they don't die. Yeah, so where was the aha moment for me? You can see on the left, this is the transmitters that were being installed first on government buildings. So in about 2010s, in the early 2010s, I saw one of these receivers and I see that they have this public alert logo and I see like a NOAA logo and then I see on the Spark phone, I don't remember what was first. Like if I see the radio of the Spark phone, but I see like, okay, this breakout board from Spark phone, they talk about NOAA and maybe it's not, because well, you see the radios, here it's open, but normally they are closed. So you think maybe it's some custom technology, I don't know, because they were not announcing how they were building this. So I bought some breakout boards and well, I built my receiver. So yeah, in 2010s, what you do when you start receiving something cool, you build a Twitter box. So yeah, it was popular to get on Twitter the alerts, so I published a project, SeismoAlerta, like seismic alert. So you can see the receiver on the right, I built, and well, some Twitter and some SeismoAlerta on the 20th of March of 2015. So yeah, that triggered... well, some people were very interested, I made a workshop to build these receivers on a makerspace in Mexico City, Acedores Makerspace. So there were like eight people, we built some receivers, so yeah, the government published some like, oh, you remember, the internet channels are not official channels for this kind of alert, because they can have delays, and you know, I didn't take it very seriously, but yeah, like, okay, well, I added a disclaimer, it's not official, you build it at your own risk, this is not official. But at the same time, there were other people that were very critical of the government, because the government funded this, but there was a company, a private company, for profit, selling the receivers, and these receivers were the only ones authorized by the government, so there was no way to make one receiver, or to make it comply with the law. So there were some people, I don't know them, but they started to be very vocal about this, until the government made a standard, and they said, okay, we will receive applications, so you can build a receiver, or sell a receiver. But at the same time, I don't know if it was good or bad, I have mixed feelings about it, they modified the standard, and well, the receivers from the US market no longer work for their quick alerts. We are going to see what they changed later. So well, you see the logos of the companies, Alertandote and Sina, they built receivers that comply with the law, they send them to review, and to be authorized. And well, I'm very happy, because I know at least one of these companies is using the software I published. Yeah, I know for the developers. It's cool to have help to build this small ecosystem of entrepreneurs around this in Mexico City. And well, then I studied engineering, so I needed a project to finish my studies, so I built a receiver, like a formal one, I built the documentation, testing, following the rules. I also published it, as you know, any dissertation about a degree in Mexico has to be published. So yeah, this was the receiver I built, the PCB on the center is the one I designed, I programmed, and I talked about. And then when I was doing the research for this, you know, for the document you have to deliver, is when I started learning the details of how the EAS systems, the alerts are transmitted, are encoded, and that's the second aha moment, like, okay, so this is not so complex or even secure as you would think about it, right? So yeah, that's where this idea, this talk, it was born. So, we are going to jump to talk about the EAS, same system. I don't know how many of you know what it is, can you raise your hand? Yeah, I think it's popular here, but as you just saw, it's very relevant to Mexico City, like the people living there. I know it's useful here, but for certain areas that are prone to certain dangers. So what is the EAS? The EAS is short for Emergency Alert System, and it's a system nationwide here in the U.S. to notify the public about natural disasters, security threats, or civilian emergencies. And the same protocol is short for Specific Area Missation Coding, and it's a digital format used to transmit information about the type and location of hazards, such as severe weather or other dangers. So that's the EAS, same system. So the origin, I think this is very cool, like the origin is from the Chicago area, when they started broadcasting this marine weather broadcast. So they were transmitting it in 162.55 megacycles, not megahertz, megacycles. It's cool to know that. So yeah, this was a frequency VHF that they were transmitting like just a weather report. It's not FM radio, it's a little bit different, a little bit higher, but it's the same. They were transmitting voice messages about the forecast. So yeah, so this system started evolving. Like I say, in the 60s, the weather information broadcast in the U.S. In the 70s, in 71, they introduced the warning alarm tone. It was a tone that was made for... you didn't have to have your receiver on all the time. If your receiver could be like the speaker off, and if they get this tone, the goal was to turn on the speaker, and you would hear the alert. So that's the warning alarm tone. But it was on the same frequency, so then they designed this network transmitter, the NOAA weather radio, and well, in 88, after 10 years of development, the NWBS, the National Weather Relay, the same protocol. So what I'm trying to clarify here is things move slow with this kind of systems. It's not very fast. And then in the 97, 10 years after it was released, it was adopted in the U.S., and then almost 10 years after that, it was adopted in Mexico. So if we see at this timeline, maybe this is a legacy system, but it will be in use I think for at least another 10 years. NOAA weather radio, it covers 90% of the 50 U.S. states, as you can see. In Mexico, it covers just the center part, but we have only like 15. You have over 750 transmitters. It's a pretty big network. So yeah, this is where the fun begins. So how it works, NOAA weather radio. So on the right, there is the table of the channels, the frequencies. As you can see, the first frequency on the table is the same from the 60s player. So yeah, they continue to use it. They haven't changed it. Well, I understand it. Why did you change it? Because, well, after you see they are using the same frequency, you just added the warning alarm tone, then the summit protocol. So in theory, if you have a 60s radio, it should still work. So yeah, the range of this transmitter is up to 40 miles on flat terrain. And well, the modulation is wide FM. It's wide FM modulation like any radio modulation. So yeah, and well, what about the same protocol? The same protocol, these are like digital broadcasts that you hear on these channels. On AF-SK modulation, audio frequency shift key. So yeah, they have a bit period of 1.92 milliseconds. That will be like about 50, yes, it's 520 bytes per second you can send. Yeah, there you see the logical 0, logical 1. There is a preamble of 16 bytes of A, B, C, 1, 0, 1, 0, 1, 0, 1, 1 that are sent before each broadcast, so the receivers can sync with this protocol. And well, the characters are encoded in ASCII, so the less significant bit is sent first. And well, that's all. So when I saw this, when I was writing my designation, this is something you can write, you can decode even, you can see it and you can count it. So on the right is the structure of one message. It's composed of four sections. There is a header , an alert tone, the ones from the 70s, then a voice message that's optional, and then an end of message. So the header is where all the information about the alert is sent. They send the same protocol, send the message three times, so the receiver must choose each bit, like two of three, if it's the same, they build the message. So as you can see, there is no error correction, so the receiver has to do it from the repetitions. And well, each header, it sends a preamble, then the header, a pause, and then another two. So let's see, well, this is the header. The header starts with the start of the header, then the organization, then the type of event, then the geographic area code, that's the area message encoding, that's the area part. They can send several of these codes. This is made so if you get the alert, for example, if one transmitter is on top of a hill, you see this in each side of the hill will receive the message. But why do I care if the alert is from the city on the other side of the hill? So you can configure your code area to your receiver and ignore alerts that don't match your receiver. So they also send expiration time and the issue date and time, and the transmitter ID. So this is the information they are sending in one of these headers. So the event type, EQWB, it's for equipment warning, ERDWT, it's a regular weekly test, TOR, it's for a tornado, and so on. So yeah, it's very simple. So, well, and how they implement it in Mexico. That's the interesting part for the ones that know how it works here in the US, so how we did it for Mexico. So yeah, first we have a law that says that in the workplace and in commercial buildings, you have to have a receiver for this kind of alerts. And then we have a technical standard, which is the standard about this. So in technical standard, they state a lot of things, but the most important part is ERDWT, the regular weekly test, is not sent weekly, it's sent daily, and each three hours. So yeah, this says a little bit about how this is important for us, like you have your receiver and it should have an alert on the receiver if after three hours it didn't get the weekly test. So you must check your antenna installation and so on. And then, their quick warning, the EQWB, it's sent three times. So three messages, like the ones we saw, without a voice message, without a warning tone, and if your receiver gets one of these messages, it must play the official audio within five seconds or 60 seconds. So they take out the voice message. So now, if you bought a U.S. receiver, it doesn't work in Mexico for this alert. So yeah, they say it's to make it more robust, but well, I disagree a little bit because a lot of people were buying receivers for the U.S. market because the price of an official receiver, they are 20% the price of an official receiver. So they were very cheap, and people were buying these and there was a market, but they were not officially recognized. So yeah, we can gossip about that. There is a lot to say about it. So let's see how can you receive the code and encode these messages. So that's the fun part, the theory. In practice, how can you receive these messages? As I say, you can use a commercial radio, like the Midland, or the ones that sell the government in Mexico City, and I think there are a lot of weather radios here in the U.S. You can use dedicated ICs, like the SI4707, that was the IC that was sold in the Sparkphone breakout that I showed you at the beginning that I used in my receiver and then used for my degree. I used the same one. It's a solution in one chip that tunes the code and does everything. But you can also use an SDR dongle, and that's what we are going to use to see how this is transmitted and we're going to decode it. So this is with SDR++. How do you see it in Mexico City? At least in my apartment, I get like three or four very strong signals about the weather radio. You can see it on the right. I even get the signal from another state, because there are a lot of transmitters in Mexico City because it's a city and they want to cover it because there are a lot of buildings and they want to have coverage. So I'm going to play what you hear on this audio channel. I don't think the audio is enabled for the presentation, but what you hear is the weather report for Mexico City. If you tune to one of these frequencies. So yeah, it's very easy. And then here we see the moment that they send these text messages. You can see like the three digital brushes of the message of the header that has all the information and then you have the three end of messages, like the small ones, messages. So now if you record this... yeah, you will not hear, but I don't know if... ah, you can hear it on my laptop. This is how it sounds. So yeah, that's how it sounds. Okay, so if you record this, you can decode it. So there are already built tools, like Multimon, that can decode a lot of AFSK protocols. So if you record this, you can decode it and you can see the message we saw at the beginning. So I am marking in red, because I told you, the standard says that you have to have two equal bits, so you can take this bit as valid. So the message with the first two headers, because it receives and they are equal, this is the end of... like the final message, the third message, it helps, but it doesn't matter. You already got the message. So yeah, you can use it in Multimon to decode this, but yeah, just for the fun, I built my decoder in Python. So yeah, it's not very difficult, as I was saying. I use SciPy and NumPy. It processes the recordings in web format. I use a band-fan filter and the Groetzel algorithm to detect the tones. Groetzel algorithm is a type of fast Fourier transformation that you send a little part of the message and it tells you the dominant frequency. It's synchronized using the preamble detection and applies a sliding window to detect the bit transitions. And well, it detects the audio attention signal and extracts the message stream. So yeah, you can see the code there and there is a recording of the same message. So yeah, a real recording, in fact, the one we heard. And then, how can you encode this? I was going to build it, but I decided not to because there was a Python library to do it. You just input your header and it generates you a web file. So yeah, it was pretty easy. So yeah, I decided to build the decoder because decoding is much harder than encoding. So I decided not to build it. But well, how can you test if this web file turns on the receiver? So you can. Well, you can, but you should not because this is pretty legal in Mexico. And also here in the U.S. I think so. So yeah, in Mexico the law says that it's... I don't know how to say it in English, but the point is that you can... they can send you to jail and ask questions later. Basically, that's what the law says. So yeah, it's pretty hard if you transmit on the weather band because it's reserved. But you can validate if this web, you send it to the decoder and the decoder says the same. So yeah, you can do it. If you want to transmit, you know there are SDRs that can transmit on these frequencies or maybe a radio can do it. You modify it because but yeah, it's pretty easy. So this is how it looks. On the top you can see the recording. You know, there is noise, there is a lot of things, and in the bottom part is the one you generate. So obviously because you are generating it, it's clean. But now that you know how it's done, don't do it. Yeah, yeah, because well, it's punishable by law, but also it's like you play with, you can play with people and it can have implications. So some final thoughts. First of all, I think it's very cool that we have like in Mexico the series, even with the bad parts that they have, like it's, I think it's, we must be proud in Mexico that they build this technology, that it works, and yeah, it's something that only applies to Mexico. It's one of, because the seismics came from far away from the city, they can do this. And well, the NOAA weather radio, I think it's also a cool system here for the U.S. I'm glad we have this kind of organization that build this kind of technology to help save lives of people. So there are advantages and improvement areas about this. So first, advantages, the simplicity. As you saw, you need only a receiver that can decode some AFSK signals, so it's simple. Interoperability, so it's an open standard. You can build receivers, you can do it with your own. It's efficient, you saw the message is small, and it goes to the point. Resilience, so yeah, it works fine in rural areas, remote areas, so you have like, you saw like 15 receivers and you cover like 30 million people in Mexico. So yeah, it's resilient. And well, it's a standard, so yeah, you can save on training, and all that kind of stuff. But improvement areas, so the first one is lack of origin verification, right? Anybody can transmit these signals and nobody can verify its origin. Message tampering, it's almost the same, like anybody can alter the signal, like you can or change something. Interference or jamming. So yeah, I think with any wireless system, you can do some interference, some jamming, but there is no channel jump or something like that, no. It's just a fixed channel. Dependence on specialized hardware. Obviously you need a receiver that can synchronize these frequencies and interpret it. And well, language limitations, obviously. You can only transmit a voice message in one language, so you have to choose one, like here in the U.S. there are people that speak a lot of languages. So I think that what you do here is you have frequencies for one language and another ones for another language, but it's not ideal. So, what's beyond these systems? First is the Common Alerting Protocol, that is a system that is designed to have signatures. It's an XML protocol, so it has overcome a lot of the improvement areas we saw. And well, I already mentioned this, Cell Broadcast. It's part of the GSM protocol, so it lives in lower layers, so it doesn't matter if there is network congestion or whatever, or even if you don't have the data on your SIM card, you should receive the message. But yeah, in Mexico there is a tough time making this work. And in fact, I think today or yesterday, they were just going to send another alert to see if it worked this time. So yeah, that's all. I'm very grateful for you for being here. So please, if you want to connect, I am Manuel Rabade on social networks. You can drop me an email. You can visit my webpage when I write about technology and other stuff. I also invite you to follow the RF Village, the Mexican version, that was inspired by things like this. So yeah, if you come to Mexico City to a security event, maybe we will be there, or if you want to go and do some tourism in Mexico City, we can hang out a little bit and let you know what you have to do in case of an earthquake. And I really want to finish this with a question. How do we balance accessibility, interoperability and security? Because, well, doing software or doing whatever, at the end it's a balance of these. So yeah, it's a very interesting question. How can you secure these systems? Because if you add a security layer, you also are adding a part that can fail. And if it fails, it can stop alerting people. So yeah, it's like... there is a balance. There's no right answer how to tackle this. So yeah. So thank you very much for everybody and have a great day.