diff --git a/Makefile b/Makefile index 5563515..b933d4f 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ CONFIG_EXT_CLK = n CONFIG_TRAFFIC_PROTECT = n CONFIG_LOAD_PHY_PARA_FROM_FILE = y CONFIG_TXPWR_BY_RATE = y -CONFIG_TXPWR_BY_RATE_EN = y +CONFIG_TXPWR_BY_RATE_EN = n CONFIG_TXPWR_LIMIT = y CONFIG_TXPWR_LIMIT_EN = n CONFIG_RTW_CHPLAN = 0xFF diff --git a/README.md b/README.md index afe6c9c..52dd81d 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,6 @@ and post in `Discussions` or `Issues`. - x86, amd64 - ARM, ARM64 -- MIPS ### Compatible Kernels @@ -374,6 +373,10 @@ Note: For automated builds, use _NoPrompt_ as an option. sudo ./install-driver.sh ``` +Note: If you elect to skip the reboot at the end of the installation +script, the driver may not load immediately and the driver options will +not be applied. Rebooting is strongly recommended. + Note: Solus Linux does not support dkms and will require a manual build. See `Manual build instructions` below. @@ -391,10 +394,6 @@ sudo reboot Note: If you use the manual build instructions, you will need to repeat the process each time a new kernel is installed in your distro. -Note: If you elect to skip the reboot at the end of the installation -script, the driver may not load immediately and the driver options will -not be applied. Rebooting is strongly recommended. - ----- ### Driver Options ( edit-options.sh ) diff --git a/docs/Monitor_Mode.md b/docs/Monitor_Mode.md index 7067c7a..3ccf539 100644 --- a/docs/Monitor_Mode.md +++ b/docs/Monitor_Mode.md @@ -1,6 +1,6 @@ ----- -2021-12-18 +2022-01-25 ## Monitor Mode @@ -10,12 +10,14 @@ mode with the following Realtek drivers: ``` https://github.com/morrownr/8812au-20210629 https://github.com/morrownr/8821au-20210708 +https://github.com/morrownr/8821cu-20210118 https://github.com/morrownr/88x2bu-20210702 +https://github.com/morrownr/8814au ``` - -For adapters that use in-kernel drivers, use any of the many guides that -are available as the in-kernel drivers work in the textbook, standards -compliant manner. +Note: This document and the `start-mon.sh` script will work with +adapters that use in-kernel drivers but it is not necessary as the use +of any of the many guides that are available should work fine as the +in-kernel drivers work in the textbook, standards compliant manner. Please submit corrections or additions via Issues. @@ -30,7 +32,7 @@ adapters can operate in: Master (acting as an access point), Managed (client, also known as station), Ad hoc, Repeater, Mesh, Wi-Fi Direct, TDLS and Monitor mode. -Note: This document and the `test-mon.sh` script have been tested on the +Note: This document and the `start-mon.sh` script have been tested on the following: ``` @@ -41,7 +43,7 @@ Ubuntu ``` ----- -## Steps to test monitor mode +## Steps to start/test monitor mode #### Install USB WiFi adapter and driver per instructions. @@ -63,9 +65,9 @@ sudo rfkill unblock wlan ----- -#### Install the aircrack-ng and wireshark packages +#### Install aircrack-ng (optional) ``` -sudo apt install -y aircrack-ng wireshark +sudo apt install -y aircrack-ng ``` ----- @@ -87,33 +89,56 @@ document. #### Enter and check monitor mode -A script called `test-mon.sh` is available in the driver directory. -It will automate much of the following. It is a work in progress so -please feel free to make and submit improvements. It is written in Bash. +A script called `start-mon.sh` is available in the driver directory. +It will automate much of the following. Usage: ``` -sudo ./test-mon.sh [interface:wlan0] +sudo ./start-mon.sh [interface:wlan0] ``` Note: If you want to do things manually, continue below. ----- -#### Disable interfering processes +#### Disable interfering processes (see note about `start-mon.sh` below) ``` sudo airmon-ng check kill ``` +Note: `start-mon.sh` is capable of disabling interfering processes. It +uses a different method than airmon-ng. Airmon-ng kills the processes +whereas `start-mon.sh` simply stops the processes and restarts them +when the script terminates. Stopping the processes seems to have some +advantages over killing them. + +Advantage 1: When killing the very clever interfering processes, you may +find that interfering processes are able to spawn new processes that will +continue to interfer. Stopping the interfering processes does not seem to +trigger the spawning of new processes. + +Advantage 2: If you use more than one wifi adapter/card in the system, +and if you need one of the adapter/cards to stay connected to the +internet, killing the processes may cause your internet connection to +drop. Stopping the processes does not cause your internet connection to +drop. + +Advantage 3: Stopping the processes allows the processes to be restarted. +The `start-mon.sh` script can put your interface in monitor mode, +properly configured, and then return your system, including stopped +processes and interface to original settings. This can reduce reboots +that sometimes might have been needed to reset things to normal operation. + + #### Change to monitor mode Option 1 (the airmon-ng way) Note: This option may not work with some driver/adapter combinations (I'm looking at you Realtek). If this option does not work, you can -use Option 2 or the `test-mon.sh` script that was previously mentioned. +use Option 2 or the `start-mon.sh` script that was previously mentioned. ``` sudo airmon-ng start ``` diff --git a/test-mon.sh b/start-mon.sh similarity index 65% rename from test-mon.sh rename to start-mon.sh index 25a9e44..d8844ad 100755 --- a/test-mon.sh +++ b/start-mon.sh @@ -1,75 +1,46 @@ #!/bin/bash +SCRIPT_NAME="start-mon.sh" +SCRIPT_VERSION="20220125" -SCRIPT_NAME="test-mon.sh" -SCRIPT_VERSION="20211218" +# Purpose: Start and configure monitor mode on the provided interface + +# Usage: $ sudo ./start-mon.sh [interface:wlan0] + + +# Set color definitions (https://en.wikipedia.org/wiki/ANSI_escape_code) + # Black 0;30 Dark Gray 1;30 +LightRed='\033[1;31m' # Red 0;31 Light Red 1;31 +LightGreen='\033[1;32m' # Green 0;32 Light Green 1;32 +Yellow='\033[1;33m' # Brown/Orange 0;33 Yellow 1;33 + # Blue 0;34 Light Blue 1;34 + # Purple 0;35 Light Purple 1;35 +LightCyan='\033[1;36m' # Cyan 0;36 Light Cyan 1;36 + # Light Gray 0;37 White 1;37 +NoColor='\033[0m' + +clear # Check that sudo was used to start the script if [[ $EUID -ne 0 ]] then - clear - echo "You must run this script with superuser (root) privileges." - echo "Try: \"sudo ./${SCRIPT_NAME}\"" + echo -e "${LightRed}ERROR: You must run this script with superuser (root) privileges." +# echo -e "${NoColor}Try: ${LightCyan}\"sudo ./${SCRIPT_NAME}\"" + echo -e "${NoColor}Try: $ ${LightCyan}sudo ./${SCRIPT_NAME}" + echo -e "${NoColor}" exit 1 fi -# Set color definitions (https://en.wikipedia.org/wiki/ANSI_escape_code) -# Black 0;30 Dark Gray 1;30 -# Red 0;31 Light Red 1;31 -# Green 0;32 Light Green 1;32 -# Brown/Orange 0;33 Yellow 1;33 -# Blue 0;34 Light Blue 1;34 -# Purple 0;35 Light Purple 1;35 -# Cyan 0;36 Light Cyan 1;36 -# Light Gray 0;37 White 1;37 -RED='\033[1;31m' -YELLOW='\033[0;33;1m' -GREEN='\033[1;32m' -CYAN='\033[1;36m' -NoColor='\033[0m' - - -# Display docs -clear -echo -e "${GREEN}" -echo ' --------------------------------' -echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" -echo ' --------------------------------' -echo -echo ' Purpose: Test monitor mode on the provided wlan interface' -echo -echo ' Usage: $ sudo ./test-mon.sh [interface:wlan0]' -echo -echo ' Please feel free to help make this script better.' -echo -echo ' Some parts of this script require the installation of:' -echo -echo ' aircrack-ng' -echo ' wireshark' -echo -echo ' Note: To exit this script and install the above: Ctrl + c' -echo -echo ' Note: For installation on Debian based systems:' -echo -echo ' $ sudo apt install -y aircrack-ng wireshark' -echo -echo ' --------------------------------' -echo -e "${NoColor}" -# Interfering processes must be disabled prior to running this script: -# -#``` -# $ sudo airmon-ng check kill -#``` - - # Assign default monitor mode interface name iface0mon='wlan0mon' + # Assign default channel chan=6 + # Activate option to set automatic or manual interface mode # # Option 1: if you only have one wlan interface (automatic detection) @@ -78,25 +49,48 @@ chan=6 # Option 2: if you have more than one wlan interface (default wlan0) iface0=${1:-wlan0} + # Set iface0 down ip link set dev $iface0 down # Check if iface0 exists and continue if true if [ $? -eq 0 ] then -# Disabled interfering processes +# Disable interfering processes + PROCESSES="wpa_action\|wpa_supplicant\|wpa_cli\|dhclient\|ifplugd\|dhcdbd\|dhcpcd\|udhcpc\|NetworkManager\|knetworkmanager\|avahi-autoipd\|avahi-daemon\|wlassistant\|wifibox\|net_applet\|wicd-daemon\|wicd-client\|iwd" + unset match + match="$(ps -A -o comm= | grep ${PROCESSES} | grep -v grep | wc -l)" +# ps -A -o pid=PID -o comm=Name | grep "${PROCESSES}\|PID" + badProcs=$(ps -A -o pid=PID -o comm=Name | grep "${PROCESSES}\|PID") + for pid in $(ps -A -o pid= -o comm= | grep ${PROCESSES} | awk '{print $1}'); do + command kill -19 "${pid}" # -19 = STOP + done + clear + echo + echo ' The following processes have been stopped:' + echo -e "${LightRed}" + echo "${badProcs}" + echo -e "${NoColor}" + echo + echo ' Note: The above processes will be returned' + echo ' to a normal state at the end of this script.' + echo + read -p " Press any key to continue... " -n 1 -r + +# Disable interfering processes using airmon-ng # clear - echo - read -p " Do you want to use airmon-ng to disable interfering processes? [y/N] " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]] - then - airmon-ng check kill - read -p " Press any key to continue. " -n 1 -r - fi +# echo +# read -p " Do you want to use airmon-ng to disable interfering processes? [y/N] " -n 1 -r +# echo +# if [[ $REPLY =~ ^[Yy]$ ]] +# then +# airmon-ng check kill +# read -p " Press any key to continue. " -n 1 -r +# fi + # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -114,19 +108,21 @@ then echo ' --------------------------------' echo -e "${NoColor}" + # Set addr (has to be done before renaming the interface) iface_addr_orig=$iface_addr read -p " Do you want to set a new addr? [y/N] " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then - read -p " What addr do you want? ( 12:34:56:78:90:ab ) " iface_addr + read -p " What addr do you want? ( e.g. 12:34:56:78:90:ab ) " iface_addr ip link set dev $iface0 address $iface_addr fi # iface_addr=$(iw dev $iface0 info | grep 'addr' | sed 's/addr //' | sed -e 's/^[ \t]*//') # echo ' addr - ' $iface_addr # exit 1 + # Set monitor mode # iw dev set monitor # Valid monitor flags are: @@ -139,20 +135,23 @@ then # mumimo-groupid : use MUMIMO according to a group id # mumimo-follow-mac : use MUMIMO according to a MAC address iw dev $iface0 set monitor control - + + # Rename interface ip link set dev $iface0 name $iface0mon - + + # Bring the interface up ip link set dev $iface0mon up - + + # Run airodump-ng # airodump-ng will display a list of detected access points and clients # https://www.aircrack-ng.org/doku.php?id=airodump-ng # https://en.wikipedia.org/wiki/Regular_expression # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -167,37 +166,45 @@ then echo ' state - ' $iface_state iface_addr=$(iw dev $iface0mon info | grep 'addr' | sed 's/addr //' | sed -e 's/^[ \t]*//') echo ' addr - ' $iface_addr - echo ' --------------------------------' + echo ' --------------------------------' echo -e "${NoColor}" - echo -e " airodump-ng can receive and interpret key strokes while running..." + echo ' airodump-ng can display a list' + echo ' of detected access points and' + echo ' connected clients.' echo - echo -e " a - select active area" - echo -e " i - invert sorting order" - echo -e " s - change sort column" - echo -e " q - quit" - echo ' ----------------------------' - echo - read -p " Do you want to run airodump-ng to display a list of detected access points and clients? [y/N] " -n 1 -r + read -p " Do you want to run airodump-ng? [y/N] " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then -# usage: airodump-ng [,,...] -# -# -c : Capture on specific channels -# -a : Filter unassociated clients -# --ignore-negative-one : Removes the message that says fixed channel : -1 -# --essid-regex : Filter APs by ESSID using a regular expression -# + clear + echo + echo -e " airodump-ng can receive and interpret key strokes while running..." + echo + echo -e " [a]: Select active areas by cycling through the display options" + echo -e " [d]: Reset sorting to defaults" + echo -e " [i]: Invert sorting algorithm" + echo -e " [m]: Mark the selected AP" + echo -e " [r]: (De-)Activate realtime sorting" + echo -e " [s]: Change column to sort by" + echo -e " [SPACE]: Pause display redrawing/ Resume redrawing" + echo -e " [TAB]: Enable/Disable scrolling through AP list" + echo -e " [UP]: Select the AP prior to the currently marked AP if available" + echo -e " [DOWN]: Select the AP after the currently marked AP if available" + echo -e " [q] - quit" + echo + read -p " Press any key to continue... " -n 1 -r + echo + # Select option # # 1) shows hidden ESSIDs # airodump-ng -c 1-165 -a --ignore-negative-one $iface0mon # # 2) does not show hidden ESSIDs -# - airodump-ng -c 1-165 -a --ignore-negative-one --essid-regex '^(?=.)^(?!.*CoxWiFi)' $iface0mon + airodump-ng -c 1-165 -a -n 20 --uptime --ignore-negative-one --essid-regex '^(?=.)^(?!.*CoxWiFi)' $iface0mon fi + # Set channel read -p " Do you want to set the channel? [y/N] " -n 1 -r echo @@ -209,9 +216,10 @@ then # ip link set dev $iface0mon up fi + # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -233,20 +241,23 @@ then echo ' --------------------------------' echo -e "${NoColor}" + # Set txpw read -p " Do you want to set the txpower? [y/N] " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then - read -p " What txpw setting do you want? ( 2300 = 23 dBm ) " iface_txpw + echo -e "${Yellow} Note: Some USB WiFi adapters will not allow the txpw to be set.${NoColor}" + read -p " What txpw setting do you want to attempt to set? ( e.g. 2300 = 23 dBm ) " iface_txpw # ip link set dev $iface0mon down iw dev $iface0mon set txpower fixed $iface_txpw # ip link set dev $iface0mon up fi + # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -268,47 +279,16 @@ then echo ' --------------------------------' echo -e "${NoColor}" -# Test injection capability with aireplay-ng - read -p " Do you want to test injection capability? [y/N] " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]] - then -# ip link set dev $iface0mon up - aireplay-ng --test $iface0mon - fi -# Start wireshark - read -p " Do you want to start Wireshark? [y/N] " -n 1 -r +# Interface ready + echo " The Interface is now ready for Monitor Mode use." echo - if [[ $REPLY =~ ^[Yy]$ ]] - then -# ip link set dev $iface0mon up - wireshark --interface wlan0mon -# test filter: wlan.fc.type_subtype == 29 - # Display interface settings - clear - echo -e "${GREEN}" - echo ' --------------------------------' - echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" - echo ' --------------------------------' - echo ' WiFi Interface:' - echo ' '$iface0 - echo ' --------------------------------' - iface_name=$(iw dev $iface0mon info | grep 'Interface' | sed 's/Interface //' | sed -e 's/^[ \t]*//') - echo ' name - ' $iface_name - iface_type=$(iw dev $iface0mon info | grep 'type' | sed 's/type //' | sed -e 's/^[ \t]*//') - echo ' type - ' $iface_type - iface_state=$(ip addr show $iface0mon | grep 'state' | sed 's/.*state \([^ ]*\)[ ]*.*/\1/') - echo ' state - ' $iface_state - iface_addr=$(iw dev $iface0mon info | grep 'addr' | sed 's/addr //' | sed -e 's/^[ \t]*//') - echo ' addr - ' $iface_addr - iface_chan=$(iw dev $iface0mon info | grep 'channel' | sed 's/channel //' | sed -e 's/^[ \t]*//') - echo ' chan - ' $chan -# iface_txpw=$(iw dev $iface0mon info | grep 'txpower' | sed 's/txpower //' | sed -e 's/^[ \t]*//') -# echo ' txpw - ' $iface_txpw - echo ' --------------------------------' - echo -e "${NoColor}" - fi + echo " You can place this terminal in the background" + echo " while you run any applications you wish to run." + echo + read -p " Press any key to continue... " -n 1 -r + echo + # Return the adapter to original settings read -p " Do you want to return the adapter to original settings? [Y/n] " -n 1 -r @@ -317,7 +297,7 @@ then # ip link set dev $iface0mon up # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -340,9 +320,17 @@ then iw $iface0mon set type managed ip link set dev $iface0mon name $iface0 ip link set dev $iface0 up +# Enable interfering processes +# PROCESSES="wpa_action\|wpa_supplicant\|wpa_cli\|dhclient\|ifplugd\|dhcdbd\|dhcpcd\|udhcpc\|NetworkManager\|knetworkmanager\|avahi-autoipd\|avahi-daemon\|wlassistant\|wifibox\|net_applet\|wicd-daemon\|wicd-client\|iwd" +# unset match +# match="$(ps -A -o comm= | grep ${PROCESSES} | grep -v grep | wc -l)" +# ps -A -o pid=PID -o comm=Name | grep "${PROCESSES}\|PID" + for pid in $(ps -A -o pid= -o comm= | grep ${PROCESSES} | awk '{print $1}'); do + command kill -18 "${pid}" # -18 = CONT + done # Display interface settings clear - echo -e "${GREEN}" + echo -e "${LightGreen}" echo ' --------------------------------' echo -e " ${SCRIPT_NAME} ${SCRIPT_VERSION}" echo ' --------------------------------' @@ -362,8 +350,9 @@ then fi exit 0 else - echo -e "${YELLOW}ERROR: Please provide an existing interface as parameter! ${NoColor}" - echo -e "${NoColor}Usage: $ ${CYAN}sudo ./$SCRIPT_NAME [interface:wlan0] ${NoColor}" - echo -e "${NoColor}Tip: $ ${CYAN}iw dev ${NoColor}(displays available interfaces)" + echo -e "${LightRed}ERROR: Please provide an existing interface as parameter! ${NoColor}" + echo -e "${NoColor}Usage: $ ${LightCyan}sudo ./$SCRIPT_NAME [interface:wlan0] ${NoColor}" + echo -e "${NoColor}Tip: $ ${LightCyan}iw dev ${NoColor}(displays available interfaces)" + echo exit 1 fi diff --git a/supported-device-IDs b/supported-device-IDs index 56dbb6c..6c22c82 100644 --- a/supported-device-IDs +++ b/supported-device-IDs @@ -1,4 +1,4 @@ -USB Vendor and Device ID List for the rtl88x2bu chipset based USB WiFi Adapters +USB Vendor and Device ID List for rtl88x2bu chipset based USB WiFi Adapters To determine your Device ID: