Silly Science Electronics, Programming and Hacking About

17May/130

Accessing partitions within an image or LVM volume used as an iSCSI target

I recently reinstalled the software on my NAS (open media vault) and tidied up the host name etc. As part of this I changed the name of the iSCSI target. This meant that my media PC wouldn't boot over the network (I set it up using XBMCbuntu using this guide - http://www.heath-bar.com/blog/?p=184). To solve this I managed to mount the partition on the NAS server itself and modify the necessary boot parameters.

To mount it I did the following:

  1. Install kpartx:
  2. sudo apt-get install kpartx

  3. Create a loopback device. This create /dev/mapper/loop0pX where X is the parition number
  4. sudo /sbin/losetup /dev/loop0 /dev/mapper/Target-LogicalVolume

  5. Mount the parition:
  6. sudo mount /dev/mapper/loop0p1 /tmp/iscsi-target-mnt

The reason I created the loopback device was because I kept receiving these errors:

$ sudo kpartx -a /dev/mapper/Target-LogicalVolume
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume1
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume2
device-mapper: reload ioctl failed: Invalid argument

Credit to http://www.skytale.net/blog/categories/5-Linux for pointing me in the right direction.

16Feb/130

/dev/md0 can’t read superblock

Sometimes when my Stora NAS gets rebooted the array fails to mount and I get

/dev/md0 can't read superblock

To correct this I do the following:

  1. Try mount /dev/md0 (you probably tried this and got the above error)
  2. Do xfs_repair /dev/md0
  3. If that refuses to repair then do xfs_repair -L /dev/md0

No guarantees this won't screw things up for you but it works for me.

15Feb/131

XBMC Frodo for Legacy AMD Graphics Cards (pre 5xxx)

Apparently AMD/ATI graphics cards less than 5xxx series have been left behind in the latest drivers. This is a bit of a pain for me as I have a 24xx series in my media PC. I tried the stock XBMCbuntu 12 ISO for AMD, but this left me with a non-working system. Going back the XBMCbuntu 11 and then doing a manual package upgrade seems to work:

sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc xbmc-bin
sudo apt-get upgrade

This upgrades everything, but keeps the base ubuntu install - so we get to keep the video drivers.

19Dec/121

MediaPC in a Xen Virtual Machine

The aim of this project was to get my MediaPC running as a VM host. This would allow me to run instances alongside my MediaPC, thus giving me a platform to experiment and develop things without having to setup separate machines etc.

I decided to use Xen on Ubuntu and found the Ubuntu Xen guide very useful.

Note: I never got this working - this is just documenting what I did and how it failed.

27Sep/120

Indefero errors fatal: bad argument fatal: The remote end hung up unexpectedly

I was trying to commit something to my Indefero project management server today and was getting the following error:

fatal: bad argument
fatal: The remote end hung up unexpectedly

I puzzled around for a while and then tried manually logging into the git server using a console SSH and was greeted with this:

$ ssh mygitserver.com
PTY allocation request failed on channel 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mhash.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mhash.so' - /usr/lib/php5/20090626+lfs/mhash.so: cannot open shared object file: No such file or directory in Unknown on line 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to mygitserver.com closed.

Those PHP errors are probably throwing Git off course and making it unhappy. The solution was two step:

  1. Edit /etc/php5/cli/conf.d/ming.ini to ensure that comments are pre-ceded by ';' and not '#'
  2. Move mhash.ini out of  /etc/php5/cli/conf.d/ as as it is no longer used in debian (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593266)

Doing the above two steps resulted in a clean session opening up when ssh'ing into the git server:

$ ssh mygitserver.com
PTY allocation request failed on channel 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to mygitserver.com closed.

Now pushing to the Git server works - yay!

 

Tagged as: , , , , No Comments
14Aug/121

Getting JetPack working

I had two issues with JetPack - but I finally got it working.

Issue one -

 Jetpack could not contact WordPress.com: register_http_request_failed.
This usually means something is incorrectly configured on your web host.
Operation timed out after 15000 milliseconds with 0 bytes received

This was resolved by setting the max_execution_time to 300 in my php.ini file - make sure you restart your webserver / fast cgi daemon.

Issue two -

Your website needs to be publicly accessible to use Jetpack: site_inaccessible
Error Details: The Jetpack server was unable to communicate with your site [IXR -32300: transport error: http_request_failed Operation timed out after 15000 milliseconds with 0 bytes received]

This was easily solved by changing the following value from 1 to 2 in my /etc/init.d/php-cgi script

PHP_FCGI_CHILDREN

