So my name is Bogdan Aleku and the topic for today would be business logic flaws in mobile operator services. For those that don't know me, if you think about me, I work as a system administrator as day job and during my free time when I have it, I like to break a lot of mobile related stuff. I started on this path a couple of years ago with monitoring GSM networks by using net monitor tool from a Nokia phone and then continued with voice over IP and finally got to GSM and mobile phones. If you want to keep in touch with me, you can find me on Twitter or on my website. So the goals for today would be for you to have a really high overview regarding SIM toolkit, what it is, how can we exploit it. The first thing is, I'm going to present you a couple of business logic flaws I've identified on some carriers and I think you're going to find them really interesting and also in the end, if there is a way to protect from this attacks that I'm going to show you. So we're going to cover SIM toolkit, HTTP headers, data traffic, extra digit and summary at the end. So who has heard about SIM toolkit? toolkit. Okay. To keep it simple, think about it as a platform for the carriers in order that they use it in order to install applications on your SIM card. This is how SIM toolkit icon looks like on an Android device. On some other devices, you might find them like an extra menu with the carrier's name, like orange Vodafone and so on. And from this SIM toolkit menu, you can find things like exchange rates, the weather, how is the weather like, or calling customer support, so different activities. And if you think about it, it's a pretty good thing because you have these applications on your SIM card and no matter what phone you use and you put your SIM card in, it's going to be the same thing. So you don't have to install anything else in order to have them. Since this application sits on your SIM card, the carrier has a way to update these applications or modify them or delete them and so on. So for example, if the customer support number changes, the carrier will send an over the air update, which is basically a text message to your SIM card. And then the carrier will say that the SIM card should update the phone number for the customer support. This message is kind of a special message, a common message. And in order to have this common message, they make use on the SMS of the user data header. The same user data header is used in cases like when you go over the 160 characters limit and you go concurrently. So if you go over the 160 characters, you have two messages, which are concatenated into one message. And this makes use of the user data header. Of course, and also in cases for who remembers the old Nokia ringtones, they also used user data header. This is how the common packet looks like for such SIM toolkit SMS. So as I said, you have the user data header and then some other fields like command packet, length, header length, security parameter indicator and so on. The most important one that I want you to keep in mind is this security parameter indicator. The number that you see below represents the number of bytes each element has. So this ‑‑ all these specifications can be found on GSN specs. In order to also have this comment, you also add other two important fields. Data coding scheme and protocol ID. By setting the protocol ID to 7F, it means that you do a SIM data download. And data coding scheme to F6 means that this type of text message is directly addressed to your SIM card. So according to the GSN specification, what will happen when you receive such a comment message, the phone will transparently pass this SIM message, this comment message to your SIM card and will not alert you in any other way. So basically when your carrier sends this comment message saying, okay, I want to update the number for the customer support, you will have no idea that you have just got a text message. And I told you keep in mind security parameter indicator. So you're sending this comment. But you need some kind of acknowledgement to know that this comment message has been received. And this is called proof of receipt, which can be set in the first two bits. If you set it, for example, to 01, it means that you always want to get a proof of receipt. So no matter if there was an error or there wasn't any error, you will always get the proof of receipt. And how you get it, you set it in the bit number 6. And there are two ways of getting this proof of receipt back. By SMS submit, which means by a regular text message, which is sent by our SIM card, or by SMS delivery report, which is like a delivery report when you send a text message and you want to know if the target message or the target person has received your text message. So, again, we have the structure and we need to fill in the elements. The user data header, the protocol ID, the data coding scheme I have presented you, and then the others. And as you would imagine, in order to make this update of the customer support number, you need to have some proper security keys. . So if you look at this example, you will see that ciphering keys that are KIC are set to 0, because I do not care about ciphering keys at all. Why? Because of the security parameter indicator. If we drill down to this security parameter indicator, you will see the first two bits are set to 01, meaning that I want to get a proof of receipt, always get a proof of receipt, and I want it to get by a text message. So basically, when you're going ‑‑ when ‑‑ if I'm going to send this text command message to you, what will happen, it will get to your phone, the phone will pass it to the SIM card, the SIM card will try to execute it, it will see that I don't have any proper security keys, but in return, it will send me back a text message without you controlling it, without you even knowing it. And in order to make sure that how the things are like, here is a screenshot of a Wireshark capture, and as you see, the command is to send short message. And it has been initiated by the card application toolkit. So it wasn't a human-initiated action. So SIM card automatically replies to the sending number. There is nothing in your inbox, nothing in your outbox. Basically, you will have no idea that you're sending a message. So you will have no idea that you're sending a message. You will see that your SIM card has just sent a text message back to me. Only if you look at the ‑‑ on your bill, on your detailed call records, you will see that sometimes your SIM card has just sent a text message to someone. So let's see it in action. Okay. So, here I have the destination number. I have the user data header. The binary data, the fields that I filled in. The protocol ID and the data coding scheme. And I have the target phone. On this phone, this is a prepaid phone, and there is ‑‑ its balance is zero. So I have no credit on it. So it will try to send a text message. But since it has no balance, I will get a text message from the carrier saying, hey, you don't have any credit. You need to refill. So. Okay. Now, once I support the SIM card, it will send a text message to the carrier. I will submit this. It says sending. And there is no way to stop this. I can push any button. The SIM card just sends ‑‑ tries to send a text message. You cannot control it. And it keeps trying to send. If I hadn't looked at it, I would have no idea it just did this. So if you ‑‑ if it's in your pocket, you are not going to see the text message. you will have no idea that your SIM card is trying to send a text message. And I also got some text messages from my carrier saying you do not have enough credit for sending SMS to this number. Please recharge your account. But I didn't send any text message by myself. The SIM card tried to do so. So maybe you will think that, okay, this is maybe not something I don't know important. Let's say I can make your SIM card send a text message back to me. Well, maybe that's not a big deal. But let's think on some other way. Okay. So let's say, you know, there are services that allows you to send a text message from any number. So you can send someone a text message coming from whatever number you want. Now, let's say you also have a premium rate number, international premium rate number, and you send a comment message coming from the premium rate number to some target phone number. What will happen, the target phone number will send a text message to the target phone number. What will happen, the target phone number will send back a text message to the premium rate number you have. So you're paying like a couple of cents for sending a text message and in return you get 20 times more. So it's a pretty good conversion rate, right? And the target phone, as I told you, some phones don't even show that there is a text message sending in progress even if you keep your eyes on them. So until you will get your monthly bill, you'll have no idea you have just sent text messages to premium rate numbers. Now let's talk a little bit about HTTP headers. The easiest way you can think about them is by identifying the browser you're using. So if you're browsing from Firefox, let's say. That browser will have specific HTTP headers. If you're browsing from Safari, it will have other headers and so on. Now, with this in mind, there are some ‑‑ most of the carriers have a mobile page where you can find your balance, you can change your services, you can download ringtones, videos and whatever. This page address is usually m.carrier.com. So the carrier name. If you try to access that page from your computer, you will most probably get something like this. So they will detect that you're not connected to their network and they tell you, okay, you have to connect to our network in order for us to show you the page. But in some cases, if you pretend to be browsing from a mobile device, they will display this page. So what I did was to use Firefox extension called user agent switcher. And I identified myself as a Nokia EC2 user agent switcher. And once I did that, I got the display page of the mobile page of the carrier. But it was just a general page because I was not authenticated. So I could not see any balance. I could not download any ringtones. I couldn't do anything. Well, this is how the things are starting to get interesting. The operators, the carriers know how to charge me. And they have their own devices. They have their own systems. They have their own mobile phones. And the operators are not from the sameから from the same area. So I just have this case that I did, you know, from the same area. And just to show you why it All right. mobile device was accessing his website, that carrier was also sending the phone number. So he did a list with all the HTTP headers that the carrier was sending and published it and the carriers are no longer sending these HTTP headers. Okay. So they are not sending the headers. But what if I will inject the headers in the traffic? So I chose a couple of HTTP headers which identified the phone number and as their value it is the phone number in international format with the country code. So now I can access that mobile page of the carrier from my computer by identifying myself as a mobile device and I can also authentically indicate myself by injecting these HTTP headers. And what happens now, I can see anyone else's balance. I can change their subscription plan. I can refill any other account and stuff like this. Whatever carrier allows me to do so. And some carriers are even tidying up the phone number with the bank account. So you can even see the bank details of that specific customer. But I didn't stop here. Remember when there was a time we had to call Internet with our phones? Well, I was surprised to see that there are still carriers who still have CSD. So think about it just like a dial-up connection from your phone. Right? So the carrier has dial in number. You set up a dial-up connection from your phone to that number and you're browsing the Internet with 9.6 kilobits per second. Which is around 1 kilobyte per second. Pretty good speed, right? Well, but since it's just a phone call, it also has the vulnerabilities of a phone call. Which are caller ID spoofing. Now, guess what was my reaction when I first set up a dial-up connection to a voice over IP provider which was spoofing my caller ID and then forwarding the call back to the dial in number. And I was authenticated. So this is just the target phone. It's the screen of the target phone. And also I have connected a mobile phone via Bluetooth. Because I want to have a GSM modem attached to my computer. So first I'm calling myself on my own number with my own number. So this is what it means, own number. So this works. Then I'm making up the dial-up connection. As you see, I'm using a pretty old Nokia phone. And I'm connected to the carrier's network. What is the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the, the choose something to download. And I'm choosing some image. It goes pretty slow because remember I'm browsing with one kilobyte per second. So and it also goes the call goes internationally. So okay. I'm choosing some image which costs 1.99 euros. So I'm going to download this image. And once I click buy now, I will get a text message on the target phone. So the thing worked apparently. And it says thank you for your purchase and so on. So now I'm going to check again for the balance. So previously I had 6.05 and this one costed 1.99. So now I should have 4.06 euros. So now I'm going to check again for the balance. So now I'm going to click buy. Okay. And indeed I have 4.06 euros. So the attack was successful. Just by spoofing the caller ID, I was authenticated like any other customer. So I'm going to get this email. So the data. So let's talk about the data traffic. Let's talk a little bit about data traffic. Let's say you have a prepaid account and you have some data included in your subscription. You have no more money on your account and you have finished all your data in the subscription. What will happen? happen? Will you still be able to have data connection? Well, you will still be able to have data connection but the only page you will be able to browse will be the carrier's web page because maybe you want to do a refill and browse again the Internet. While I had no more money in my account, I thought, well, what would happen if I perform a DNS query? So I tried to find the IP address of Google.com and I got a reply from the DNS that my carrier was using. Okay. That works. But what happens if I use open DNS servers? And I also got a reply from open DNS servers. Although I could not browse any web page but the DNS replies worked. So then I thought of this. What if I set up a VPN server on my cable connection at home? And make that server run on port 53 UDP, which is the DNS port, and then set up the VPN connection from my phone to my server. So think about it just like a regular VPN connection, but this VPN server is listening on port 53 UDP. And guess what happens? You have free Internet. And even though I had a speed limit, now with this method, the speed limit is gone. But I didn't stop here. Since I'm living near the border at home, I thought, okay, what happens if I force my phone to connect to a network across the border and try the same? And it also works in roaming. So right now, instead of paying $12 per megabyte, I'll let you guess how much I'm paying. Next the extra digit. I'm pretty sure you have here a flat rate plan with unlimited minutes inside your operator's network. So if you're from Verizon, you will have unlimited minutes in Verizon. But if you call to AT&T, for example, you will not have unlimited minutes. And you also have mobile number portability. So you can transfer your current number to a different operator. Well, let's think of this scenario. You have two mobile numbers, two phone numbers into an A Operator. And you decide to transfer the second number to the B Operator. If you're calling now from the first number, you have to transfer your phone number to the B Operator. number to the second number, you will be charged like calling across the network from A to B. But in some cases, if you dial the same second number but add some extra digits at the end of it, the carrier will have no idea that the number has been transferred so you will be billed like calling inside the same A operator. And also, it also works the other way around. So if you have two different numbers in two different networks and you decide to transfer the second number to the A network, if you are going to call with the extra digit, you will pay more because it will not know it's in the same network as yours. So on this side, it's not so good, but if you have them on different networks, then it will be even good. So, let's see how that worked. So here I have 2,077 minutes inside my whole network and 58 minutes national minutes and international minutes. So what I'm going to do, I'm going to call regular 10 digits. This is a number which has been transferred in the same network as mine. So it's the second case scenario where I am paying more than I should. Now, I'm going to check again for my balance. And now I have 2,076 minutes. So one minute has gone from the initial minute plan. Now I'm going to dial the same number again but add two extra digits at the end of it. I'm going to add 15 at the end. Okay. I'm going to hang up. Check again for the balance. Okay. And now I should have 2,075 minutes, national minutes. But the national minutes have been the same. And you see it has been deducted from the 57 minutes. Even though the number is in the same network. So I wasn't deducted from this minutes but from the minutes to other networks. And what's even funnier is that on some carrier, this P, first when I dial the number, you see it has a P at the end, which means it has been transferred. And it has been deducted, my call, from the 150 national minutes. The second time I added two extra digits and this one means unknown. So I have been deducted from the unknown plan. Which means I get to talk free for this important number. Even though I do not have unlimited calls. And if that doesn't work, try with all of the digits. One carrier was working, worked with this attack only if I had used one digit. And that digit had to be number two. I have no idea why. But if I put two, then it worked. Okay. Well, after reporting this, the carriers, most of them have fixed it. So now when I'm calling with the extra digit, I get a voice prompt back saying you have dialed the wrong number. So I can no longer dial myself the wrong number. But how can I make the carrier dial the number instead of me? Well, it's pretty simple. Make call forwarding for all calls. And to the call forwarding destination, put the wrong number. . And once your call will reach to that forwarded number, your carrier will successfully dial the wrong number for you. So it will still work. As a summary, I'd like to start with some reply I got from customer support. Our technology does not allow unauthorized access. Occurrence of errors in billing regarding data traffic or voice is excluded because of their technology. Now that is an article we should check. Oh, sorry. You can call me up. I love to do this. But our SNAP is often affected by some delta voters. Dig級 gangster often does like this. I figure that this would be a lot of trouble for the interface. Everything's onHisJob.txt . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I haven't even talked about CodeStrich. Until now, I haven't found any of them that will do this. Because they could say only arrow SIM toolkit messages that are coming from specific numbers and the other ones just drop them. Also do not rely on the caller ID. There are still a lot of services that rely on caller ID and they consider this as a good authentication. This is really not proper authentication. Do a proper authentication. And to show you an example of some really good authentication, I don't know why sound is not working. Okay. Okay. Okay. Okay. Okay. Um, I don't know if you're going to hear it. . Starting with the area code, please enter this number you have called. If you're not ready. So basically what I'm doing now, I'm calling the customer support of some carrier in U.S. and I'm using Skype because it's free to call 1-800 numbers and if you're calling the customer support from a different network, it will ask you to authenticate by inputting, by entering your number, your number, right? Oh, so it has some kind of protection. It has the password I need to enter. Well, what do I have to lose? Let's enter some passwords, random passwords. Your entry does not match our records. Maybe better luck next time. Please press the corresponding keypad number. Your entry does not match our records. Maybe third time. Your current balance is... So I don't know if we implemented this, but I love this guy because usually on the third failure attempt you get kicked out, but in this case, on the third third failure attempt, they let you in. How cool is that? If I knew that previously, I would have tried it on so many systems. Really. Just enter three wrong passwords and you are in. Okay. Okay. To summarize, this is the good authentication. So thank you very much for your attention. I hope you enjoyed all the things I showed you. If you have any questions, you can follow me on Twitter, send me an e-mail address or on my website. Thank you once again.