Unpack script ASA 8.4(2) under QEMU with GNS3

Full credit goes to our good community friend “dmz” from 7200emu.hacki forum.
He was able to write a patch that automates the process of extracting the kernel and initrd of version 8.4(2).

This really saves us all from the burden of finding the right offset location of the header not mentioning all the necessary patches that needs to be done to be able to run the asa with as much features as possible.

DISCLAIMER: All the information provided in this post are for self-education purposes only. Use it at your own risk.

 

I’m using ubuntu 10.10-64 bit , but you can use any Linux or Unix distros that you have, as the patch doesn’t need any special package to run.

1. Prepare your asa842-k8.bin image. You can get one from cisco website using your  cco account.
2. Get the script   ((  repack.v4.sh )) unpack the file and make it executable.

bash-4.1#
bash-4.1# tar xvf repack.v4.sh.tar
repack.v4.sh
bash-4.1#
bash-4.1# chmod +x repack.v4.sh
bash-4.1#

3. Run the script with a privilege user:

 

bash-4.1#
bash-4.1# sudo ./repack.v4.sh asa842-k8.bin
Repack script version: 4
Detected syslinux/cdrtools – ISO will be created
1359344+0 records in
1359344+0 records out
1359344 bytes (1.4 MB) copied, 4.88292 s, 278 kB/s
23697936+0 records in
23697936+0 records out
23697936 bytes (24 MB) copied, 83.464 s, 284 kB/s
/tmp/tmp.kjYBVS /home

gzip: /home/asa842-initrd-original.gz: decompression OK, trailing garbage ignored
114476 blocks
114476 blocks
114476 blocks
/home
/tmp/tmp.xn9fHR /home
Setting input-charset to ‘ISO-8859-1’ from locale.
Size of boot image is 4 sectors -> No emulation
 21.04% done, estimate finish Mon Jan 06 08:54:54 2011
 42.00% done, estimate finish Mon Jan 06 08:54:54 2011
 63.00% done, estimate finish Mon Jan 06 08:54:54 2011
 84.03% done, estimate finish Mon Jan 06 08:54:54 2011
Total translation table size: 2048
Total rockridge attributes bytes: 0
Total directory bytes: 2048
Path table size(bytes): 26
Max brk space used 21000
23814 extents written (46 MB)
/home
bash-4.1#

 

4. This will give you three files:

 

bash-4.1#
bash-4.1# ls
asa842-initrd-original.gz
asa842-initrd.gz
asa842-k8.bin
asa842-vmlinuz
repack.v4.sh.tar.gz
repack.v4.sh

 

5. And that’s pretty much it. You can now import the kernel (asa842-vmlinuz) and ram disk file (asa842-initrd.gz) to gns3. Don’t forget to add the ‘-icount auto‘ to qemu options as this will help us to bypass the divizion by zero exception error and allows us to do a reload in our qemu-emulated asa.

Thanks to my Friends

dmz , chicany , twopacket

 

 

 

