Friday, April 25, 2014

Installing Broadcom BCM43142 Drivers on Kali Linux

Introduction

I've seen some confusion when it comes to installing the wireless drivers for Broadcom's BCM43142 802.11b/g/n card, specifically with Kali or other Debian based distributions. If you're running Linux kernel < 3.10, then just comment out the lines regarding the wl_3.10 patch. This script has been run on both 32bit and 64bit installations with Kali 1.0.6.

lspci

$ lspci | grep BCM43142
02:00.0 Network controller: Broadcom Corporation BCM43142 802.11b/g/n (rev 01)

Installing the drivers

The script is available through Github using the wget command below, or check the bottom of this article for the full script.

$ wget https://gist.githubusercontent.com/chokepoint/11305606/raw/52109f648c2ad5ec6a65bf8eee78fbda15fa1cfb/bcm43142_drivers.sh
$ chmod +x bcm43142_drivers.sh
$ sudo ./bcm43142_drivers.sh

Resources

Kali Linux
Broadcom Driver Instructions
Original wl_3.10 Patch

Script

#!/bin/bash
# chmod +x broadcom_drivers.sh
# ./broadcom_drivers.sh

mkdir broadcom 
cd broadcom
apt-get install linux-headers-`uname -r` build-essential -y

if [ `uname -m` == "i686" ] ; then
 wget http://www.broadcom.com/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz
else
 wget http://www.broadcom.com/docs/linux_sta/hybrid-v35_64-nodebug-pcoem-6_30_223_141.tar.gz
fi
tar -xvf hybrid-v35*
wget http://www.mindwerks.net/wp-content/uploads/2013/10/wl_3.10.patch
patch -p2 < wl_3.10.patch
make
cp wl.ko /lib/modules/`uname -r`/kernel/net/wireless/
depmod
rmmod bcma
echo "blacklist bcma" >> /etc/modprobe.d/blacklist.conf
modprobe wl

