A universal method of circumventing the ban Yota to distribute the Internet from the phone or collect the Android kernel module

Old methods and their disadvantages


I think no one is interested in reading a second time (or maybe a third ) about how Yota determines whether a person uses a phone in modem or access point mode. “Why do we need another article?” - you ask.

The fact is that the bypass methods provided by the links do not allow you to configure the phone so that later when you connect any devices you do not need to configure anything again. In addition, the user will experience serious inconvenience if he connects several devices with different TTL. You will have to at least change the TTL on one of them.

It was these reasons that motivated me to dig further in search of an answer to the eternal question “How can I give out the Internet to the entire office for free?” And I managed to find such an answer (only for android, I do not have an apple).

Finished program


When I found out that Yota is monitoring TTL, I assumed that there are probably providers in other countries somewhere who do the same. We are trying to enter TTL in the search for the Play Market.

I was right: the TTLEditor program was found right there . It is very nice that it is not only free, but also open source .
It is very simple to use: select an interface (it is best to choose the interface through which the phone is connected to the provider, I have rmnet0 ) and click OK. You can also put the program to work when the phone boots.



Only one problem arose: the program generated an error " TTL update failed". Before scolding the author in the comments and minus the Play Market, I decided to read the source code.

Note. Perhaps the program will work immediately on your phone model. So you are very lucky, close this article and enjoy life.

Cause of error


The main action of the program is to run the following command as root:
iptables -t mangle -A POSTROUTING -o <interface> -j TTL --ttl-set <TTL value>
Many brains are not needed to understand what this command does (moreover the program says about it): it sets the TTL value to all packets passing through a certain interface (that is, just what we need).

I tried to execute the command manually and saw this error: iptables: No chain / target / match by that name . A couple of minutes of googling showed that iptables is ready to give out this error on almost any incorrect parameters. Google in relation to TTL and somethingstill find. We look how suitable information we have found.

The command cat /proc/net/ip_tables_matchesissues a list in which there is ttl , that is, our kernel can check TTL. But in the list that the team issues cat /proc/net/ip_tables_targets, there is no TTL , so our kernel does not know how to modify TTL . We will not give up before such an impudent conspiracy of mobile providers and manufacturers, so we are going to assemble a kernel module that is missing.

I think that at this stage, CyanogenMod users are already giggling giggly, but I didn’t want to give up the regular system so easily, but I wanted to add new features to it (without even replacing the kernel).

Retreat


Further, I assume that the reader knows how to use Linux, understands what the kernel and kernel modules are, and also knows how to use adb to transfer files (adb push / pull) and how to open the telephone terminal on the computer (adb shell). If not - urgently to google! If so, be sure to enable USB debugging.

What to collect and how


This is the most difficult step : you need to find a suitable cross-compiler and kernel sources. Try to search specifically for your phone, because otherwise, most likely, it will not work (and this will be known only at the last step). I made several unsuccessful attempts, making a mistake at this stage.

My model is Sony Xperia Z1 Compact, the operating system of my computer is Ubuntu 14.04. Below on their example I will show how you can act.

  • The team cat /proc/versioncan tell which version of gcc was used to build the kernel on the phone (mine: 4.7 ).

  • Download the appropriate cross-compiler (toolchain). I found it here . I execute the command on the computer:
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7
    and I have it in the arm-eabi-4.7 folder (do not forget to install git to clone the git repository).

  • The firmware assembly number can be found in the phone settings “About phone”. I have: 14.4.A.0.108 .
    We managed to find the necessary kernel sources in the corresponding archive here and in the repository here . I took it from the archive, because I had previously found it.
    If I understand anything in the world of licenses, then the manufacturer is obliged to provide the source code for the kernel running on the android phone.


Setup and assembly


Those who are faced with the process of assembling the kernel for the first time, do not give in to panic, with Google we are always god-like .

  • To begin with, open the console in the folder with the kernel sources and configure the environment so that the kernel is collected by the extracted cross-compiler:
    export ARCH=arm
    export CROSS_COMPILE=/путь/к/arm-eabi-4.7/bin/arm-eabi-
    At the end of the environment variable, there CROSS_COMPILEshould be a common prefix for most (or all) executable files in the bin folder .

  • Then you need to create a default kernel configuration (file .config) for your phone model . The command you need for this is usually written in some README nearby. In my case, there was a file in the folder with the kernel sources README_Xperia.
    make rhine_amami_row_defconfig    # создание дефолтной конфигурации ядра для Sony Xperia Z1 Compact

  • And now you need to take a step that is usually not given in the kernel assembly descriptions for Android.
    make menuconfig
    The kernel configurator will open.

    Press “ / ” and enter “ TARGET_TTL ” into the search .



    Yeah, now it has become clear where the core capability we need is located. Go to it in the configurator and press the " M " button . This means that we want to compile this feature as a kernel module.



    We exit the configurator, saving the changes.

  • We assemble the kernel and modules:
    make -j8
    make modules
    If any errors occurred, it means that you most likely found the wrong kernel source or cross-compiler.

  • The assembled module we need is here: net/netfilter/xt_HL.ko


Using the module on the phone


We transfer the module xt_HL.koto the phone and try to connect it to the kernel with a command insmod.
If this command gives an error, then you can find out the details in the output of the command dmesg(most likely, it will be a conflict of kernel and module versions or something similar - this means that the wrong kernel sources or cross-compiler were taken).

If the command is insmodsuccessful, it means the module was able to connect to the kernel (you can check the command lsmod).
After that, we try to run the command that TTLEditor tried unsuccessfully. Does not give an error? So the rule has been added to the list. You can check with the command iptables -t mangle -L:



We try to distribute the Internet to any devices and rejoice.

Startup Setup


The last step remains: to make it so that you can distribute the Internet whenever you want.

Create a file setup_ttl_editing.shwith the following contents:
#!/system/bin/sh
insmod /storage/sdcard0/xt_HL.ko
iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set 64

We drop it onto the phone, install the Script Manager program and configure it to have the script run when the system boots and as root.



Everything is set up, you can forget about the problem of distributing the Internet from your phone!

Note. We do not need the TTLEditor program. Everything you need is already written in the script.

Conclusion


I will not write “ iota, do not be greedy ”, because compared to many other mobile providers they are still quite generous. I’d better say: iota, stay the same as you are.

Download the filext_HL.ko that I got for the Xperia Z1 Compact, please follow this link .
Perhaps it is suitable for similar phone models.

UPD from 03/13/2015. Thanks to the user CTE6EJIb for the filext_HL.ko for Xperia V Android 4.3, firmware version 9.2.A.2.5.
UPD from 08/01/2015. Compiled for Xperia Z1 Compact for Android 5, firmware version 14.5.A.0.270. Download .

Also popular now: