Last active
December 22, 2018 23:03
-
-
Save DanTheMan827/08cf57df258d5a53f94e04b2b63e0a27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Copyright 2018 madmonkey | |
# Copyright 2018 DanTheMan827 | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. | |
CONFIGFS="/sys/class/android_usb/android0" | |
modname="lolhack" | |
setSysNode(){ | |
echo "$2" > "$1" | |
} | |
getMac(){ | |
local macfile="/data/rndis-mac-address" | |
if [ ! -f "$macfile" ]; then | |
dd if=/dev/urandom bs=6 count=1 2>/dev/null | hexdump -e '6/1 "%02x"' > "$macfile" | |
sync &>/dev/null | |
fi | |
cat "$macfile" | |
} | |
start(){ | |
setSysNode "$CONFIGFS/enable" 0 | |
setSysNode "$CONFIGFS/functions" rndis | |
setSysNode "$CONFIGFS/iManufacturer" "$modname" | |
setSysNode "$CONFIGFS/iProduct" classic | |
setSysNode "$CONFIGFS/iSerial" "$(getMac)" | |
setSysNode "$CONFIGFS/f_rndis/manufacturer" "$modname" | |
setSysNode "$CONFIGFS/f_rndis/vendorID" 057e | |
setSysNode "$CONFIGFS/f_rndis/wceis" 1 | |
setSysNode "$CONFIGFS/idVendor" 04e8 | |
setSysNode "$CONFIGFS/idProduct" 6863 | |
setSysNode "$CONFIGFS/bDeviceClass" 224 | |
setSysNode "$CONFIGFS/enable" 1 | |
sleep 2 | |
} | |
stop(){ | |
setSysNode "$CONFIGFS/enable" 0 | |
sleep 2 | |
} | |
restart(){ | |
stop | |
start | |
} | |
for mode in start stop restart; do | |
if [ "$1" == "$mode" ]; then | |
$mode | |
exit $? | |
fi | |
done | |
echo "$(basename "/$0") <start|stop|restart>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment