Jump to content

Software Lag Switch for Rooted Android


Wiffzack
 Share

Recommended Posts

The script consists of 2 parts, a server script for Android in Bash and a client script for Windows in AutoIT.

 

The script sends commands to the mobil phone using netcat.
The script uses Traffic Control (TC) to limit the upload to 5 KByte which should cause lags.

 

 

AutoIT Script on Windows:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Download.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
AutoItSetOption("WinTitleMatchMode", 4)

HotKeySet("q", "on")
HotKeySet("e", "off")
HotKeySet("x", "Quit")

While 1
    Sleep(100)
WEnd

Func on()
;Run('ncat 192.168.43.1 80')
Run("ncat 192.168.43.1 80", "", @SW_HIDE)
ProcessWait("ncat.exe")
Local $hwnd = WinGetHandle("[REGEXPTITLE:(?i)(.*ncat.*|.*ncat.*)]")
;WinWaitActive("ncat.exe", "", 1)
ControlSend($hwnd, "", "", "on{Enter}")
Sleep(50)
ProcessClose("ncat.exe")

EndFunc   ;==>on

Func off()
Run("ncat 192.168.43.1 80", "", @SW_HIDE)
ProcessWait("ncat.exe")
Local $hwnd = WinGetHandle("[REGEXPTITLE:(?i)(.*ncat.*|.*ncat.*)]")
ControlSend($hwnd, "", "", "off{Enter}")
Sleep(50)
ProcessClose("ncat.exe")
EndFunc   ;==>off

Func Quit()
    Exit
EndFunc   ;==>Quit

Bash Script on Android:

#!/system/bin/sh
#if [ -n "$readt" ]

iptables -F
iptables -A INPUT -i wlan0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i wlan0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

on='on';
off='off';

while :
do
nc -l 192.168.43.1:80 > /sdcard/Scripts/nc.log
readt=$(cat /sdcard/Scripts/nc.log | awk '{print $1}')
if [ "$readt" == "$on" ]; then
echo "lag on"
tc qdisc add dev rmnet0 handle 1: root htb default 11 
tc class add dev rmnet0 parent 1: classid 1:1 htb rate 10kbps
tc class add dev rmnet0 parent 1:1 classid 1:11 htb rate 10kbps
> /sdcard/Scripts/nc.log
else
if [ "$readt" == "$off" ]; then
echo "lag off"
tc qdisc del dev rmnet0 root
> /sdcard/Scripts/nc.log
fi
fi
done

 

Link to comment
Share on other sites

Hi Wiffzack, welcome to the forum. :)

Are you asking a question, for I don't see it?

Or are you posting this for the benefit of others?

If the latter, then you probably should have posted it in the Examples section of the forum, as this is purely for Discussions about Developing. If this is the case, then Report your topic and ask for it to be relocated to Examples.

Similar scenario if you are after Help, as it should be in GH&S in that case.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...