Please consider donating: https://www.corelan.be/index.php/donate/


6,548 views

Creating and installing lzm modules in Backtrack 2

Today, I will explain how you can create your own lzm modules & patch the backtrack 2 final ISO file (by adding your new module).

First of all, get a fresh copy of the bt2final.iso file from http://www.remote-exploit.org/backtrack_download.html

Write the ISO file to a CD and boot from the CD. This will load the bt2final version. By default, if you make changes to the live cd, the changes will be lost after rebooting the CD. You can of course install Backtrack to harddisk or a USB stick and install your patches afterwards, but you would still create some scripts to make sure changes to the filesystem are stored and used next time.

So ideally, you would want to include your custom scripts, new tools, updated tools or drivers into the ISO file, so you can use it to either boot from CD (including your own scripts) or install it to harddisk/usb and use your own tools as well.

These tools can be loaded at boot time by converting them into a module and adding the module into the boot process by adding the module into the ISO file.

This is how it works.

First of all, I’ll show you how you can create your own module (lzm file). Basically, there are 2 ways to create a lzm file : either from a directory, or from a source tarball.

Create a lzm file from a directory

Suppose you have a script myscript.sh that needs to be place in /usr/bin. First of all, boot up backtrack
Next, create the following folder structure (reflecting the file paths that will be used by your script and script lzm file) :

bt ~ # cd /tmp
bt tmp # mkdir MODULE
bt tmp # mkdir -p MODULE/usr/bin

Next, copy the file(s) into the folder structure. Put the file(s) in the right place within that structure

bt tmp # cp myscript.sh MODULE/usr/bin

Create a lzm file from the folder structure

bt tmp # dir2lzm MODULE/ module.lzm
[======================================================================] 1/1 100%
bt tmp #
bt tmp # ls -l module.lzm
-r——– 1 root root 4096 Feb 27 11:30 module.lzm

 

 

Create a lzm file from a source tarball

If your tool or script needs to be installed/compiled, then there’s another way to create a lzm file :

Boot from the Backtrack CD and put the source tarball on your system. Let’s assume you want to convert “authforce-0.9.8.tar.gz” into a lzm module, but the tool needs to be compiled first

First, extract the files and run the ./configure and make tool

bt ~ # tar zxpf authforce-0.9.8.tar.gz
bt ~ # cd authforce-0.9.8
bt authforce-0.9.8 # ./configure
bt authforce-0.9.8 # make

Next, run “checkinstall”. This will automatically launch “make install”, so you don’t have to do it yourself

bt authforce-0.9.8 # checkinstall

Creating package authforce-0.9.8-i386-1…OK

A tgz file is being generated as result from the checkinstall script.

Finally, convert the tgz package into a lzm file :

bt authforce-0.9.8 # tgz2lzm authforce-0.9.8-i386-1.tgz authforce-0-9-8.lzm
Installing package authforce-0.9.8-i386-1…
PACKAGE DESCRIPTION:
authforce: Package created with checkinstall 1.5.3
Executing install script for authforce-0.9.8-i386-1…

[=========================================] 19/19 100%

You are now left with a file called authforce-0.9.8.lzm

 

Patch the ISO file

After creating your lzm files, you need to put those files on CD. In order to do so, you need to edit the ISO file. Either mount the original ISO file from backtrack or edit the ISO file using a tool such as Magic ISO

The new lzm files need to be placed in the /BT/modules folder. If you use MagicISO, this is as easy as dragging & dropping the files in that folder. Save the ISO file, burn to CD, and you’re done.

If you want to do it from within Backtrack, use the following procedure :

Create a temp folder and mount the ISO file (stored as /tmp/bt2final.iso)

bt tmp # mkdir /tmp/INSTALL
bt tmp # mkdir /mnt/iso
bt tmp # mount -o loop -t iso9660 /tmp/bt2final.iso /mnt/iso
bt tmp # cp -rf /mnt/iso/* /tmp/INSTALL/

Copy the new module into the BT/modules folder :

bt tmp # cp /tmp/module.lzm /tmp/INSTALL/BT/modules

 

Recreate the ISO file :

bt tmp # cd INSTALL/BT/
bt BT # ./make_iso.sh
Target ISO file name [ Hit enter for ../../BT.iso ]: /tmp/bt2final-mod.iso
mkisofs 2.01 (i686-pc-linux-gnu)

Scanning ../.
Scanning .././BT
Scanning .././BT/base
Scanning .././BT/configs
Scanning .././BT/modules
Scanning .././BT/optional

Done with: Directory tree cleanup Block(s) 0
Writing: Extension record Start Block 65
Done with: Extension record Block(s) 1
Writing: The File(s) Start Block 66
1.41% done, estimate finish Fri Mar 9 02:22:37 2007
2.81% done, estimate finish Fri Mar 9 02:22:37 2007
4.21% done, estimate finish Fri Mar 9 02:22:13 2007
5.61% done, estimate finish Fri Mar 9 02:22:19 2007

Total translation table size: 2048
Total rockridge attributes bytes: 8261
Total directory bytes: 34816
Path table size(bytes): 244
Done with: The File(s) Block(s) 356309
Writing: Ending Padblock Start Block 356375
Done with: Ending Padblock Block(s) 150
Max brk space used 0
356525 extents written (696 MB)

 

Now write the new ISO file and you’re ready to rock ‘n roll again

 

Links : http://backtrack.offensive-security.com

© 2007 – 2015, Peter Van Eeckhoutte (corelanc0d3r). All rights reserved.

Comments are closed.

Corelan Training

We have been teaching our win32 exploit dev classes at various security cons and private companies & organizations since 2011

Check out our schedules page here and sign up for one of our classes now!

Donate

Want to support the Corelan Team community ? Click here to go to our donations page.

Want to donate BTC to Corelan Team?



Your donation will help funding server hosting.

Corelan Team Merchandise

You can support Corelan Team by donating or purchasing items from the official Corelan Team merchandising store.

Protected by Copyscape Web Plagiarism Tool

Corelan on Slack

You can chat with us and our friends on our Slack workspace:

  • Go to our facebook page
  • Browse through the posts and find the invite to Slack
  • Use the invite to access our Slack workspace
  • Categories