Kernel Socks Bouncer for 2.6.x kernels


0] HOW KSB26 WORKS
1] HOW TO INSTALL KSB26
2] CONCLUSION

0] HOW KSB26 WORKS and WHY A KERNEL PATCH? 


* KSB26 redirects connections through a socks5 server to improve your anonimity on the Net.
* Only connections to user-defined hosts will be bounced.

* I have choosen this implementation simply to enjoy myself writing in kernel space.


1] HOW TO INSTALL KSB26


1.0] Installation script [ Recommended ]


Default path of the Linux kernel source directory is:
kernel_dir=/usr/src/linux
Default path for the installation of ksb26manager [userspace tool] is:
bin_dir=/usr/bin
You can modify this two path simply editing install.sh
To install KSB26 simply run ./install.sh 
This script will: 
* patch your Linux kernel backuping changed files.
* build ksb26lkm.c, the Linux kernel module for KSB26 and copy ksb26lkm.ko to
/lib/modules/2.6.x/extra
* copy ksb26manager, the managment tool for KSB26 to /usr/bin [default]
->GOTO 1.2]


1.1] Manual installation

* Unpack ksb26-x-x-x.tar.gz archive
~# mv ksb26-x-x-x.tar.gz /usr/src
~# cd /usr/src
~# tar zxvf ksb26.tar.gz

* Patch Linux Kernel source [using ksb26.patch]
~# cp ksb26/kernel/ksb26.patch linux
~# cd linux
~# patch -p0 < ksb26.patch

* Build ksb26lkm.c [Linux Kernel Module] [running makemod.sh shell script]
~# cd /usr/src/ksb26/kernel
~# ./makemod.sh

* Copy ksb26lkm.ko to /lib/modules/2.6.x/extra where 2.6.x is the version
of the Linux Kernel you're using.

* Copy ksb26manager [KSB26 Manager] to /usr/bin
[For more informations about ksb26manager read 1.5]
->GOTO 1.2]

1.2] Rebuild your Linux Kernel
* Rebuild Linux Kernel and install the new image.
~# cd /usr/src/linux
~# make
~# cp arch/i386/boot/bzImageKSB26 /boot
* Create a new boot image in the boot loader configuration file and reboot.
[Do not overwrite existing kernel, because it may be usefull in case of emergencies]
Example of lilo configuration file [/etc/lilo.conf]
image = /boot/bzImageKSB26
	root = /dev/hda1
	#root = /devices/discs/disc0/part3
	label = Linux-KSB26

1.3] Loading ksb26 module and /dev/ksb26 device creation
~# insmod ksb26lkm.ko // loads the module with default configuration

* Create a character device in /dev directory using major number of ksb26lkm kernel module.
To detect major number read dmesg kernel logs running for example:
~# dmesg
or
~# cat /var/log/messages
Between messages of KSB26 module there's this string:
[KSB26] Major device number = num
~# mknod /dev/ksb26 c num 0 // creates the char device

1.4] /dev/ksb26 device
Accepted strings are:
* ip addresses and port of socks5
* ip addresses of target hosts [when KSB26 finds a new connection from localhost
to that host, this connection will pass through socks5 before reach the target host]
* clear socks list string [ csl ] : ksb26lkm clears the socks5 list

To add a new socks5 to the list:
~# echo "Sip:port;" > /dev/ksb26
Example:
~# echo "S123.123.123.123:1080;" > /dev/ksb26

To add a new target host:
~# echo "Hip;" > /dev/ksb26
Example:
~# echo "H12.34.56.78;" > /dev/ksb26

To clear socks5 list:
~# echo "csl" > /dev/ksb26

1.5] ksb26manager
YOU ARE NOT OBLIGED TO USE THIS TOOL, infact you can write manually ips to the
character device.

*ksb26manager is a tool that keeps socks5 list updated and flushes older lists.
It needs wget, egrep, sed and cat to work.
Configuration:
edit /usr/bin/ksb26manager [the copy that will be ran]
Set these:
thosts_file=/root/thosts	#File containing target hosts
sleep_time=240			#Seconds between socks5 and target hosts list updates

Sleep time is the number of seconds between updates of the socks5 list.

Target hosts ips' have to be written in thost_file. The format of this file:
Hip1;
Hip2;
Hip3;

2] CONCLUSION
For any question, problem or request write me to:
ardoino.gnu@disi.unige.it
