From 92d08ce6a8a58e0b572c66c61d18be3304c6ce97 Mon Sep 17 00:00:00 2001 From: Mathy Date: Sat, 7 Mar 2020 21:10:55 -0500 Subject: [PATCH] fragattack: script to turn hardware encryption on or off --- research/hwcrypto.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 research/hwcrypto.sh diff --git a/research/hwcrypto.sh b/research/hwcrypto.sh new file mode 100755 index 000000000..0a5b22422 --- /dev/null +++ b/research/hwcrypto.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2020, Mathy Vanhoef +# +# This code may be distributed under the terms of the BSD license. +# See README for more details. + +set -e + +NOHWCRYPT="ath5k ath9k ath9k_htc rt2800usb carl9170 b43 p54common rt2500usb rt2800pci rt2800usb rt73usb" +SWCRYPTO="iwlwifi iwl3945 iwl4965" +HWCRYPTO="ipw2200" + +hwcrypt_remove_modules() { + # Remove loaded modules so they'll reload parameters + for MODULE in $NOHWCRYPT $SWCRYPTO $HWCRYPTO + do rmmod $MODULE 2> /dev/null || true; done +} + +hwcrypt_off() { + # Create nohwcrypt.conf options file + rm /etc/modprobe.d/nohwcrypt.conf 2> /dev/null || true + + for MODULE in $NOHWCRYPT + do echo "options $MODULE nohwcrypt=1" >> /etc/modprobe.d/nohwcrypt.conf; done + + for MODULE in $SWCRYPTO + do echo "options $MODULE swcrypto=1" >> /etc/modprobe.d/nohwcrypt.conf; done + + for MODULE in $HWCRYPTO + do echo "options $MODULE hwcrypto=0" >> /etc/modprobe.d/nohwcrypt.conf; done + + # Done. To be sure parameters are reloaded, reboot computer. + hwcrypt_remove_modules + echo "Done. Reboot your computer." +} + +hwcrypt_on() { + rm -f /etc/modprobe.d/nohwcrypt.conf + hwcrypt_remove_modules + echo "Done. Reboot your computer." +} + + +if [[ $1 == "on" ]]; then + hwcrypt_on +elif [[ $1 == "off" ]]; then + hwcrypt_off +else + echo "Usage: $0 on|off" +fi +