Sunday, 10 June 2007

Hostap Injection patch on Ubuntu 7.04 (Feisty Fawn)

This is a quick tutorial on how to compile the hostap driver with the aircrack-ng injection patch. Everything is done from scratch on a vanilla feisty fawn.

We are going to be doing some kernel compilation, so make sure that at least these two packages are installed on your system: "dpkg-dev" and "linux-kernel-devel" (they are normally not included in the basic distro).

Create a temp directory where we can download the kernel sources and the injection patch:

mkdir HostApInjection
cd HostApInjection


Create a sub directory to hold the compilation output. Copy your current kernel config onto it:

mkdir OutputDir
cp /boot/config-2.6.20-16-generic OutputDir/
ln -s OutputDir/config-2.6.20-16-generic OutputDir/.config


Now get the kernel:

apt-get source linux-image-2.6.20-16-generic

Get the injection patch:

wget -nc http://rsappe.googlepages.com/hostap-kernel-injection-2.6.20-16.patch

or just click here. This is the SAME patch as in http://patches.aircrack-ng.org/hostap-kernel-2.6.18.patch, it's just tailored for 2.6.20-16

Patch the kernel:

patch -p1 < hostap-kernel-injection-2.6.20-16.patch

And compile just the hostap module:

cd linux-source-2.6.20-2.6.20/
make O=../OutputDir outputmakefile
make O=../OutputDir archprepare
make O=../OutputDir modules SUBDIRS=scripts
make O=../OutputDir modules SUBDIRS=drivers/net/wireless/hostap

The new module should now be ready. We just need to replace the old one (you may want to save a copy somewhere safe):

cd..
cd OutputDir/drivers/net/wireless/hostap/
sudo cp -dpR *.ko /lib/modules/2.6.20-16-generic/kernel/drivers/net/wireless/hostap/

And that's it! Hostap should now support injection and you can start playing with aircrack-ng.

Enjoy!

10 comments:

peterdog said...

Hola

Todo ok
el problema es que cuando inserto la PCMCIA solo reconoce los drivers deorino_cs.
HAy alguna solucion para que reconozca los drivers de hostap_cs

Un saludo

Anonymous said...

Hi, I have the following errors on Feisty Fawn when following the directions to the letter. What's wrong?

# uname -r
2.6.20-16-generic
# mkdir HostApInjection
# cd HostApInjection/
# mkdir OutputDir
# cp /boot/config-2.6.20-16-generic OutputDir/
# ln -s OutputDir/config-2.6.20-16-generic OutputDir/.config
# apt-get source linux-image-2.6.20-16-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
Need to get 63.8MB of source archives.
Get:1 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (dsc) [2472B]
Get:2 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (tar) [62.2MB]
Get:3 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (diff) [1578kB]
Fetched 63.8MB in 3m21s (316kB/s)
gpg: Signature made Thu 30 Aug 2007 02:00:27 AM CEST using DSA key ID 17063E6D
gpg: Can't check signature: public key not found
dpkg-source: extracting linux-source-2.6.20 in linux-source-2.6.20-2.6.20
dpkg-source: unpacking linux-source-2.6.20_2.6.20.orig.tar.gz
dpkg-source: applying ./linux-source-2.6.20_2.6.20-16.31.diff.gz
# wget -nc http://rsappe.googlepages.com/hostap-kernel-injection-2.6.20-16.patch
--08:23:41-- http://rsappe.googlepages.com/hostap-kernel-injection-2.6.20-16.patch
=> `hostap-kernel-injection-2.6.20-16.patch'
Resolving rsappe.googlepages.com... 72.14.203.118
Connecting to rsappe.googlepages.com|72.14.203.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7,487 (7.3K) [application/octet-stream]

100%[======================================================>] 7,487 --.--K/s

08:23:41 (50.54 KB/s) - `hostap-kernel-injection-2.6.20-16.patch' saved [7487/7487]

# patch -p1 < hostap-kernel-injection-2.6.20-16.patch
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_80211_tx.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_hw.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_ioctl.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_main.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_pci.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_plx.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_wlan.h
# cd linux-source-2.6.20-2.6.20/
# make O=../OutputDir outputmakefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/docproc
GEN /home/rohan/HostApInjection/OutputDir/Makefile
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/kxgettext.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/i386/Kconfig
***
*** You have not yet configured your kernel!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
GEN /home/rohan/HostApInjection/OutputDir/Makefile
# make O=../OutputDir archprepare
GEN /home/rohan/HostApInjection/OutputDir/Makefile
scripts/kconfig/conf -s arch/i386/Kconfig
***
*** You have not yet configured your kernel!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
make: *** [archprepare] Error 2
# make O=../OutputDir modules SUBDIRS=scripts

ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/rohan/HostApInjection/OutputDir/Module.symvers
is missing; modules will have no dependencies and modversions.

CC scripts/mod/empty.o
cc1: error: include/linux/autoconf.h: No such file or directory
make[3]: *** [scripts/mod/empty.o] Error 1
make[2]: *** [scripts/mod] Error 2
make[1]: *** [_module_scripts] Error 2
make: *** [modules] Error 2
# make O=../OutputDir modules SUBDIRS=drivers/net/wireless/hostap

ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/rohan/HostApInjection/OutputDir/Module.symvers
is missing; modules will have no dependencies and modversions.

