Archive for Aaron

Decoding “.264” Non-standard Video files from Cheap IP Camera

I’m in the process of tinkering with the Amicom WiFi-enabled Outdoor Security Camera.

Amazon store link.

As usual with these types of devices that I buy, I tend to get a bit obsessive about wanting to understand how the thing works internally.  Suffice it to say I have Buildroot working and have loaded various additional Linux utility programs on the camera.  I also wrote my own custom application to simulate the ‘cloud’ service that it connects to, so that I can prevent it from using cloud services (and still make it work).  I might blog more about the larger reverse engineering and cloud simulation project later.

But, toward the end of the project, I wanted to ensure I could view the video files the camera saves on the (optional) embedded SD card.  The files have a .264 extension, but the format is (I think) a raw H.264 stream with chunks of audio data interleaved in between.  Completely non-standard. 

I Googled and found many sites that guide users through playing the .264 files with VLC.  See example.  But, turns out, these steps only allow viewing of the video data; the audio does not play because VLC doesn’t know how to read it.

I dug deeper and finally found a post from someone on videohelp.com who had figured out how to extract the audio portions of the file to a separate audio-only file: 

Brilliant.  @ljx34, whoever you are, I owe you a drink!

Using this script, we can split out the audio and re-combine it with the video in a standard format. I threw this script together very quick:

#!/bin/bash
raw_audio_temp_file=$(mktemp).aac
conv_audio_temp_file=$(mktemp).aac
./extractaudio.py "$1" "${raw_audio_temp_file}"
ffmpeg -i "${raw_audio_temp_file}" "${conv_audio_temp_file}"
rm -f "${raw_audio_temp_file}"
ffmpeg -i "$1" -i "${conv_audio_temp_file}" -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 "$2.mp4"
rm -f "${conv_audio_temp_file}"

Here are the two script files:

convert.sh

extractaudio.py

Put em both in the same directory and run:

./convert.sh <inputfile> <outputfile>

Of course you must have a Linux shell environment and have python3 and ffmpeg installed.

Smart Card Technology & Getting Started in the Open Source World

Introduction

In the last year or so in my current position, I’ve been fortunate enough to have some time to explore and experiment with smart card technology.  In particular, I’m talking about smart cards based on the Java Card and Global Platform standards.

I now have a pretty solid understanding the above standards, and at this point, I have even developed some (small) custom Java Card “applets” as well as some changes to the open source “Coolkey” applet that my current organization uses to store its client PKI certificates and (most importantly) secure the associated RSA private keys.  Red Hat has even been kind enough to check in some of my (small) changes to their applet.

Continue reading this entry

Debugging and Patching Star Trek Armada I – Part 3 of 3

Introduction

In part 1 of this mini-series, we saw how to diagnose and correct the issues preventing an old computer game (Star Trek Armada) from starting on modern (Windows 7) systems. In part 2 we saw how to find the game loop and introduce our own code to slow it down so that the game’s native timing code would work properly.

This third and final post brings closure to the STA reverse engineering by enabling multiplayer saves and presenting a combined diff file for all of the patches we have made in this and the previous posts.

Fix #4 – Enabling Multiplayer Saves

Star Trek Armada is buggy; merely allowing the game to minimize (say, due to a screensaver turning on or alt-tabbing to another program) can cause it to crash. The game also suffers from multiplayer synchronization issues. Ideally, if we could figure out how to save and load multiplayer games, it would allow players in a multiplayer match to continue from a recent point when a problem occurs during gameplay.

Continue reading this entry

Debugging and Patching Star Trek Armada I – Part 2 of 3

Introduction

In part 1 of this mini-series, we saw how it was a relatively simple task to diagnose and correct the issues preventing an old computer game from starting on modern (Windows 7) systems. This post continues the reverse engineering and patching theme to correct additional runtime issues with Star Trek Armada on modern systems.

Fix #3 – Abnormal Simulation Speed

Once the game was starting correctly, it played just fine on my laptop. When I tried it on one of my family’s desktop machines; however, things were a different story.

Continue reading this entry

Installing & Using Rsync on Windows

10-21-2013 Update:  Corrected a few errors in the write-up and fixed the template configuration files.

Introduction

I remotely manage the computers & networks for various family members (parents, siblings, and grandparents).  To this end, I currently have router-to-router VPN links consistently established between home networks at five distinct geographic locations.  (These links are maintained using OpenVPN running on my OpenWrt-based gateway routers.)

As administrator of this geographically-diverse home network, I need to consistently back up my family’s data in case disaster strikes.  While there are many reputable cloud-backup solutions available, I prefer to trust my own skills to manage and protect my (and my family’s) data.

As we all know, a key backup strategy is to have off-site backups.  Fortunately, because my VPN spans multiple geographic locations, the off-site backup problem is easy – provided I can periodically synchronize files between computers at different locations.  Unfortunately, my VPN links are limited to approximately 300 KB/s due to the limited uplink bandwidth.  For me, this is where rsync comes in.

What is Rsync?

Rsync is a tool for *NIX.  From the rsync man page, “rsync … [is] … a fast, versatile, remote (and local) file-copying tool.” For me, attractive capabilities of rsync include:

Continue reading this entry

Debugging and Patching Star Trek Armada I – Part 1 of 3

Making Armada Work On Modern Systems
(a.k.a. A Partial Guide to Ollydbg)

Being a professional in the Computer Science field, I don’t have that much time for video games anymore. As a result, when I choose to play games, I typically prefer to take a trip down memory lane and play something from my childhood. One of my favorite games is Star Trek Armada I. Unfortunately, Star Trek Armada I is rather poorly written (from a reliability standpoint) and generally doesn’t play very well (if at all) on most modern Windows systems. I could switch over to Star Trek Armada II, but I much prefer the original game for various design reasons.

Fortunately, modern IT professionals (and amateurs, in my case) are armed with a swath of debugging and reverse engineering tools, with which we can correct some of Star Trek Armada’s shortcomings. So, without further ado, let’s get started!

Continue reading this entry

Windows VB Script for Batch WMA to MP3 Conversion

A few months back, I was attempting to load my music collection on my iPhone for the first time and was encountering issues.  My situation:

  1. I was running iTunes in a Virtual Machine to avoid all the crapware that iTunes installs.
  2. My music library was a combination (about half and half) of WMA and MP3 files.
  3. My music library was well organized in a folder hierarchy.
  4. The iTunes converter was giving me grief upon importing my music library.  (I seem to recall that due to the use of virtual machine snapshots, iTunes kept getting confused and re-converting certain WMA files that had already been converted by it; furthermore, due to the virtualization, conversion of my music library was taking forever!)

“No problem,” I thought, “I’ll just find a tool to batch-convert my entire music library to MP3 format, which is compatible with iTunes.”  My plan was to run this once on the host and then import the entire (converted) folder into iTunes on the VM.

Continue reading this entry