(Credit to http://technology.bauzas.com/uncategorized/the-jetpack-server-was-unable-to-communicate-with-your-site/)

23Jun/125

Lenovo USB Modem in Linux (Ubuntu 10.04)

I recently bought a Lenovo USB modem for some experiments in telephony that I am working on. I want it to work on Linux. It is based on the Conexant RD02-D400 device. When plugging it in I get the following in dmesg:

cdc_acm 2-2:1.0: Zero length descriptor references
cdc_acm: probe of 2-2:1.0 failed with error -22

This seems to be a common problem - it looks like the cdc_acm driver is not correctly recognising and processing the descriptors.

The fix is pretty easy -

  1. Get root, install kernel source
  2. $ sudo -i
    # apt-get install linux-headers-uname -r linux-source-2.6.32
    # cd /usr/src
    # tar xjf linux-source-2.6.32.tar.bz2
    # ln -s linux-source-2.6.32 linux
    # cd /usr/src/linux

  3. Now edit the cdc_acm.c file
  4. # nano /usr/src/linux/drivers/usb/class/cdc-acm.c

  5. Add the following lines in the long list of entries that are similar to it:
  6. { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
    .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
    },

  7. Prepare configuration (will pull config file from /boot) and build the entire kernel
  8. # make oldconfig
    # make

  9. To re-build the driver (can now use this to rebuild if you get the VID/PID etc wrong)
  10. # make M=drivers/usb/class

  11. Remove current driver
  12. # rmmod cdc-acm

  13. Test the driver
  14. # insmod drivers/usb/class/cdc-acm.ko

  15. You should get something like
  16. cdc_acm 2-2:1.0: ttyACM0: USB ACM device

  17. Install the driver permanently
  18. # cd /lib/modules/uname -r
    # mv kernel/drivers/usb/class/cdc-acm.ko ~/cdc-acm.ko.bak
    # cp /usr/src/linux/drivers/usb/class/cdc-acm.ko kernel/drivers/usb/class/cdc-acm.ko
    # depmod -a

Note: I ended up using Ubuntu 10.04 because I was having a bit of a battle with 12.04. I suspect it was just some mistakes I made... the principles of the above should carry. Will update if I try it again on anything newer.

5Jun/120

Pairing Apple 1st Gen Keyboard (A1016) with Windows 7

I was having some errors pairing the Apple 1st Gen bluetooth keyboard to my media centre. I discovered that you need todo the following:

  1. Turn on the keyboard
  2. Open up Bluetooth 'Add Devices' and wait for windows to discover the keyboard
  3. Select the keyboard and proceed to the next step in the wizard
  4. While it is saying 'Connecting to device...' you need to type a code into the apple keyboard. Just type 1234 then return
  5. Windows will now ask you for the code - you'll need a working keyboard to enter this
  6. The keyboard should now be connected

Some users have reported that you will need to unpair the device with any previous computers - so you may need to do this as well.

3Dec/112

Can you crack it? Stage 3 solution

Once getting through stage 2 you will have an EXE file. It requires windows (I ran it in a VirtualBox VM seeing as I had no idea what it would do - can't be too careful!), cygwin and the crypt library when installing cygwin.

Running the EXE you will see that you require some kind of license.txt - if you create an empty one then you get an error about it being invalid. The next stage is working out what is required to make the license.txt file valid. Being new to this realm of reverse engineering, but being comfortable with work with ASM I tried a number of tools - strace, objdump and strings. Each yielded useful bits of information - especially strings.

However the real breakthrough came when I ran the exe file through a tool called IDA Pro - the freeware version is sufficient for this exercise.

Running the binary through IDA Pro produces a very comprehensive flow of the program. If you navigate this flow you will being to see calls to printf which relate to the message we get on the screen.

2Dec/114

Can you crack it? Stage 2 Solution

There has been a lot of news about the "Can you crack it?" challenge that is currently to publicise GCHQ recruiting. Here is my solution for stage 2 - the implementation of the Virtual Machine, or emulator. It's actually pretty straight forward when you get a hold of a few of the nuances. I'll put a list of hints here, and then present the full solution after the fold.

  1. As of stage 1 - everything is centred around the x86 architecture, this means that your instructions need to mirror the behaviour of their x86 equivalents
  2. Firmware seems to be irrelevant - don't worry about it.
  3. There is no real trickery here - it's just a straight forward instruction set simulator implementation
  4. The programme will finish on a HALT instruction

This is actually quite a neat little program that works by decrypting itself further programme code which it then runs and decrypts the message to get to the next stage... enjoy...