Uwe Hermann: Miro 2.0


raid5: raid level 5 set md1 active with 3 out of 3 devices, algorithm 2 RAID5 conf printout: --- rd:3 wd:3 disk 0, o:1, dev:hda2 disk 1, o:1, dev:hdg2 disk 2, o:1, dev:hde2 [...] hdg: dma_timer_expiry: dma status == 0x21 hdg: DMA timeout error hdg: 4 bytes in FIFO hdg: dma timeout error: status=0x50 DriveReady SeekComplete ide: failed opcode was: unknown hdg: dma_timer_expiry: dma status == 0x21 hdg: DMA timeout error hdg: 252 bytes in FIFO hdg: dma timeout error: status=0x50 DriveReady SeekComplete ide: failed opcode was: unknown hdg: dma_timer_expiry: dma status == 0x21 hdg: DMA timeout error hdg: 252 bytes in FIFO hdg: dma timeout error: status=0x58 DriveReady SeekComplete DataRequest ide: failed opcode was: unknown hdg: DMA disabled ide3: reset: success hdg: dma_timer_expiry: dma status == 0x21 hdg: DMA timeout error hdg: 252 bytes in FIFO hdg: dma timeout error: status=0x58 DriveReady SeekComplete DataRequest ide: failed opcode was: unknown hdg: DMA disabled ide3: reset: success hdg: status timeout: status=0x80 Busy ide: failed opcode was: 0xea hdg: drive not ready for command hdg: lost interrupt hdg: task_out_intr: status=0x50 DriveReady SeekComplete ide: failed opcode was: unknown hdg: lost interrupt hdg: task_out_intr: status=0x50 DriveReady SeekComplete ide: failed opcode was: unknownThat's when I realized that something was horribly wrong. Not long after that, these messages appeared in dmesg. As you can see the software-RAID automatically realized that a drive died and removed the faulty disk from the array. I did not lose any data, and the system did not freeze up; I could continue working as if nothing happened (as it should be).
md: super_written gets error=-5, uptodate=0 raid5: Disk failure on hdg2, disabling device. raid5: Operation continuing on 2 devices. RAID5 conf printout: --- rd:3 wd:2 disk 0, o:1, dev:hda2 disk 1, o:0, dev:hdg2 disk 2, o:1, dev:hde2 RAID5 conf printout: --- rd:3 wd:2 disk 0, o:1, dev:hda2 disk 2, o:1, dev:hde2This is how you can check the current RAID status:
$ cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md1 : active raid5 hda2[0] hde2[2] hdg2[3](F) 584107136 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U]The "U_U" means two of the disks are OK, and one is faulty/removed. The desired state is "UUU", which means all three disks are OK. The next steps are to replace the dead drive with a new one, but first you should know exactly which disk you need to remove (in my case: hda, hde, or hdg). If you remove the wrong one, you're screwed. The RAID will be dead and all your data will be lost (RAID5 can survive only one dead disk at a time). The safest way (IMHO) to know which disk to remove is to write down the serial number of the disk, e.g. using smartctl, and then check the back side of each disk for the matching serial number.
$ smartctl -i /dev/hda grep Serial $ smartctl -i /dev/hde grep Serial $ smartctl -i /dev/hdg grep Serial(ideally you should get the serial numbers before one of the disks dies) Now power down the PC and remove the correct drive. Get a new drive which is at least as big as the one you removed. As this is software-RAID you have quite a lot of flexibility; the new drive doesn't have to be from the same vendor / series, it doesn't even have to be of the same type (e.g. I got a SATA disk instead of another IDE one). Insert the drive into some other PC in order to partition it correctly (e.g. using fdisk or cfdisk). In my case I needed a 1 GB /boot partition for GRUB, and the rest of the drive is another partition of the type "Linux RAID auto", which the software-RAID will then recognize. Then, put the drive into the RAID PC and power it up. After a successful boot (remember, 2 out of 3 disks in RAID5 are sufficient for a working system) you'll have to hook-up the new drive into the RAID:
$ mdadm --manage /dev/md1 --add /dev/sda2 mdadm: added /dev/sda2My new SATA drive ended up being /dev/sda2, which I added using mdadm. The RAID immediately starts restoring/resyncing all data on that drive, which may take a while (2-3 hours, depends on the RAID size and some other factors). You can check the current progress with:
$ cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md1 : active raid5 sda2[3] hda2[0] hde2[2] 584107136 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U] [>....................] recovery = 0.1% (473692/292053568) finish=92.3min speed=52632K/secAs soon as this process is finished you'll see this in dmesg:
md: md1: recovery done. RAID5 conf printout: --- rd:3 wd:3 disk 0, o:1, dev:hda2 disk 1, o:1, dev:sda2 disk 2, o:1, dev:hde2In /proc/mdstat you'll see "UUU" again, which means your RAID is fully functional and redundant (with three disks) again. Yay.
$ cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md1 : active raid5 sda2[1] hda2[0] hde2[2] 584107136 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]Btw, another nice utility you might find useful is hddtemp, which can check the temperature of the drives. You should take care that they don't get too hot, especially so if the RAID runs 24/7.
$ hddtemp /dev/hda dev/hda: SAMSUNG HD300LD: 38 C $ hddtemp /dev/hde dev/hde: SAMSUNG HD300LD: 44 C $ hddtemp /dev/sda dev/sda: SAMSUNG HD322HJ: 32 C
$ mkfs.vfat /dev/mmcblk0p1 (you may need to change "mmcblk0p1" to whatever fits your setup)Now insert the SD card into the Wii, start the Wii, go to Wii Options --> Data Management --> Save Data --> Wii and copy your Twilight Princess save games onto the SD card. Then, poweroff, remove the SD card, insert it into your laptop/PC and copy the save games to a safe place.
$ mount -t vfat /dev/mmcblk0p1 /mnt $ mv /mnt/private ~/zelda_savegamesTwilight Hack and Homebrew Channel
$ wget http://hbc.hackmii.com/dist/twilight-hack-v0.1-beta1.zip $ unzip twilight-hack-v0.1-beta1.zip $ cp -r private /mnt $ wget http://hbc.hackmii.com/dist/the_homebrew_channel-1.0.1.tar.gz $ tar xfvz the_homebrew_channel-1.0.1.tar.gz $ cp the_homebrew_channel-1.0.1/boot.dol /mnt $ umount /mntNow remove the SD card, insert it into the Wii and power-up the Wii. Go to Wii Options --> Data Management --> Save Data --> Wii, delete the Wii Twilight Princess save games, then copy the "Twilight Hack" save game from the SD card onto the Wii (you need to select the correct one for your region). Quit the menu, start Twilight Princess, load the "Twilight Hack" savegame and finally talk to the person in front of you (do not perform any other actions, or the Wii may crash!). Follow the remaining instructions on the screen and you're done. You now have an additional channel named Homebrew Channel where all your homebrew programs/games (and your own Free Software programs you may write/port) will appear. Installing homebrew software So far, there are no real applications in the Homebrew Channel, you need to put all the homebrew software you want on the SD card. There's a huuuge list of applications and games to choose from, many of them Free Software with source code, some however are binary-only. Basically, you put each application in a sub-directory of apps/ on the SD card, the most important file in every sub-directory is always boot.dol. If you have a boot.elf file instead, you'll probably need to convert it using the ELF to DOL converter. Restoring Twilight Princess save games You may now want to restore your Twilight Princess save games onto the Wii, you no longer need the "Twilight Hack" save game. Put your ~/zelda_savegames directory on the SD card and name it private/ again. Insert the SD card into the Wii and copy the save games on the Wii (similar procedure as above). Have fun with homebrew software on your Wii, or even better write your own software or port existing Linux applications/games!
“there’s a huge amount of potentially privacy-sensitive metadata in your typical JPEG as generated by your camera (including camera type, settings, date/time, maybe even GPS coordinates of your location, etc).” Source: jhead - List and modify EXIF fields in JPEG photos [Uwe Hermann's blog]Even worse, if you’ve been using images from your suppliers or the manufacturers without permission, the metadata can be a dead giveaway. You really shouldn’t be using them without permission anyway, though. If you’re using your own photos, want to remove the camera data and you’re not comfortable using the command line, most graphics editors like GIMP allow you to edit or remove that extra information too (I think it’s on Save As… OK… Advanced Options and untick “Save EXIF data” in GIMP). It’s just a bit slower to convert lots of images with a GUI. (I’d usually do that sort of thing from the command line for TTLLP customers.) One fringe benefit is that removing the thumbnails and EXIF makes the images a bit smaller, so they’re quicker to download!
$ apt-get install wine (as root) $ winecfgThe winecfg (graphical) utility will setup some config file defaults in your ~/.wine directory. Click on Graphics and activate Allow DirectX apps to stop the mouse leaving their window. Also, click on Audio (a dialog will pop up, just click OK). This will autodect your soundcard and setup Wine to use it. Under Drives click Add (this will add D:) and change the path to /media/cdrom, so that Wine knows about your CD-ROM drive. Finally click OK to close winecfg and save the settings.
$ mount /media/cdrom (as root) $ wine /media/cdrom/setup.exeFollow the instructions in the installer until the Starcraft install is finished (you'll need your CD key number), then exit the installer (don't start playing Starcraft right away). The next step is to get the latest patch and get rid of the need to insert the CD-ROM every time.
$ wget http://ftp.blizzard.com/pub/starcraft/patches/PC/SC-116.exe $ wine SC-116.exeAfter the patch is installed click OK and Starcraft will be started (very annoying). Leave the game again. We'll get rid of the CD-ROM requirement now:
$ cp /media/cdrom/install.exe ~/.wine/drive_c/Programme/Starcraft/StarCraft.mpqThat's a pretty big file, it may take a while. You might have to change "Programme" in the path (I have the German Starcraft version). That's it. You can now play Starcraft (without needing the CD-ROM) using:
$ wine ~/.wine/drive_c/Programme/Starcraft/StarCraft.exeA good thing is, it even works nice and fast with the open-source nv NVIDIA driver (no need to install the proprietary driver). I noticed one very annoying "bug" with the mouse behaviour at first. The mouse would sometimes just get stuck during the game (which is a total disaster of course, if you're in the middle of a fast-paced game). Left-clicking somewhere would "unstuck" the mouse, but it's still very bad. After many, many hours of reading bugreports and trying various patches I finally found out the root cause for the problem. It's somehow related to my window manager (IceWM); whenever you move the mouse to the bottom of the Starcraft screen (where the IceWM status bar is, even though it's not on top or even visible, and even though Wine/Starcraft runs in full-screen mode!), something funny happens with X11/IceWM and the mouse gets stuck. I haven't yet found out if/which IceWM option could fix this behavior, but I have a small work-around. Just start Wine directly on a second X11 server with Starcraft (without any window manager being involved):
$ xinit -e '/usr/bin/wine ~/.wine/drive_c/Programme/Starcraft/StarCraft.exe' -- :1No patches needed (stock Wine from Debian unstable works fine, that's version 1.0.1 right now). I hope this saves other people some debugging time...
$ apt-get install jheadIt can display/extract a great amount of metadata fields from JPEG files and also extract the thumbnails stored in JPEG files (if any). The following will list all known metadata fields from a sample photo:
$ wget http://farm4.static.flickr.com/3173/3061542361_60acb0904b_o.jpg $ jhead *.jpg File name : 3061542361_60acb0904b_o.jpg File size : 1074172 bytes File date : 2008:11:26 23:38:04 Camera make : Panasonic Camera model : DMC-FZ18 Date/Time : 2008:03:05 15:45:52 Resolution : 3264 x 2448 Flash used : No Focal length : 4.6mm (35mm equivalent: 28mm) Exposure time: 0.0100 s (1/100) Aperture : f/3.6 ISO equiv. : 100 Whitebalance : Auto Metering Mode: matrix Exposure : program (auto) GPS Latitude : N %:.7fd %;.8fm %;.8fs GPS Longitude: E %;.8fd %:.7fm %;.8fs GPS Altitude : 174.00m Comment : Aufgenommen auf dem <a href="http://www.froutes.de/TT00000014_Ars_Natura">Kunstweg Ars Natura</a>. ======= IPTC data: ======= Record vers. : 4 Headline : Felsburg auf dem Felsberg (C)Notice : www.froutes.de Caption : Aufgenommen auf dem <a href="http://www.froutes.de/TT00000014_Ars_Natura">Kunstweg Ars Natura</a>.As you can see there's a huge amount of potentially privacy-sensitive metadata in your typical JPEG as generated by your camera (including camera type, settings, date/time, maybe even GPS coordinates of your location, etc). You can extract the thumbnail stored in all JPEGs in the current directory with:
$ jhead -st "&i_t.jpg" *.jpg Created: '3061542361_60acb0904b_o.jpg_t.jpg'
$ jhead -purejpg *.jpg Modified: 3061542361_60acb0904b_o.jpgAs you can see the result is that only very basic information can be gathered from the file afterwards:
$ jhead *.jpg File name : 3061542361_60acb0904b_o.jpg File size : 1052506 bytes File date : 2008:11:26 23:38:04 Resolution : 3264 x 2448 $ jhead -st "&i_t.jpg" *.jpg Image contains no thumbnailI recommend doing this for most photos you make publically available on sites like flickr etc. (unless you have a good reason not to). Finally, see the jhead(1) manpage for lots more options that the tool supports.
$ openocd -f parport.cfg -f lpc2148.cfgThen, in another xterm for example, connect to the now-running OpenOCD telnet server. Here you can now run various commands to probe, control and program the JTAG device(s). Try help for a list of commands. As an example, for flashing a binary onto some LPC2148 eval board you would do something like this:
$ telnet localhost 4444 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > reset init JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4) srst pulls trst - can not reset into halted mode. Issuing halt after reset. target state: halted target halted in Thumb state due to debug-request, current mode: Supervisor cpsr: 0x800000f3 pc: 0x7fffd2a2 requesting target halt and executing a soft reset target state: halted target halted in ARM state due to debug-request, current mode: Supervisor cpsr: 0x800000d3 pc: 0x00000000 > flash write_image /home/foo/program.bin 0 wrote 1236 byte from file /home/foo/program.bin in 0.533683s (2.261701 kb/s) > resume 0The final resume 0 will start to execute your program on the ARM LPC2148 microcontroller. Check out the openocd info page (info openocd on the command line) for lots more documentation.
$ apt-get install youtube-dl $ youtube-dl http://www.youtube.com/watch?v=X72LgcMpM9kThe talk includes various demos of coreboot and various payloads you can use with coreboot. One nice example is the TINT payload, a Tetris-like game for Linux (
apt-get install tint
for the curious), which has been reworked to be usable as a coreboot payload.
$ modprobe ohci1394 phys_dma=0I have personally tested this on some boxes and I can confirm that it renders the currently published tools useless. As for the new "juju" Firewire stack, I'm not so sure. A few quick tests showed that the currently available tools don't work with the new stack, but you shouldn't feel too secure! AFAIK the new stack does support (or will support soon) physical DMA for Firewire, so it's probably just a matter of adapting the tools a bit (I'll do some testing/research on this later, as time permits). Mitigation: Mac OS On Mac OS you might also be able to completely remove Firewire support from the kernel (but I don't know if/how that can be done, not sure if you can easily recompile Mac OS kernels, and/or if you even have buildable source code and toolchains for that). However, you can at least remove the Firewire support in the default Mac OS installation by unloading AppleFWOHCI.kext:
$ sudo kextunload /System/Library/Extensions/IOFireWireFamily.kext/Contents/PlugIns/AppleFWOHCI.kextThanks to a Daniel Reutter for letting me abuse his MacBook via Firewire and for finding the above kextunload command line. We have successfully tested that after unloading AppleFWOHCI.kext the current tools won't work anymore. The tests were done on a Mac OS X Tiger (I think) with all recent security updates applied. Please leave a comment if you can test other versions of Mac OS X... Mitigation: Windows As for Windows, well, I guess you're screwed. While Windows XP does implement sort of "protection" in that it only allows physical DMA access via Firewire to devices which "deserve it", e.g. iPods (or any other Firewire mass storage device, I guess) this can be easily defeated by having your attack PC/laptop pretend to be an iPod (see the romtool Python script by Adam Boileau). The only remaining option I know of (short of removing/destroying Firewire ports or preventing physical access alltogether) is to disable the Firewire ports/drivers in the device manager (untested by me so far). If you do that, remember to also disable all PCMCIA/Cardbus/ExpressCard controllers, of course (see above). So far I've tested Windows XP SP2/SP3 successfully with Adam Boileau's tools. I haven't yet been able to test Windows 95/98/Vista, if you can verify one of them, please leave a comment. Mitigation: OpenBSD/FreeBSD/NetBSD/OpenSolaris/... On OpenBSD you're likely not vulnerable as OpenBSD doesn't have any Firewire drivers at all, as far as I know ;-) As for FreeBSD, NetBSD, OpenSolaris, and other OSes I don't have any information. I might be able to test one or two of them in the nearer future, but please leave a comment if you have some information about whether they are vulnerable and/or how you can secure your system... Conclusion That's it for now. I hope you now have a good overview of these issues and how to protect. I can only urge you to take this problem seriously! Three or four minutes of leaving your laptop unattended are fully sufficient for an attacker to get a full forensic image of all your RAM contents for later analysis. This is at least as critical as the Cold Boot attacks, if not worse. I will follow-up with more articles about some more interesting details on these Firewire issues, how to use the above tools, and I'll report on some of the stuff I was able to find in RAM dumps gathered via Firewire...
$ time ssh-keygen -t rsa -b 32768 -f ~/.ssh/tmp32768 -N foobar -q real 244m31.259s user 244m15.664s sys 0m4.736sIn other words, on my test system (AMD X2 CPU with 1.8 GHz per core) it took ca. 4 hours. This is likely very dependent on how much entropy you can get (and how fast), so take the numbers with a grain of salt. A second key with 32767 bits (one less) took 16 hours, for instance. The resulting tmp32768 (private key) file is ca. 25 KB big, the tmp32768.pub (public key) file is 5 KB big. There's likely no noticeable performance hit for ssh or scp AFAICS, as all data transfers are done with a symmetrical session key, not the RSA key itself. Only the initial connection "handshake" will take ca. 40 seconds longer... And yes, 32768 is the maximum RSA key size you can currently create with OpenSSH, go file a bug report if that's not enough for you ;-) However, as I then noticed, this key will not actually work. When you put it in some authorized_keys file and try to login, the handshake will fail and the server-side will see the following error in /var/log/auth.log:
sshd[xxxxxx]: error: RSA_public_decrypt failed: error:04067069:lib(4):func(103):reason(105)I first thought I found an off-by-one error, but the 32767 bit key (one bit less) didn't work either. After looking through the OpenSSH and OpenSSL code as well as the RSA_private_decrypt(3SSL) manpage a bit, I saw that OpenSSH uses the RSA_PKCS1_PADDING parameter. My current theory is thus that some padding is making the key not work. I'm now creating a key with 11 bits less bits than 32768, let's see what happens. For the record, a key with 16384 bits does work just fine. Anyway, I'll probably report this as "bug" (more a theoretical than a practical problem, though) as ssh-keygen let's you generate RSA keys which will never work in practice...
Next.