-
Notifications
You must be signed in to change notification settings - Fork 38
/
kali-linux-region-BO-wifi-txpower-unlocker.sh
executable file
·86 lines (69 loc) · 3.71 KB
/
kali-linux-region-BO-wifi-txpower-unlocker.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#title: kali-linux-region-BO-wifi-txpower-unlocker.sh
#description: Unlocks the wifi txpower of the 2.4Ghz band of the BO region
#author: Hiruna Wijesinghe https://github.com/hiruna/wifi-txpower-unlocker/
#date: 13/05/2017
#change the value to the tx power (dBm) you like
txpower=25 #I set it to 33 as 33dBm ~ 2W
set -e #Exit if any line fails
#Update and updrade
apt-get --yes update
apt-get --yes upgrade
#Download dependencies
apt-get --yes install pkg-config libnl-3-dev libgcrypt11-dev libnl-genl-3-dev build-essential
#Download latest CRDA and Wireless Regulatory DB
latestCRDA=$(curl -L 'https://www.kernel.org/pub/software/network/crda/' | grep -oP 'href="crda-\K[0-9]+\.[0-9]+' | sort -t. -rn -k1,1 -k2,2 -k3,3 | head -1)
latestWRDB=$(curl -L 'https://www.kernel.org/pub/software/network/wireless-regdb/' | grep -oP 'href="wireless-regdb-\K[0-9]+\.[0-9]+\.[0-9]+' | sort -t. -rn -k1,1 -k2,2 -k3,3 | head -1)
wget "https://www.kernel.org/pub/software/network/crda/crda-${latestCRDA}.tar.xz"
wget "https://www.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-${latestWRDB}.tar.xz"
#Unzip the downloaded files
tar xvJf crda-${latestCRDA}.tar.xz
tar xvJf wireless-regdb-${latestWRDB}.tar.xz
#inset txpower in db.txt
sed -i -e 's/(5250 - 5350 @ 80), (30)/(5250 - 5350 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(5470 - 5725 @ 160), (30)/(5470 - 5725 @ 160), ('$txpower')/g' db.txt
sed -i -e 's/(5725 - 5875 @ 80), (30)/(5725 - 5875 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(2402 - 2482 @ 40), (30)/(2402 - 2482 @ 40), ('$txpower')/g' db.txt
sed -i -e 's/(5170 - 5250 @ 80), (30)/(5170 - 5250 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(5250 - 5330 @ 80), (30)/(5250 - 5330 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(5490 - 5710 @ 160), (30)/(5490 - 5710 @ 160), ('$txpower')/g' db.txt
sed -i -e 's/(5170 - 5250 @ 80), (30)/(5170 - 5250 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(5250 - 5330 @ 80), (30)/(5250 - 5330 @ 80), ('$txpower')/g' db.txt
sed -i -e 's/(5490 - 5730 @ 160), (30)/(5490 - 5730 @ 160), ('$txpower')/g' db.txt
sed -i -e 's/(2400 - 2494 @ 40), (30)/(2400 - 2494 @ 40), ('$txpower')/g' db.txt
sed -i -e 's/(4910 - 5835 @ 40), (30)/(4910 - 5835 @ 40), ('$txpower')/g' db.txt
#copy modified db.txt
cp db.txt wireless-regdb-${latestWRDB}/db.txt
#compile regulatory.db
make -C wireless-regdb-${latestWRDB}
#backup the old regulatory.bin and move the new file into /lib/crda
mv /lib/crda/regulatory.bin /lib/crda/regulatory.bin.old
mv wireless-regdb-${latestWRDB}/regulatory.bin /lib/crda
#copy pubkeys
cp wireless-regdb-${latestWRDB}/*.pem crda-${latestCRDA}/pubkeys
#if the extra pubkeys exist, copy them too
if [ -e /lib/crda/pubkeys/benh\@debian.org.key.pub.pem ] ; then
cp /lib/crda/pubkeys/benh\@debian.org.key.pub.pem crda-${latestCRDA}/pubkeys
fi
if [ -e /lib/crda/pubkeys/linville.key.pub.pem ] ; then
cp /lib/crda/pubkeys/linville.key.pub.pem crda-${latestCRDA}/pubkeys
fi
#change regulatory.bin path in the Makefile
sed -i "/REG_BIN?=\/usr\/lib\/crda\/regulatory.bin/!b;cREG_BIN?=\/lib\/crda\/regulatory.bin" crda-${latestCRDA}/Makefile
#remove -Werror option when compiling
sed -i "/CFLAGS += -std=gnu99 -Wall -Werror -pedantic/!b;cCFLAGS += -std=gnu99 -Wall -pedantic" crda-${latestCRDA}/Makefile
#compile
make clean -C crda-${latestCRDA}
make -C crda-${latestCRDA}
make install -C crda-${latestCRDA}
#reboot
printf "A system reboot is required to apply changes. Do you want to reboot now ? [Yes,No,Y,N]:"
read -r reboot
if [ ${reboot,,} == "y" ] || [ ${reboot,,} == "yes" ] ; then
echo "Rebooting..."
reboot
elif [ ${reboot,,} == "n" ] || [ ${reboot,,} == "no" ] ; then
echo "You chose not to reboot. Please reboot the system manually."
else
echo "Invalid option. Please reboot the system manually."
fi