10 thoughts on “Unpack script ASA 8.4(2) under QEMU with GNS3

  1. Hee Soo says:

    I am having problems unpacking. Not sure where I am going wrong. Using Ubuntu 11.10 x64

    Below is my output

    khorsoo@acid:~/Desktop$ sudo ./repack.v4.sh asa842-k8.bin
    Repack script version: 4
    no syslinux/cdrtools – ISO creation skipped
    1359344+0 records in
    1359344+0 records out
    1359344 bytes (1.4 MB) copied, 2.92724 s, 464 kB/s
    29577744+0 records in
    29577744+0 records out
    29577744 bytes (30 MB) copied, 66.674 s, 444 kB/s
    /tmp/tmp.fZNAA4yjBg ~/Desktop

    gzip: /home/khorsoo/Desktop/asa842-initrd-original.gz: not in gzip format
    cpio: premature end of archive
    1 block
    sed: can’t read etc/init.d/rcS: No such file or directory
    sed: can’t read etc/init.d/S10udev: No such file or directory
    sed: can’t read etc/init.d/S10udev: No such file or directory
    sed: can’t read etc/init.d/S40network: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/format_flash.sh: No such file or directory
    sed: can’t read asa/scripts/rcS.common: No such file or directory
    xxd: asa/bin/lina: No such file or directory
    1 block
    ~/Desktop

  2. RH says:

    The same problem here. Could you please help?

    adminuser-mint asa # sudo ./repack.v4.sh asa842-k8.bin
    Repack script version: 4
    no syslinux/cdrtools – ISO creation skipped
    1359344+0 records in
    1359344+0 records out
    1359344 bytes (1.4 MB) copied, 7.24461 s, 188 kB/s
    23697936+0 records in
    23697936+0 records out
    23697936 bytes (24 MB) copied, 147.414 s, 161 kB/s
    /tmp/tmp.OxDdnto0TL /tmp/asa

    gzip: /tmp/asa/asa842-initrd-original.gz: decompression OK, trailing garbage ignored
    114476 blocks
    114476 blocks
    114476 blocks
    /tmp/asa

    • cuzzindavid66 says:

      I am having same issue. The first error I notice is the “no syslinux/cdrtools — ISO creation skipped”? Is the lack of having these syslinux/cdrtools critical for the remaining outputs to be correct? I am using Ubuntu 11.04 64-bit. I definitely am in privilege mode because I have the pound symbol (#) at the command prompt. Also at the end of the scripts execution, you have “decompression OK, trailing garbage ignored…”? Is this ok? Will the files created still work despite not having the same output?

  3. Dhavalsoni says:

    In ubuntu 11.0 or later “syslinux” is located at “/usr/lib” while in script “repack.sh” they need a path of syslinux in “/usr/share” so you need to copy “syslinux” from “/usr/lib” to “/usr/share”…

    • cuzzindavid66 says:

      Thanks Dhavalsoni, instead I modified the path in the script to the /usr/lib/syslinux/ location. Even though now it creates and iso, the ASA does nothing when I hit the start button, despite successful tests to qemu.

  4. Peyton Campbell says:

    I have been trying to unpack asa841-k8.bin because I have that file. I tried to do this in CentOS, butthe repack script kept failing. I downloaded and installed Unbuntu 12.04 Desktop and the results are below. I did change the script to reflect syslinux in /etc/lib and changed all the instances of asa842-k8.bin to asa841-k8.bin. I am not proficient at coding at all, but I can sometimes figure out what the script is trying to do. Any help would be appreciated.

    Thanks,

    Repack script version: 4
    Detected syslinux/cdrtools – ISO will be created
    1359344+0 records in
    1359344+0 records out
    1359344 bytes (1.4 MB) copied, 20.5923 s, 66.0 kB/s
    23476752+0 records in
    23476752+0 records out
    23476752 bytes (23 MB) copied, 355.286 s, 66.1 kB/s
    /tmp/tmp.1Xmiqrr3A4 ~/Downloads

    gzip: /home/peyton/Downloads/asa841-initrd-original.gz: not in gzip format
    cpio: premature end of archive
    1 block
    sed: can’t read etc/init.d/rcS: No such file or directory
    sed: can’t read etc/init.d/S35network: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/rcS: No such file or directory
    sed: can’t read asa/scripts/format_flash.sh: No such file or directory
    sed: can’t read asa/scripts/rcS.common: No such file or directory
    xxd: asa/bin/lina: No such file or directory
    1 block
    ~/Downloads
    /tmp/tmp.VFEsdJ8R9P ~/Downloads
    I: -input-charset not specified, using utf-8 (detected in locale settings)
    Size of boot image is 4 sectors -> No emulation
    Total translation table size: 2048
    Total rockridge attributes bytes: 0
    Total directory bytes: 2320
    Path table size(bytes): 26
    Max brk space used 0
    857 extents written (1 MB)
    ~/Downloads

  5. zipphreak says:

    For this error:
    gzip: /home/peyton/Downloads/asa841-initrd-original.gz: not in gzip format
    cpio: premature end of archive

    You need to transfer your asa842-k8.bin to the Linux server using BINARY mode in FTP, not ASCII mode or you will get this error. Once you resolve you can proceed with unpacking.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.