forked from jwise/HoRNDIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_kext.command
executable file
·58 lines (43 loc) · 1.38 KB
/
test_kext.command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Variables
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )";SOURCE="$(readlink "$SOURCE")";[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"; done
CURDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
DESTDIR="/tmp/HoRNDIS";
# Get sudo
if [ -z $(sudo echo "gotsudo") ]; then echo "Could not get super-user permissions"; exit -1; fi
# Copy KEXT to tmp
echo "Copying...";
if [ -d $DESTDIR ]; then sudo rm -r $DESTDIR; fi
sudo mkdir $DESTDIR;
sudo cp -r $CURDIR/HoRNDIS* $DESTDIR/; #Copies all files beginning with HoRNDIS…
sudo chmod -R 0700 $DESTDIR;
sudo chown -R root:wheel $DESTDIR;
# Load KEXT
KEXTFILES=();
while read -r -d $'\0'; do KEXTFILES+=("$REPLY"); done < <(sudo find $DESTDIR -iname "*.kext" -maxdepth 1 -print0);
if [ ${#KEXTFILES[@]} -gt 1 ]; then
# Ask user which kext to take
NUM_KEXTS=${#KEXTFILES[@]};
for (( i=0; i < $NUM_KEXTS; i++ )); do
echo "$i: ${KEXTFILES[$i]}";
done
KEXTNUM=-1;
while [ $KEXTNUM -lt 0 ] || [ $KEXTNUM -ge $NUM_KEXTS ]; do read -p "Which file?: " KEXTNUM; done
# Got file
KEXTFILE=${KEXTFILES[$KEXTNUM]};
else
KEXTFILE=${KEXTFILES[0]};
fi
if [ -n "$KEXTFILE" ]; then
# Load KEXT if found
echo "Loading \"$KEXTFILE\"...";
sudo kextload -t "$KEXTFILE";
echo "Loaded:";
echo $(kextstat | grep HoRNDIS);
exit 0;
else
# No KEXT found
echo 'No KEXTFILE found.';
exit 1;
fi