diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..325bd2d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.ipk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..01a340e --- /dev/null +++ b/Makefile @@ -0,0 +1,183 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=yota +PKG_VERSION:=20161128 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/yota/Default + SECTION:=net + CATEGORY:=Network + SUBMENU:=Yota + TITLE:=Scripts for cheat mobile operator regarding tethering detection + MAINTAINER:=Ilya Fedin + URL:=https://github.com/ilya-fedin/yota + PKGARCH:=all +endef + +define Package/yota/Default/description + Yota - Russian virtual mobile operator, who blocks tethering at smartpone sim. + People not wish waste money for modem, and cheats Yota and other mobile operators regarding tethering detection. + These scripts helps you cheat your mobile operator! +endef + +define Package/yota +$(call Package/yota/Default) + TITLE+= (base files) + DEPENDS:=+comgt +iptables-mod-ipopt +iptables +endef + +define Package/yota/description +$(call Package/yota/Default/description) + Base files for cheat - fix ttl, configs, etc. +endef + +define Package/yotaban +$(call Package/yota/Default) + TITLE+= (bans bad IPs) + DEPENDS:=+yota +iptables +wget +ca-certificates +endef + +define Package/yotaban/description +$(call Package/yota/Default/description) + Ban bad IPs with iptables. +endef + +define Package/yotaban-nossl +$(call Package/yota/Default) + TITLE+= (bans bad IPs, mirror source) + DEPENDS:=+yota +iptables +endef + +define Package/yotaban-nossl/description +$(call Package/yota/Default/description) + Ban bad IPs with iptables - alternate source without https. +endef + +define Package/yotareboot +$(call Package/yota/Default) + TITLE+= (reboots on tethering detection) + DEPENDS:=+yota +endef + +define Package/yotareboot/description +$(call Package/yota/Default/description) + Autoreboot your router at beggar and don't leave your beach! +endef + +define Package/yota/conffiles +/etc/config/yota +endef + +define Build/Prepare +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/yota/install + $(CP) ./files/* $(1) +endef + +define Package/yotaban/install + $(CP) ./files-ban/* $(1) +endef + +define Package/yotaban-nossl/install + $(CP) ./files-ban-nossl/* $(1) +endef + +define Package/yotareboot/install + $(CP) ./files-reboot/* $(1) +endef + +define Package/yota/postinst +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Enabling rc.d symlink for yota" + /etc/init.d/ttl enable +fi +exit 0 +endef + +define Package/yota/prerm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Removing rc.d symlink for yota" + /etc/init.d/ttl disable +fi +exit 0 +endef + + +define Package/yotaban/postinst +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Enabling rc.d symlink for yotaban" + /etc/init.d/yotaban enable +fi +exit 0 +endef + +define Package/yotaban/prerm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Removing rc.d symlink for yotaban" + /etc/init.d/yotaban disable +fi +exit 0 +endef + +define Package/yotaban-nossl/postinst +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Enabling rc.d symlink for yotaban-nossl" + /etc/init.d/yotaban enable +fi +exit 0 +endef + +define Package/yotaban-nossl/prerm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Removing rc.d symlink for yotaban-nossl" + /etc/init.d/yotaban disable +fi +exit 0 +endef + +define Package/yotareboot/postinst +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Enabling rc.d symlink for yotareboot" + /etc/init.d/yotareboot enable +fi +exit 0 +endef + +define Package/yotareboot/prerm +#!/bin/sh +# check if we are on real system +if [ -z "$${IPKG_INSTROOT}" ]; then + echo "Removing rc.d symlink for yotareboot" + /etc/init.d/yotareboot disable +fi +exit 0 +endef + +$(eval $(call BuildPackage,yota)) +$(eval $(call BuildPackage,yotaban)) +$(eval $(call BuildPackage,yotaban-nossl)) +$(eval $(call BuildPackage,yotareboot)) diff --git a/README.md b/README.md new file mode 100644 index 0000000..eddb1c3 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# Способы перезапуска модема +По умолчанию в скрипте используется метод ребута роутера, но есть и другие методы. Ну что, поехали? + +## Способ 1 - перезагрузка через API +У HiLink есть API. Через него можно делать с модемом все что угодно - перезагружать, реконнектить и т.д. Подробности в /sbin/yotareboot. + +## Способ 2 - перезагрузка через telnet +У модифицированных прошивок есть telnet, через него можно перезагрузить модем. + +Если nc полноценный: + + echo reboot | nc -w 1 -i 1 192.168.8.1 23 + +Если нет: + + (echo reboot; sleep 1) | nc 192.168.8.1 23 & (sleep 1; kill `pidof $(ps | grep 'nc 192.168.8.1 23' | grep -v 'grep')`) + +## Способ 3 - перезагрузка через adb +У adb есть два способа перезагрузки: + + 1. `adb reboot` + 2. `adb shell reboot` + +## Способ 4 - AT-команды +Вот оно! Единственный нормальный способ! +И так, нам понадобится лишь gcom, модифицированная прошивка для вашего модема (необязательно, зависит от модели) и скрипт в этом репозитории. +Ну что ж, поехали! + +Сначала пропишем открытие порта PC UI. Для этого любым удобным способом открываем порты и вводим в порт PC UI вашим любимым терминалом: + +`AT^NVWREX=50091,0,60,01 00 00 00 A1 A2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A3 A2 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00` + +А теперь самое интересное - команды для перезапуска модема с роутера. + + 1. `COMMAND=AT^RESET gcom -d $device -s /etc/gcom/runcommand.gcom` + 2. `COMMAND=AT+CFUN=1,1 gcom -d $device -s /etc/gcom/runcommand.gcom` + +Выбирайте любую понравившуюся. Первая комнада чисто хуавеевская. Где $device - путь до командного порта. Скорее всего это будет /dev/ttyUSB0. В стике всегда несколько портов, обычно это самый старший. У меня это /dev/ttyUSB2. + +И да, для вас наверняка осталось не понятным, когда нужна модифицированная прошивка. Очень просто! Она нужна тогда, когда на вашей прошивке заблокированно выполнение кодман ^NVWREX и ^NVRDEX. Узнать об этом можно в теме своего модема на 4PDA. + +## Способ 5 - usbreset +`usbreset "Имя устройства"` + +## Способ 6 - реконнект средствами OpenWrt +Подходит только для стика, увы + +`/etc/init.d/network restart` + +## Способ 7 - установка скрипта перезапуска прямо в модема +Пожалуй, идеальный вариант для HiLink! + +Все, что нужно, вы найдете в архиве yotahilink.zip + +Там есть скрипты для установки как под Windows, так и под Linux. + +# Фикс TTL +Здесь приложена служба для фиксации TTL. + diff --git a/ban.sh b/ban.sh deleted file mode 100644 index bc0952c..0000000 --- a/ban.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -#wget -O - http://cdn.rawgit.com/TTLMaster/yota-ban-list/master/list.txt | while read -r i; do -wget -O - https://raw.githubusercontent.com/TTLMaster/yota-ban-list/master/list.txt | while read -r i; do - [ "`echo $i | sed -n '/^#.*$/p'`" ] && continue - iptables -I FORWARD --destination $i -j REJECT; -done -/etc/init.d/dnsmasq restart diff --git a/files-ban-nossl/etc/hotplug.d/iface/99-yotaban b/files-ban-nossl/etc/hotplug.d/iface/99-yotaban new file mode 100644 index 0000000..97a42a3 --- /dev/null +++ b/files-ban-nossl/etc/hotplug.d/iface/99-yotaban @@ -0,0 +1,15 @@ +#!/bin/sh + +[ "$ACTION" = ifup ] || exit 0 +[ "`ps w | grep 'wget -O - http://cdn.rawgit.com/TTLMaster/yota-ban-list/master/list.txt' | grep -v 'grep'`" ] && exit 0 +/etc/init.d/yotaban enabled || exit 0 + +# remove old records +iptables -F yotaban + +# update and add new records +wget -O - http://cdn.rawgit.com/TTLMaster/yota-ban-list/master/list.txt | \ +while read -r i; do + [ "`echo $i | sed -n '/^#.*$/p'`" ] && continue + iptables -A yotaban -d $i -j DROP +done diff --git a/files-ban-nossl/etc/init.d/yotaban b/files-ban-nossl/etc/init.d/yotaban new file mode 100755 index 0000000..ec08139 --- /dev/null +++ b/files-ban-nossl/etc/init.d/yotaban @@ -0,0 +1,14 @@ +#!/bin/sh /etc/rc.common + +START=99 + +start() { + iptables -N yotaban + iptables -A FORWARD -j yotaban +} + +stop() { + iptables -D FORWARD -j yotaban + iptables -F yotaban + iptables -X yotaban +} diff --git a/files-ban/etc/hotplug.d/iface/99-yotaban b/files-ban/etc/hotplug.d/iface/99-yotaban new file mode 100644 index 0000000..ae1cdcb --- /dev/null +++ b/files-ban/etc/hotplug.d/iface/99-yotaban @@ -0,0 +1,15 @@ +#!/bin/sh + +[ "$ACTION" = ifup ] || exit 0 +[ "`ps w | grep 'wget -O - https://raw.githubusercontent.com/TTLMaster/yota-ban-list/master/list.txt' | grep -v 'grep'`" ] && exit 0 +/etc/init.d/yotaban enabled || exit 0 + +# remove old records +iptables -F yotaban + +# update and add new records +wget -O - https://raw.githubusercontent.com/TTLMaster/yota-ban-list/master/list.txt | \ +while read -r i; do + [ "`echo $i | sed -n '/^#.*$/p'`" ] && continue + iptables -A yotaban -d $i -j DROP +done diff --git a/files-ban/etc/init.d/yotaban b/files-ban/etc/init.d/yotaban new file mode 100755 index 0000000..ec08139 --- /dev/null +++ b/files-ban/etc/init.d/yotaban @@ -0,0 +1,14 @@ +#!/bin/sh /etc/rc.common + +START=99 + +start() { + iptables -N yotaban + iptables -A FORWARD -j yotaban +} + +stop() { + iptables -D FORWARD -j yotaban + iptables -F yotaban + iptables -X yotaban +} diff --git a/files-reboot/etc/init.d/yotareboot b/files-reboot/etc/init.d/yotareboot new file mode 100755 index 0000000..6b985b6 --- /dev/null +++ b/files-reboot/etc/init.d/yotareboot @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common + +START=99 +USE_PROCD=1 + +start_service() { + procd_open_instance + procd_set_param command /sbin/yotareboot + procd_set_param respawn + procd_close_instance +} diff --git a/files-reboot/sbin/yotareboot b/files-reboot/sbin/yotareboot new file mode 100755 index 0000000..b822e38 --- /dev/null +++ b/files-reboot/sbin/yotareboot @@ -0,0 +1,101 @@ +#!/bin/sh +ttysearch() { + for d in $(ls /dev/ttyUSB* /dev/cdc-wdm* /dev/ttyACM* /dev/ttyHS* | sort -r); do + DEVICE=$d gcom -s /usr/share/yota/gcom/probeport.gcom + if [ $? = 0 ]; then + ttydevice=$d + break + fi + done +} + +while true; do + method="`uci -q get yota.@reboot[0].method`" + hiip="`uci -q get yota.@reboot[0].hiip`" + telip="`uci -q get yota.@reboot[0].telip`" + telport="`uci -q get yota.@reboot[0].telport`" + adbip="`uci -q get yota.@reboot[0].adbip`" + adbport="`uci -q get yota.@reboot[0].adbport`" + ttydevice="`uci -q get yota.@reboot[0].ttydevice`" + usbreset="`uci -q get yota.@reboot[0].usbreset`" + if wget captive.apple.com -q -O - | grep -q 'tethering.svg'; then + case $method in + reboot) + reboot + ;; + hiconn) + # заготовка для реконнекта через HiLink API + # + # + # нужно из /api/webserver/SesTokInfo взять SesInfo и TokInfo + # SesInfo передаем как кукис + # TokInfo как хидер __RequestVerificationToken + # + # посылкаем два запроса: + # 0 + # на + # /api/dialup/mobile-dataswitch + # для дисконнекта + # + # и далее + # 1 + # на + # /api/dialup/mobile-dataswitch + # для коннекта + ;; + hireb) + # заготовка для ребута через HiLink API + # + # + # нужно из /api/webserver/SesTokInfo взять SesInfo и TokInfo + # SesInfo передаем как кукис + # TokInfo как хидер __RequestVerificationToken + # + # посылкаем запрос: + # 1 + # на + # /api/device/control + ;; + telnetreboot) + [ "$telip" -a "$telport" ] && (echo reboot; sleep 1) | nc $telip $telport & (sleep 1; kill `ps w | grep "nc $telip $telport" | grep -v 'grep' | awk '{print $1}'`) + ;; + telnetatreset) + [ "$telip" -a "$telport" ] && (echo "echo -e 'AT^RESET\r' > /dev/appvcom"; sleep 1) | nc $telip $telport & (sleep 1; kill `ps w | grep "nc $telip $telport" | grep -v 'grep' | awk '{print $1}'`) + ;; + telnetatcfun) + [ "$telip" -a "$telport" ] && (echo "echo -e 'AT+CFUN=1,1\r' > /dev/appvcom"; sleep 1) | nc $telip $telport & (sleep 1; kill `ps w | grep "nc $telip $telport" | grep -v 'grep' | awk '{print $1}'`) + ;; + adbreboot) + [ "$adbip" -a "$adbport" ] && adb connect $adbip:$adport + adb reboot + ;; + adbshellreboot) + [ "$adbip" -a "$adbport" ] && adb connect $adbip:$adport + adb shell reboot + ;; + adbatreset) + [ "$adbip" -a "$adbport" ] && adb connect $adbip:$adport + adb shell "echo -e 'AT^RESET\r' > /dev/appvcom" + ;; + adbatcfun) + [ "$adbip" -a "$adbport" ] && adb connect $adbip:$adport + adb shell "echo -e 'AT+CFUN=1,1\r' > /dev/appvcom" + ;; + atreset) + [ "$ttydevice" ] || ttysearch + COMMAND=AT^RESET gcom -d $ttydevice -s /usr/share/yota/gcom/runcommand.gcom + ;; + atcfun) + [ "$ttydevice" ] || ttysearch + COMMAND=AT+CFUN=1,1 gcom -d $ttydevice -s /usr/share/yota/gcom/runcommand.gcom + ;; + usbreset) + [ "$usbreset" ] && usbreset "$usbreset" + ;; + network) + /etc/init.d/network restart + ;; + esac + fi + sleep 10 +done diff --git a/files/etc/config/yota b/files/etc/config/yota new file mode 100644 index 0000000..083e418 --- /dev/null +++ b/files/etc/config/yota @@ -0,0 +1,12 @@ +config 'ttl' + option 'value' '64' + option 'mode' 'set' +config 'reboot' + option 'method' 'reboot' + option 'hiip' '192.168.8.1' + option 'telip' '192.168.8.1' + option 'telport' '23' + option 'adbip' '192.168.8.1' + option 'adbport' '5555' + option 'ttydevice' '' + option 'usbreset' 'HUAWEI Mobile' diff --git a/files/etc/init.d/yotattl b/files/etc/init.d/yotattl new file mode 100755 index 0000000..7668950 --- /dev/null +++ b/files/etc/init.d/yotattl @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common + +START=19 +VALUE="`uci -q get yota.@ttl[0].value`" +MODE="`uci -q get yota.@ttl[0].mode`" + +start() { + iptables -t mangle -N yotattl + iptables -t mangle -A POSTROUTING -j yotattl + iptables -t mangle -A yotattl -j TTL --ttl-$MODE $VALUE +} + +stop() { + iptables -t mangle -D POSTROUTING -j yotattl + iptables -t mangle -F yotattl + iptables -t mangle -X yotattl +} diff --git a/files/usr/share/yota/gcom/probeport.gcom b/files/usr/share/yota/gcom/probeport.gcom new file mode 100644 index 0000000..cbbc175 --- /dev/null +++ b/files/usr/share/yota/gcom/probeport.gcom @@ -0,0 +1,14 @@ +let $d = $env("DEVICE") +if $d = "" goto timeout + +open com $d +set com 57600n81 +set senddelay 0.05 +waitquiet 2 0.5 +send "AT^m" +waitfor 2 "OK" +if % = -1 goto timeout +exit 0 + +:timeout + exit 1 diff --git a/files/usr/share/yota/gcom/runcommand.gcom b/files/usr/share/yota/gcom/runcommand.gcom new file mode 100644 index 0000000..e99b6f9 --- /dev/null +++ b/files/usr/share/yota/gcom/runcommand.gcom @@ -0,0 +1,31 @@ +# run AT-command from environment +opengt + set com 115200n81 + set senddelay 0.02 + waitquiet 1 0.2 + flash 0.1 + +:start + print "sending -> ",$env("COMMAND"),"\n" + send $env("COMMAND") + send "^m" + + waitfor 15 "OK","ERR","ERROR","COMMAND NOT SUPPORT" + if % = 0 goto continue + if % = 1 goto error + if % = 2 goto error + if % = 3 goto notsupported + + print "Timeout running AT-command\n" + exit 1 + +:error + print "Error running AT-command\n" + exit 1 + +:notsupported + print "AT-command not supported\n" + exit 1 + +:continue + exit 0 diff --git a/yotareboot.sh b/yotareboot.sh deleted file mode 100644 index 79dcb8b..0000000 --- a/yotareboot.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -for i in 1 2 3 4 5 -do - content=$(wget captive.apple.com -q -O -) - if [ `echo $content | grep -c "tethering.svg" ` -gt 0 ] - then - usbreset "HUAWEI Mobile" - fi - sleep 10 -done -