40 comments:

  1. Do you think this would work on Tails 1.1, too? I noticed that both Kali and Tails are *extremely* similar.

    ReplyDelete
    Replies
    1. patching file src/wl/sys/wl_linux.c
      Hunk #1 succeeded at 3236 (offset 7 lines).
      Hunk #2 succeeded at 3254 (offset 7 lines).
      Hunk #3 succeeded at 3417 (offset 7 lines).
      Hunk #4 succeeded at 3447 (offset 7 lines).
      Hunk #5 succeeded at 3483 (offset 7 lines).
      KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
      make[1]: Entering directory `/usr/src/linux-headers-3.18.0-kali1-686-pae'
      CFG80211 API is prefered for this kernel version
      Using CFG80211 API
      LD /root/broadcom/built-in.o
      CC [M] /root/broadcom/src/shared/linux_osl.o
      CC [M] /root/broadcom/src/wl/sys/wl_linux.o
      /root/broadcom/src/wl/sys/wl_linux.c: In function ‘wl_alloc_linux_if’:
      /root/broadcom/src/wl/sys/wl_linux.c:1348:64: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
      /root/broadcom/src/wl/sys/wl_linux.c:1348:8: error: ‘alloc_netdev’ undeclared (first use in this function)
      /root/broadcom/src/wl/sys/wl_linux.c:1348:8: note: each undeclared identifier is reported only once for each function it appears in
      make[4]: *** [/root/broadcom/src/wl/sys/wl_linux.o] Error 1
      make[3]: *** [_module_/root/broadcom] Error 2
      make[2]: *** [sub-make] Error 2
      make[1]: *** [all] Error 2
      make[1]: Leaving directory `/usr/src/linux-headers-3.18.0-kali1-686-pae'
      make: *** [all] Error 2
      cp: cannot stat `wl.ko': No such file or directory
      FATAL: Module wl not found.




      Any Solution to this..problem

      Delete
    2. I also encountered the same error....please help me....
      I dont have active internet connection

      Delete
    3. i have same problem too plz help

      Delete
  2. its working.............................

    ReplyDelete
  3. works on Kali.... Awesome

    ReplyDelete
  4. Superb! Thanks alot bro. I've been trying all the fixes but only this one worked. thanks again. :)

    ReplyDelete
  5. I am having issues with this installation I installed 32 bit Kalilinux OS on a 64 BIt sony VAIO...TECHIESSS please help meee



    root@Backtrack:~/Desktop# ./broadcom.sh


    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package linux-headers-3.7-trunk-686-pae
    E: Couldn't find any package by regex 'linux-headers-3.7-trunk-686-pae'
    --2014-09-24 16:58:53-- http://www.broadcom.com/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz
    Resolving www.broadcom.com (www.broadcom.com)... 63.251.216.155
    Connecting to www.broadcom.com (www.broadcom.com)|63.251.216.155|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1735911 (1.7M) [application/x-gzip]
    Saving to: `hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz'

    100%[======================================>] 17,35,911 11.6K/s in 2m 29s

    2014-09-24 17:01:25 (11.4 KB/s) - `hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz' saved [1735911/1735911]

    Makefile
    lib/
    lib/wlc_hybrid.o_shipped
    lib/LICENSE.txt
    src/
    src/shared/
    src/shared/linux_osl.c
    src/shared/bcmwifi/
    src/shared/bcmwifi/include/
    src/shared/bcmwifi/include/bcmwifi_channels.h
    src/shared/bcmwifi/include/bcmwifi_rates.h
    src/include/
    src/include/typedefs.h
    src/include/bcmdefs.h
    src/include/bcmendian.h
    src/include/linuxver.h
    src/include/wlioctl.h
    src/include/bcmutils.h
    src/include/osl.h
    src/include/linux_osl.h
    src/include/packed_section_end.h
    src/include/packed_section_start.h
    src/include/pcicfg.h
    src/include/epivers.h
    src/common/
    src/common/include/
    src/common/include/proto/
    src/common/include/proto/ethernet.h
    src/common/include/proto/bcmeth.h
    src/common/include/proto/bcmip.h
    src/common/include/proto/bcmevent.h
    src/common/include/proto/ieee80211_radiotap.h
    src/common/include/proto/802.11.h
    src/common/include/proto/802.1d.h
    src/common/include/proto/wpa.h
    src/wl/
    src/wl/sys/
    src/wl/sys/wl_cfg80211_hybrid.c
    src/wl/sys/wl_export.h
    src/wl/sys/wl_dbg.h
    src/wl/sys/wlc_key.h
    src/wl/sys/wlc_ethereal.h
    src/wl/sys/wl_linux.c
    src/wl/sys/wl_linux.h
    src/wl/sys/wl_cfg80211_hybrid.h
    src/wl/sys/wl_iw.c
    src/wl/sys/wl_iw.h
    src/wl/sys/wlc_types.h
    src/wl/sys/wlc_pub.h
    src/wl/sys/wlc_utils.h
    --2014-09-24 17:01:25-- http://www.mindwerks.net/wp-content/uploads/2013/10/wl_3.10.patch
    Resolving www.mindwerks.net (www.mindwerks.net)... 192.81.217.188
    Connecting to www.mindwerks.net (www.mindwerks.net)|192.81.217.188|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2916 (2.8K) [application/octet-stream]
    Saving to: `wl_3.10.patch'

    100%[======================================>] 2,916 18.0K/s in 0.2s

    2014-09-24 17:01:28 (18.0 KB/s) - `wl_3.10.patch' saved [2916/2916]

    patching file src/wl/sys/wl_linux.c
    Hunk #1 succeeded at 3236 (offset 7 lines).
    Hunk #2 succeeded at 3254 (offset 7 lines).
    Hunk #3 succeeded at 3417 (offset 7 lines).
    Hunk #4 succeeded at 3447 (offset 7 lines).
    Hunk #5 succeeded at 3483 (offset 7 lines).
    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make: *** /lib/modules/3.7-trunk-686-pae/build: No such file or directory. Stop.
    make: *** [all] Error 2
    cp: cannot stat `wl.ko': No such file or directory
    Error: Module bcma is not currently loaded
    FATAL: Module wl not found.


    root@Backtrack:~/Desktop#

    ReplyDelete
    Replies
    1. Looks like you're on backtrack. Try manually installing the appropriate linux-headers package for your current kernel version and then rerun the script.

      Delete
    2. I am new to kali linux and i am running x64 kali 1.10
      it is asking file to patch ?
      what should i do ?

      Delete
  6. It is showing as "root@Backtrack:~/Desktop# " because I have named the host as "Backtrack" instead of "Kali" and here is the result for the OS version that i got on running "uname -a"

    Linux Backtrack 3.7-trunk-686-pae #1 SMP Debian 3.7.2-0+kali8 i686 GNU/Linux

    Please let me know the commands and steps needed to be done as I am illiterate in LINUX OS...THANKS IN ADVACE......stderr...

    ReplyDelete
  7. Try using "apt-cache search linux-headers". Find the package that matches your installed kernel version, and then "apt-get install ". Typically it is the result of "echo linux-headers-$(uname -r)" Hope this helps.

    ReplyDelete
  8. Is it the latest driver?
    As per the "broadcom driver instruction" mentioned in RESOURCES the site is showing latest driver as ----223.248 and the script is installing ----223.241
    What should I do? Need advice.......thanks

    ReplyDelete
    Replies
    1. Good call. I'll look into updating the script to point to the latest driver. You should be able to just copy/paste the link in the correct spot and run it, but I haven't tested the latest driver either.

      Delete
  9. JUST THANK YOU !!!

    ReplyDelete
  10. hello there! am new for kali and also having patch failure, i try to relocate the patch file too but it again...


    root@kali:~/broadcom# patch -p2 < wl_3.10.patch.1
    can't find file to patch at input line 4
    Perhaps you used the wrong -p or --strip option?
    The text leading up to this was:
    --------------------------
    |diff -Naur bcmwl-6.30.223.30+bdcom.orig/src/src/wl/sys/wl_linux.c bcmwl-6.30.223.30+bdcom/src/src/wl/sys/wl_linux.c
    |--- bcmwl-6.30.223.30+bdcom.orig/src/src/wl/sys/wl_linux.c 2013-04-23 12:31:31.011588881 +0200
    |+++ bcmwl-6.30.223.30+bdcom/src/src/wl/sys/wl_linux.c 2013-05-20 18:27:18.830187333 +0200
    --------------------------
    File to patch: wl_3.10.patch
    patching file wl_3.10.patch
    Hunk #1 FAILED at 3229.
    Hunk #2 FAILED at 3242.
    Hunk #3 FAILED at 3401.
    Hunk #4 FAILED at 3424.
    Hunk #5 FAILED at 3455.
    5 out of 5 hunks FAILED -- saving rejects to file wl_3.10.patch.rej
    root@kali:~/broadcom#
    any help please?


    ReplyDelete
  11. Thanks! Worked perfectly!

    ReplyDelete
  12. Soooo perfect, thanks

    ReplyDelete
  13. Thank you very much. It's working for me.

    ReplyDelete
  14. my lappy is lenovo y510p ideapad. my wireless chipset is bcm43142. i m working on enabling the wifi from last 3 weeks. i followed the above procedure and got my wifi working. but i am able to use it for injection on my dual boot kali linux. after looking around for it i found that my drivers wl is unable to support the injection. is it true ??? if yes then can i get it work after installing another drivers?? give me the link here. if it s not true then tell me how to enable it for injection. thank you!!!!

    ReplyDelete
    Replies
    1. *not able to use injection

      Delete
  15. Hello, I am totally new to kali . . .please anyone guide me how to run this script please

    ReplyDelete
  16. Love you stderr. . . good work . . .i fix it . . .thank you soooooooo much

    ReplyDelete
  17. Awesome... >Works 100% (Y)

    ReplyDelete
  18. Hi, works perfectly, but wifi hack tools (air...-ng) trigger related driver errors.
    Anybody here install the drivers with air-ng tools working?

    ReplyDelete
  19. Hey buddy i am having the same issue with my broadcom driver and my kernel version is 3.18.0-kali1-amd64.
    what should i do.

    ReplyDelete
  20. If your are using Broadcom drivers for kali it will not support the packet injection, so you cant go for the wifi hacking :( Rafael E. Espinosa Santiesteban

    ReplyDelete
  21. i m running kali version 3.18.0-kali1-amd64
    network interface
    02:00.0 Network controller: Broadcom Corporation BCM43142 802.11b/g/n (rev 01).

    this is the output when i run the above script.


    Saving to: `wl_3.10.patch'

    100%[======================================>] 2,916 --.-K/s in 0s

    2015-02-24 08:48:56 (172 MB/s) - `wl_3.10.patch' saved [2916/2916]

    patching file src/wl/sys/wl_linux.c
    Hunk #1 succeeded at 3236 (offset 7 lines).
    Hunk #2 succeeded at 3254 (offset 7 lines).
    Hunk #3 succeeded at 3417 (offset 7 lines).
    Hunk #4 succeeded at 3447 (offset 7 lines).
    Hunk #5 succeeded at 3483 (offset 7 lines).
    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make[1]: Entering directory `/usr/src/linux-headers-3.18.0-kali1-amd64'
    CFG80211 API is prefered for this kernel version
    Using CFG80211 API
    LD /root/shell-script/broadcom/built-in.o
    CC [M] /root/shell-script/broadcom/src/shared/linux_osl.o
    CC [M] /root/shell-script/broadcom/src/wl/sys/wl_linux.o
    /root/shell-script/broadcom/src/wl/sys/wl_linux.c: In function ‘wl_alloc_linux_if’:
    /root/shell-script/broadcom/src/wl/sys/wl_linux.c:1348:64: error: macro "alloc_netdev" requires 4 arguments, but only 3 given
    /root/shell-script/broadcom/src/wl/sys/wl_linux.c:1348:8: error: ‘alloc_netdev’ undeclared (first use in this function)
    /root/shell-script/broadcom/src/wl/sys/wl_linux.c:1348:8: note: each undeclared identifier is reported only once for each function it appears in
    make[4]: *** [/root/shell-script/broadcom/src/wl/sys/wl_linux.o] Error 1
    make[3]: *** [_module_/root/shell-script/broadcom] Error 2
    make[2]: *** [sub-make] Error 2
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.18.0-kali1-amd64'
    make: *** [all] Error 2
    cp: cannot stat `wl.ko': No such file or directory
    FATAL: Module wl not found.

    ReplyDelete
  22. Found a way of the decision for a kernel 3.18.0 here: http://www.sakryukin.ru/index.php?module=articles&c=articles&b=6&a=17

    ReplyDelete
    Replies
    1. the problem got more worse after going above solution.
      i am unable to run wifi.
      nothings work now

      always says Fatal Error
      leaving directory.
      No make...
      etc

      please help me sir.

      Delete
  23. this don't work for me :
    ------
    root@kali:~/Downloads/tmp# ./bcm43142_drivers.sh
    --2015-03-14 21:55:56-- http://www.broadcom.com/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz
    Résolution de www.broadcom.com (www.broadcom.com)... 63.251.216.155
    Connexion vers www.broadcom.com (www.broadcom.com)|63.251.216.155|:80...connecté.
    requête HTTP transmise, en attente de la réponse...200 OK
    Longueur: 1735911 (1,7M) [application/x-gzip]
    Sauvegarde en : «hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz»

    100%[============================================================================================================>] 1 735 911 64,9K/s ds 28s

    2015-03-14 21:56:24 (61,0 KB/s) - «hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz» sauvegardé [1735911/1735911]

    Makefile
    lib/
    lib/wlc_hybrid.o_shipped
    lib/LICENSE.txt
    src/
    src/shared/
    src/shared/linux_osl.c
    src/shared/bcmwifi/
    src/shared/bcmwifi/include/
    src/shared/bcmwifi/include/bcmwifi_channels.h
    src/shared/bcmwifi/include/bcmwifi_rates.h
    src/include/
    src/include/typedefs.h
    src/include/bcmdefs.h
    src/include/bcmendian.h
    src/include/linuxver.h
    src/include/wlioctl.h
    src/include/bcmutils.h
    src/include/osl.h
    src/include/linux_osl.h
    src/include/packed_section_end.h
    src/include/packed_section_start.h
    src/include/pcicfg.h
    src/include/epivers.h
    src/common/
    src/common/include/
    src/common/include/proto/
    src/common/include/proto/ethernet.h
    src/common/include/proto/bcmeth.h
    src/common/include/proto/bcmip.h
    src/common/include/proto/bcmevent.h
    src/common/include/proto/ieee80211_radiotap.h
    src/common/include/proto/802.11.h
    src/common/include/proto/802.1d.h
    src/common/include/proto/wpa.h
    src/wl/
    src/wl/sys/
    src/wl/sys/wl_cfg80211_hybrid.c
    src/wl/sys/wl_export.h
    src/wl/sys/wl_dbg.h
    src/wl/sys/wlc_key.h
    src/wl/sys/wlc_ethereal.h
    src/wl/sys/wl_linux.c
    src/wl/sys/wl_linux.h
    src/wl/sys/wl_cfg80211_hybrid.h
    src/wl/sys/wl_iw.c
    src/wl/sys/wl_iw.h
    src/wl/sys/wlc_types.h
    src/wl/sys/wlc_pub.h
    src/wl/sys/wlc_utils.h
    --2015-03-14 21:56:24-- http://www.mindwerks.net/wp-content/uploads/2013/10/wl_3.10.patch
    Résolution de www.mindwerks.net (www.mindwerks.net)... 104.28.31.52, 104.28.30.52, 2400:cb00:2048:1::681c:1f34, ...
    Connexion vers www.mindwerks.net (www.mindwerks.net)|104.28.31.52|:80...connecté.
    requête HTTP transmise, en attente de la réponse...200 OK
    Longueur: 2916 (2,8K) [application/octet-stream]
    Sauvegarde en : «wl_3.10.patch»

    100%[============================================================================================================>] 2 916 --.-K/s ds 0,002s

    2015-03-14 21:56:24 (1,73 MB/s) - «wl_3.10.patch» sauvegardé [2916/2916]

    patching file src/wl/sys/wl_linux.c
    Hunk #1 succeeded at 3236 (offset 7 lines).
    Hunk #2 succeeded at 3254 (offset 7 lines).
    Hunk #3 succeeded at 3417 (offset 7 lines).
    Hunk #4 succeeded at 3447 (offset 7 lines).
    Hunk #5 succeeded at 3483 (offset 7 lines).
    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make: *** /lib/modules/3.14-kali1-686-pae/build: Aucun fichier ou dossier de ce type. Arrêt.
    make: *** [all] Erreur 2
    cp: impossible d'évaluer « wl.ko »: Aucun fichier ou dossier de ce type
    Error: Module bcma is not currently loaded
    FATAL: Module wl not found.
    -----------

    ReplyDelete
  24. Great post. Hope it'll help others. Here the solution for Centos 6 http://thisismynota.blogspot.com/2015/05/how-to-install-broadcom-bcm43142-wifi.html

    ReplyDelete
  25. i've uninstalled my kalilinux because the broadcom issue, and if this really work i'd like to install it again..
    its just wondering me, since i now there is no connection and the script order us to download some file "wget http://www.broadcom.com/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_141.tar.gz" ?
    i got an idea, can i download the file in another pc. and then run it on my kalilinux?

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. this is not work for me
    that error is :




    KBUILD_NOPEDANTIC=1 make -C /lib/modules/`uname -r`/build M=`pwd`
    make[1]: Entering directory '/usr/src/linux-headers-3.16.0-23-generic'
    CFG80211 API is prefered for this kernel version
    Using CFG80211 API
    CC [M] /home/hello/bcm/broadcom/src/wl/sys/wl_linux.o
    /home/hello/bcm/broadcom/src/wl/sys/wl_linux.c: In function ‘wl_dump_ver’:
    /home/hello/bcm/broadcom/src/wl/sys/wl_linux.c:2041:3: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
    __DATE__, __TIME__, EPI_VERSION_STR);
    ^
    /home/hello/bcm/broadcom/src/wl/sys/wl_linux.c:2041:13: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
    __DATE__, __TIME__, EPI_VERSION_STR);
    ^
    cc1: some warnings being treated as errors
    scripts/Makefile.build:257: recipe for target '/home/hello/bcm/broadcom/src/wl/sys/wl_linux.o' failed
    make[2]: *** [/home/hello/bcm/broadcom/src/wl/sys/wl_linux.o] Error 1
    Makefile:1345: recipe for target '_module_/home/hello/bcm/broadcom' failed
    make[1]: *** [_module_/home/hello/bcm/broadcom] Error 2
    make[1]: Leaving directory '/usr/src/linux-headers-3.16.0-23-generic'
    Makefile:136: recipe for target 'all' failed
    make: *** [all] Error 2







    please help me pleasssssse

    ReplyDelete
  28. for an amd64 system i did the following ( lenovo g510 with BCM43142)
    make sure you have the correct sources in your sources.list file

    # main sources for kali
    deb http://http.kali.org/kali kali main non-free contrib
    deb http://security.kali.org/kali-security kali/updates main contrib non-free

    # source sources for kali
    deb-src http://http.kali.org/kali kali main non-free contrib
    deb-src http://security.kali.org/kali-security kali/updates main contrib non-free

    # bleeding edge...
    #deb http://repo.kali.org/kali kali-bleeding-edge main
    #deb-src http://repo.kali.org/kali kali-bleeding-edge main

    and then update and upgrade your system.
    (get update, get upgrade and even get dist-upgrade)

    Then add the specific kernel headers:

    install the (apt-get install) linux-headers-3.18.0-kali3-amd64 ( following the version in the /lib/modules folder)

    then you can jump to the following site and it will explain next steps:


    https://wiki.debian.org/wl

    for clarification:
    #skip step one (thus do not alter the sources.list file as this will cock up the installation badly.)

    #step 2 is safe to run as it will auto build and install the wl.ko driver

    apt-get update
    apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms

    #step 3 and 4 must be performed:

    #(unload conflicting modules)
    modprobe -r b44 b43 b43legacy ssb brcmsmac

    #Load the wl module:

    modprobe wl

    at this point i rebooted the system as i did not see a wireless connection. after the reboot the wireless connection was visible and i could connect to the AP and the connection is working fine.

    the wl driver cannot inject packets so if you need to perform such tests then the broadcom card is not the right card..

    i might have over simplified the installation of the kernel module for the BCM card. most important lesson i learned is: patience. reading, trial and error and a reinstall (based on the trial/error result) can occur. but hey. in the end this way i did learn something new

    ReplyDelete