r00t-3xp10it

spoof-mac.sh

Oct 16th, 2016
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.73 KB | None | 0 0
  1. #!/bin/sh
  2. ###
  3. # Author: r00t-3xp10it | SSA PurpleTeam @2016
  4. # CHANGE MAC ADDRESS WITHOUT USING MACCHANGER
  5. # SUPPORTED: Linux Kali1, Kali2, Kali3
  6. # ---
  7. #
  8. # I have installed 'kali 2016.1 rolling' a few days ago, and 'macchanger' tool works well with no problems.
  9. # The problem cames when i have decided to 'update' my distro, ever since that update that iam facing bugs
  10. # at changing my 'mac+ip addr' using macchanger('Network Manager9' have changed the way things normally works)
  11. #
  12. # For Reference:
  13. # When using NetworkManager(NM9) to access the net, any spoofed mac address(MAC) produced thru the terminal window(TW)
  14. # using macchanger tool will be over-written by NM9. If no cloned mac address exists in NM9 menu settings, then
  15. # the device is returned to the device MAC (permanent) and any mac spoofing set by the user thru the TW disappears.
  16. # ---
  17. #
  18. # 'This script was writen to enable me to change my mac address using terminal windows'...
  19. # spoof-mac.sh checks if we are running againts 'Kali distros' and if NM version its 'bigger than:1.2.0 (NM9)'
  20. # sudo chmod +x spoof-mac.sh
  21. # sudo ./spoof-mac.sh -h
  22. ####
  23.  
  24.  
  25.  
  26.  
  27. # ---------------------
  28. # VARIABLE DECLARATIONS
  29. # ---------------------
  30. oS=`awk '{print $1}' /etc/issue` # grab distro (Kali or other)
  31. OlD="1.2.0" # version number of the old (not bugged) NetworkManager
  32. VeR=`NetworkManager -V` # grab networkmanager current version installed
  33.  
  34.   # String to search inside /etc/NetworkManager/system-connections/<ESSID> file
  35.   # If you are getting an error in the 'find /etc/NetworkManager/system-connections'
  36.   # command, then verify if you have enter (case sensitive) the rigth ESSID name. Or
  37.   # if you are using an old kali distro than change the next variable to: 812-11-wireless
  38.   kEy="wifi"
  39.  
  40.  
  41.  
  42.  
  43. # -----------------------------------
  44. # Colorise shell Script output leters
  45. # -----------------------------------
  46. Colors() {
  47. Escape="\033";
  48.   white="${Escape}[0m";
  49.   RedF="${Escape}[31m";
  50.   GreenF="${Escape}[32m";
  51.   YellowF="${Escape}[33m";
  52.   BlueF="${Escape}[34m";
  53.   CyanF="${Escape}[36m";
  54. Reset="${Escape}[0m";
  55. }
  56.  
  57.  
  58.  
  59.  
  60. Colors;
  61. # pass arguments to script [ -h | -v | -m ]
  62. # we can use: ./spoof-mac.sh -h for help menu
  63. # we can use: ./spoof-mac.sh -v to list mac vendors
  64. # we can use: ./spoof-mac.sh -m to show current mac and ip address
  65. while getopts ":h,:v,:m,:D" opt; do
  66.   case $opt in
  67.     h)
  68. cat << !
  69. ---
  70. -- Author: r00t-3xp10it | SSA PurpleTeam @2016
  71. -- CHANGE MAC ADDRESS WITHOUT USING MACCHANGER
  72. -- Supported: Linux Kali1, Kali2, Kali3
  73. ---
  74.  
  75.   When using NetworkManager (NM9) to access the net, any spoofed mac address (MAC)
  76.   produced thru the terminal window (TW) using macchanger tool will be over-writen by
  77.   NM9. If no cloned mac address exists in NM menu settings, then the device is returned
  78.   to the device MAC (permanent) and any mac spoofing set by user thru the TW disappears.
  79.  
  80.   [ script arguments available ]
  81.   sudo ./spoof-mac.sh for execution
  82.   sudo ./spoof-mac.sh -h for help menu
  83.   sudo ./spoof-mac.sh -v to list mac vendors
  84.   sudo ./spoof-mac.sh -m show current mac and ip address
  85.  
  86.   "The follow script its my attempt to build the macchanger funtion thru TW"
  87. !
  88.    exit
  89.     ;;
  90.     v)
  91. cat << !
  92. ---
  93. -- Author: r00t-3xp10it | SSA PurpleTeam @2016
  94. -- CHANGE MAC ADDRESS WITHOUT USING MACCHANGER
  95. -- [ list of know vendors ]
  96. ---
  97.  
  98.    00:16:f0 - Dell
  99.    00:03:93 - Apple
  100.    00:05:02 - Apple
  101.    00:0a:27 - Apple
  102.    00:00:17 - Oracle
  103.    00:17:ef - IBM Corp
  104.    00:30:ab - Netgear MA401
  105.    08:00:46 - Sony PCWA-C10
  106.    00:30:bd - Belkin F5D6020
  107.    00:50:f2 - MICROSOFT CORP.
  108.    00:01:10 - Gotham Networks.
  109.    00:00:00 - XEROX CORPORATION
  110.    00:00:0b - MATRIX CORPORATION
  111.    00:17:9a - D-Link Corporation
  112.    00:17:0e - CISCO SYSTEMS, INC.
  113.    00:17:a5 - Ralink Technology Corp
  114.    00:04:64 - Fantasma Networks, Inc.
  115.    00:20:91 - National Security Agency.
  116.    00:05:5d - D-Link DWL-650, DWL-650H
  117.    00:06:25 - Linksys WPC11 v2.5, Linksys WPC11 v3
  118.  
  119. !
  120.    exit
  121.     ;;
  122.     m)
  123. cat << !
  124. ---
  125. -- Author: r00t-3xp10it | SSA PurpleTeam @2016
  126. -- CHANGE MAC ADDRESS WITHOUT USING MACCHANGER
  127. -- [ mac and ip addr - current settings ]
  128. ---
  129.  
  130. !
  131.    # funtion to check mac and ip current settings.
  132.    # grab default interface, current mac and ip settings.
  133.    InTeR=`netstat -r | grep "default" | awk {'print $8'}`
  134.    cUrRe=`ifconfig $InTeR | grep "ether" | awk {'print $2'}`
  135.    IP=`ifconfig $InTeR | egrep -w "inet" | awk '{print $2}'`
  136.    echo ${BlueF}[*]${white} Interface active:${GreenF} $InTeR ${Reset};
  137.    echo ${BlueF}[*]${white} Current mac addr:${GreenF} $cUrRe ${Reset};
  138.    echo ${BlueF}[*]${white} Current ip addr :${GreenF} $IP ${Reset};
  139.    exit
  140.     ;;
  141.     D)
  142.       # easter egg: dump wifi passwords to a hidden file :D
  143.       # This argument (funtion) will write .dumped-wifi.txt
  144.       # into the working directory (path were script has run)
  145.       PsK=`sudo grep psk= /etc/NetworkManager/system-connections/*`
  146.       WeP=`sudo grep wep-key0= /etc/NetworkManager/system-connections/*`
  147.       sleep 1
  148.       echo ${BlueF}[]${white} easter egg:${GreenF} Done ...${Reset};
  149.       echo "[DUMPED WIFI WEP/PSK's]" >> .dumped-wifi.txt
  150.       echo "$PsK" >> .dumped-wifi.txt
  151.       echo "$WeP" >> .dumped-wifi.txt
  152.       echo "" >> .dumped-wifi.txt
  153.       sleep 1 && clear
  154.       exit
  155.     ;;
  156.     \?)
  157.       echo ${RedF}[x]${white} Invalid option:${RedF} -$OPTARG ${Reset}; >&2
  158.       exit
  159.     ;;
  160.   esac
  161. done
  162.  
  163.  
  164.  
  165.  
  166.  
  167. # --------------
  168. # BANNER DISPLAY
  169. # --------------
  170. echo ${YellowF}
  171. cat << !
  172. ---
  173. -- Author: r00t-3xp10it | SSA PurpleTeam @2016
  174. -- CHANGE MAC ADDRESS WITHOUT USING MACCHANGER
  175. -- Supported: Linux Kali1, Kali2, Kali3
  176. ---
  177. !
  178.  
  179.  
  180.  
  181.  
  182. # ---------------------------------------------
  183. # Chek if we are running againts Kali distros
  184. # and if NM version its bigger than: 1.2.0 (NM9)
  185. # ----------------------------------------------
  186. if [ "$oS" = "Kali" ] && [ $VeR \> $OlD ]; then
  187.   echo ${BlueF}[*]${white} Kali Distro found...${Reset};
  188.   echo ${BlueF}[*]${white} NetworkManager9 found... ${Reset};
  189.  
  190.  
  191.     # questions to user
  192.     iNtEr=$(zenity --title="Input INTERFACE in Use" --text "example: wlan0" --entry --width 300) > /dev/null 2>&1
  193.     echo ${BlueF}[*]${white} Sellected INTERFACE:${GreenF}$iNtEr...${Reset};
  194.     EsSiD=$(zenity --title="Input ESSID to inject Clone" --text "example: Gh0st-Ubuntu" --entry --width 300) > /dev/null 2>&1
  195.     echo ${BlueF}[*]${white} Sellected ESSID:${GreenF}$EsSiD...${Reset};
  196.     ClOnE=$(zenity --title="Input MAC ADDR to Inject" --text "example: 00:04:64:a8:04:b8" --entry --width 300) > /dev/null 2>&1
  197.     echo ${BlueF}[*]${white} Sellected CLONE:${GreenF}$ClOnE...${Reset};
  198.  
  199.       # bring interface down
  200.       echo ${BlueF}[*]${white} Stop network-manager...${Reset};
  201.       service network-manager stop > /dev/null 2>&1
  202.       sleep 3
  203.       echo ${BlueF}[*]${white} Bring interface down...${Reset};
  204.       ifconfig $iNtEr down > /dev/null 2>&1
  205.       sleep 2
  206.  
  207.         # add cloned mac to NetworkManager
  208.         echo ${BlueF}[*]${white} Add Cloned mac address to network-manager...${Reset};
  209.         find "/etc/NetworkManager/system-connections/$EsSiD" -type f -exec sh -c "sed -i \"/^cloned-mac-address.*/d;/^\[$kEy\]/a\cloned-mac-address=$ClOnE\" \"{}\"" \;
  210.         sleep 2
  211.  
  212.     # bring interface up
  213.     echo ${BlueF}[*]${white} Bring interface up...${Reset};
  214.     ifconfig $iNtEr up > /dev/null 2>&1
  215.     sleep 2
  216.     echo ${BlueF}[*]${white} Restart network-manager...${Reset};
  217.     service network-manager start > /dev/null 2>&1
  218.     sleep 5
  219.  
  220.   # display settings to user
  221.   cUrRe=`ifconfig $iNtEr | grep "ether" | awk {'print $2'}`
  222.   IP=`ifconfig $iNtEr | egrep -w "inet" | awk '{print $2}'`
  223.   echo ${BlueF}[*]${white} Current mac addr:${GreenF}$cUrRe ${Reset};
  224.   echo ${BlueF}[*]${white} Current ip addr :${GreenF}$IP ${Reset};
  225.   sleep 2
  226.   echo ${BlueF}['!'] To change your Mac adress to default [ permanent ] ${Reset};
  227.   echo ${BlueF}['!'] just run the tool again, and when the clone mac adress ${Reset};
  228.   echo ${BlueF}['!'] window appear just press ENTER [ dont input any mac ]. ${Reset};
  229.   exit
  230.  
  231.  
  232. else
  233.  
  234.  
  235.   sleep 1
  236.   # not supported distro/operative system...
  237.   if [ "$oS" != "Kali" ]; then
  238.   echo ${RedF}[x]${white} OS Distribution :${RedF} $oS '(NOT SUPPORTED)' ${Reset};
  239.   else
  240.   echo ${RedF}[x]${white} OS Distribution :${RedF} $oS ${Reset};
  241.   fi
  242.   if [ $OlD \> $VeR ]; then
  243.   echo ${RedF}[x]${white} Network Manager :${RedF} $VeR '(NOT SUPPORTED)' ${Reset};
  244.   else
  245.   echo ${RedF}[x]${white} Network Manager :${RedF} $VeR ${Reset};
  246.   fi
  247.   sleep 1
  248.   echo ${BlueF}['!'] Use macchanger utility to spoof your mac addr. ${Reset};
  249.   echo ${BlueF}['!'] This bug it´s only present In NetworkManager '( >=' $OlD ')'${Reset};
  250.   echo ${BlueF}['!'] versions, the main reason why this script was build... ${Reset};
  251.   exit
  252.  
  253. fi
Advertisement
Add Comment
Please, Sign In to add comment