mirror of
https://github.com/xchwarze/wifi-pineapple-cloner.git
synced 2025-01-22 11:28:59 +00:00
Fix fs-patcher.sh bugs
This commit is contained in:
parent
d1eab247f1
commit
0dbeb3ea50
168
files/common/lib/mac80211.sh
Normal file
168
files/common/lib/mac80211.sh
Normal file
@ -0,0 +1,168 @@
|
||||
#!/bin/sh
|
||||
append DRIVERS "mac80211"
|
||||
|
||||
lookup_phy() {
|
||||
[ -n "$phy" ] && {
|
||||
[ -d /sys/class/ieee80211/$phy ] && return
|
||||
}
|
||||
|
||||
local devpath
|
||||
config_get devpath "$device" path
|
||||
[ -n "$devpath" ] && {
|
||||
for _phy in /sys/devices/$devpath/ieee80211/phy*; do
|
||||
[ -e "$_phy" ] && {
|
||||
phy="${_phy##*/}"
|
||||
return
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
|
||||
[ -n "$macaddr" ] && {
|
||||
for _phy in /sys/class/ieee80211/*; do
|
||||
[ -e "$_phy" ] || continue
|
||||
|
||||
[ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
|
||||
phy="${_phy##*/}"
|
||||
return
|
||||
done
|
||||
}
|
||||
phy=
|
||||
return
|
||||
}
|
||||
|
||||
find_mac80211_phy() {
|
||||
local device="$1"
|
||||
|
||||
config_get phy "$device" phy
|
||||
lookup_phy
|
||||
[ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
|
||||
echo "PHY for wifi device $1 not found"
|
||||
return 1
|
||||
}
|
||||
config_set "$device" phy "$phy"
|
||||
|
||||
config_get macaddr "$device" macaddr
|
||||
[ -z "$macaddr" ] && {
|
||||
config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_mac80211_device() {
|
||||
config_get phy "$1" phy
|
||||
[ -z "$phy" ] && {
|
||||
find_mac80211_phy "$1" >/dev/null || return 0
|
||||
config_get phy "$1" phy
|
||||
}
|
||||
[ "$phy" = "$dev" ] && found=1
|
||||
}
|
||||
|
||||
detect_mac80211() {
|
||||
devidx=0
|
||||
config_load wireless
|
||||
while :; do
|
||||
config_get type "radio$devidx" type
|
||||
[ -n "$type" ] || break
|
||||
devidx=$(($devidx + 1))
|
||||
done
|
||||
|
||||
for _dev in /sys/class/ieee80211/*; do
|
||||
[ -e "$_dev" ] || continue
|
||||
|
||||
dev="${_dev##*/}"
|
||||
|
||||
found=0
|
||||
config_foreach check_mac80211_device wifi-device
|
||||
[ "$found" -gt 0 ] && continue
|
||||
|
||||
mode_band="g"
|
||||
channel="11"
|
||||
htmode=""
|
||||
ht_capab=""
|
||||
|
||||
iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
|
||||
iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
|
||||
|
||||
vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
|
||||
cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
|
||||
[ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
|
||||
mode_band="a";
|
||||
channel="36"
|
||||
htmode="VHT80"
|
||||
}
|
||||
|
||||
[ -n $htmode ] && append ht_capab " option htmode $htmode" "$N"
|
||||
|
||||
if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then
|
||||
path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
|
||||
else
|
||||
path=""
|
||||
fi
|
||||
if [ -n "$path" ]; then
|
||||
path="${path##/sys/devices/}"
|
||||
dev_id=" option path '$path'"
|
||||
else
|
||||
dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
config wifi-device radio$devidx
|
||||
option type mac80211
|
||||
option channel ${channel}
|
||||
option hwmode 11${mode_band}
|
||||
$dev_id
|
||||
$ht_capab
|
||||
config wifi-iface
|
||||
option device radio$devidx
|
||||
$(if [ $devidx -gt 0 ]; then
|
||||
echo -e "\toption ifname wlan$devidx";
|
||||
fi)
|
||||
option network lan
|
||||
option mode $(if [[ "$devidx" == "0" ]] ; then echo ap ; else echo sta ; fi)
|
||||
option ssid Pineapple_$(cat /sys/class/ieee80211/${dev}/macaddress|awk -F ":" '{print $5""$6 }'| tr a-z A-Z)
|
||||
$(if [ $devidx -eq 0 ]; then
|
||||
echo -e "\toption ifname wlan0";
|
||||
echo -e "\toption maxassoc 100";
|
||||
fi)
|
||||
option encryption none
|
||||
$(if [[ "$devidx" == "0" ]]; then
|
||||
echo config wifi-iface
|
||||
|
||||
echo -e "\toption device radio$devidx";
|
||||
echo -e "\toption ifname wlan0-1";
|
||||
echo -e "\toption network lan";
|
||||
echo -e "\toption mode ap";
|
||||
echo -e "\toption ssid Management";
|
||||
echo -e "\toption encryption psk2+ccmp";
|
||||
echo -e "\toption key 'pineapplesareyummy'";
|
||||
echo -e "\toption disabled 1";
|
||||
|
||||
echo config wifi-iface
|
||||
echo -e "\toption device radio$devidx";
|
||||
echo -e "\toption ifname wlan0-2";
|
||||
echo -e "\toption network lan";
|
||||
echo -e "\toption mode ap";
|
||||
echo -e "\toption ssid PineAP_Enterprise";
|
||||
echo -e "\toption macaddr 00:11:22:33:44:55";
|
||||
echo -e "\toption encryption wpa2+ccmp";
|
||||
echo -e "\toption key 12345678";
|
||||
echo -e "\toption server 127.0.0.1";
|
||||
echo -e "\toption disabled 1";
|
||||
fi)
|
||||
|
||||
$(if [[ "$devidx" == "2" ]]; then
|
||||
echo config wifi-iface
|
||||
|
||||
echo -e "\toption device radio$devidx";
|
||||
echo -e "\toption ifname wlan2";
|
||||
echo -e "\toption network lan";
|
||||
echo -e "\toption mode sta";
|
||||
echo -e "\toption disabled 0";
|
||||
fi)
|
||||
EOF
|
||||
devidx=$(($devidx + 1))
|
||||
done
|
||||
}
|
||||
|
@ -153,19 +153,23 @@ common_patch () {
|
||||
# patch elf files
|
||||
if [[ "$ARCHITECTURE" == "mips" ]]; then
|
||||
xxd "$ROOT_FS/usr/bin/pineap" "$ROOT_FS/usr/bin/pineap.hex"
|
||||
rm "$ROOT_FS/usr/bin/pineap"
|
||||
sed -i 's/6361 7420 2f70 726f 632f 636d 646c 696e/6563 686f 2027 5049 4e45 4150 504c 452d/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
sed -i 's/6520 7c20 6177 6b20 277b 2073 706c 6974/5445 5452 4127 2020 2020 2020 2020 2020/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
sed -i 's/2824 312c 782c 223d 2229 3b20 7072 696e/2020 2020 2020 2020 2020 2020 2020 2020/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
sed -i 's/7420 785b 325d 207d 2700 0000 5749 4649/2020 2020 2020 2020 2000 0000 5749 4649/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
sed -i 's/6420 7379 6e74 6178 2065 6e61 626c 6564/6420 5B57 5043 2056 4552 5349 4F4E 5D20/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
xxd -r "$ROOT_FS/usr/bin/pineap.hex" "$ROOT_FS/usr/bin/pineap"
|
||||
rm "$ROOT_FS/usr/bin/pineap.hex"
|
||||
|
||||
xxd "$ROOT_FS/usr/sbin/pineapd" "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
rm "$ROOT_FS/usr/bin/pineap"
|
||||
sed -i 's/6361 7420 2f70 726f 632f 636d 646c 696e/6563 686f 2027 5049 4e45 4150 504c 452d/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/6520 7c20 6177 6b20 277b 2073 706c 6974/5445 5452 4127 2020 2020 2020 2020 2020/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/2824 312c 782c 223d 2229 3b20 7072 696e/2020 2020 2020 2020 2020 2020 2020 2020/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/7420 785b 325d 207d 2700 0000 5749 4649/2020 2020 2020 2020 2000 0000 5749 4649/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
xxd -r "$ROOT_FS/usr/sbin/pineapd.hex" "$ROOT_FS/usr/sbin/pineapd"
|
||||
rm "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -190,7 +194,14 @@ mipsel_patch () {
|
||||
mv "$ROOT_FS/usr/sbin/sniffer" "$ROOT_FS/usr/sbin/http_sniffer"
|
||||
|
||||
# patch elf files
|
||||
xxd "$ROOT_FS/usr/bin/pineap" "$ROOT_FS/usr/bin/pineap.hex"
|
||||
rm "$ROOT_FS/usr/bin/pineap"
|
||||
sed -i 's/6420 7379 6e74 6178 2065 6e61 626c 6564/6420 5B57 5043 2056 4552 5349 4F4E 5D20/' "$ROOT_FS/usr/bin/pineap.hex"
|
||||
xxd -r "$ROOT_FS/usr/bin/pineap.hex" "$ROOT_FS/usr/bin/pineap"
|
||||
rm "$ROOT_FS/usr/bin/pineap.hex"
|
||||
|
||||
xxd "$ROOT_FS/usr/sbin/pineapd" "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
rm "$ROOT_FS/usr/sbin/pineapd"
|
||||
sed -i 's/3030 3a30 3000 0000 202d 2000 6865 6164/3030 3a30 3000 0000 202d 2000 6563 686f/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/202d 6e32 202f 7072 6f63 2f63 7075 696e/2027 4861 6b35 2057 6946 6920 5069 6e65/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/666f 207c 2074 6169 6c20 2d6e 2031 207c/6170 706c 6520 4d61 726b 2037 2720 2020/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
@ -205,6 +216,7 @@ mipsel_patch () {
|
||||
sed -i 's/2074 6169 6c20 2d6e 2031 207c 2061 776b/2020 2020 2020 2020 2020 2020 2020 2020/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
sed -i 's/2027 7b70 7269 6e74 2824 3329 7d27 0000/2020 2020 2020 2020 2020 2020 2020 0000/' "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
xxd -r "$ROOT_FS/usr/sbin/pineapd.hex" "$ROOT_FS/usr/sbin/pineapd"
|
||||
rm "$ROOT_FS/usr/sbin/pineapd.hex"
|
||||
}
|
||||
|
||||
nano_patch () {
|
||||
|
Loading…
Reference in New Issue
Block a user