Building modules, stage 2.
/home/rohan/HostApInjection/linux-source-2.6.20-2.6.20/scripts/Makefile.modpost:42: include/config/auto.conf: No such file or directory
make[2]: *** No rule to make target `include/config/auto.conf'. Stop.
make[1]: *** [modules] Error 2
make: *** [modules] Error 2
#

Anonymous said...

Hi, I have the following errors on Feisty Fawn when following the directions to the letter. What's wrong?


# uname -r
2.6.20-16-generic
# mkdir HostApInjection
# cd HostApInjection/
# mkdir OutputDir
# cp /boot/config-2.6.20-16-generic OutputDir/
# ln -s OutputDir/config-2.6.20-16-generic OutputDir/.config
# apt-get source linux-image-2.6.20-16-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
Need to get 63.8MB of source archives.
Get:1 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (dsc) [2472B]
Get:2 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (tar) [62.2MB]
Get:3 http://security.ubuntu.com feisty-security/main linux-source-2.6.20 2.6.20-16.31 (diff) [1578kB]
Fetched 63.8MB in 3m21s (316kB/s)
gpg: Signature made Thu 30 Aug 2007 02:00:27 AM CEST using DSA key ID 17063E6D
gpg: Can't check signature: public key not found
dpkg-source: extracting linux-source-2.6.20 in linux-source-2.6.20-2.6.20
dpkg-source: unpacking linux-source-2.6.20_2.6.20.orig.tar.gz
dpkg-source: applying ./linux-source-2.6.20_2.6.20-16.31.diff.gz
# wget -nc http://rsappe.googlepages.com/hostap-kernel-injection-2.6.20-16.patch
--08:23:41-- http://rsappe.googlepages.com/hostap-kernel-injection-2.6.20-16.patch
=> `hostap-kernel-injection-2.6.20-16.patch'
Resolving rsappe.googlepages.com... 72.14.203.118
Connecting to rsappe.googlepages.com|72.14.203.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7,487 (7.3K) [application/octet-stream]

100%[======================================================>] 7,487 --.--K/s

08:23:41 (50.54 KB/s) - `hostap-kernel-injection-2.6.20-16.patch' saved [7487/7487]

# patch -p1 < hostap-kernel-injection-2.6.20-16.patch
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_80211_tx.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_hw.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_ioctl.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_main.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_pci.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_plx.c
patching file linux-source-2.6.20-2.6.20/drivers/net/wireless/hostap/hostap_wlan.h
# cd linux-source-2.6.20-2.6.20/
# make O=../OutputDir outputmakefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/docproc
GEN /home/rohan/HostApInjection/OutputDir/Makefile
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/kxgettext.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/i386/Kconfig
***
*** You have not yet configured your kernel!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
GEN /home/rohan/HostApInjection/OutputDir/Makefile
# make O=../OutputDir archprepare
GEN /home/rohan/HostApInjection/OutputDir/Makefile
scripts/kconfig/conf -s arch/i386/Kconfig
***
*** You have not yet configured your kernel!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
make: *** [archprepare] Error 2
# make O=../OutputDir modules SUBDIRS=scripts

ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/rohan/HostApInjection/OutputDir/Module.symvers
is missing; modules will have no dependencies and modversions.

CC scripts/mod/empty.o
cc1: error: include/linux/autoconf.h: No such file or directory
make[3]: *** [scripts/mod/empty.o] Error 1
make[2]: *** [scripts/mod] Error 2
make[1]: *** [_module_scripts] Error 2
make: *** [modules] Error 2
# make O=../OutputDir modules SUBDIRS=drivers/net/wireless/hostap

ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/rohan/HostApInjection/OutputDir/Module.symvers
is missing; modules will have no dependencies and modversions.

Building modules, stage 2.
/home/rohan/HostApInjection/linux-source-2.6.20-2.6.20/scripts/Makefile.modpost:42: include/config/auto.conf: No such file or directory
make[2]: *** No rule to make target `include/config/auto.conf'. Stop.
make[1]: *** [modules] Error 2
make: *** [modules] Error 2
#

Angus said...

To stop orinoco_cs from loading try creating a file called:

hotplug/blacklist.d/hostap-utils

and write to it:

orinoco_pci
orinoco_cs
orinoco_plx
hermes

Hope it helps.

Angus said...

To fix:

***
*** You have not yet configured your kernel!
***

Have you tried doing a 'make oldconfig'?

Anonymous said...

For anyone else having problems compiling simply replace the "make O" commands to "make 0" and it will compile properly.
Thanks for this kick-ass tut btw Angus!!!

Anonymous said...

For anyone else having problems compiling simply replace the "make O" commands to "make 0" and it will compile properly.
Thanks for this kick-ass tut btw Angus!!!

Anonymous said...

For anyone else having problems compiling simply replace the "make O" commands to "make 0" and it will compile properly.
Thanks for this kick-ass tut btw Angus!!!

charles said...

it either wont compile (tells me to make menuconfig, which i did) or it scrolls constantly - this is at the make O=../Outputdir steps

Anonymous said...

Has anyone solved the errors?

*** You have not yet configured your kernel!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2

If you change the "make 0" it still does not solve the problem.