# Katcat

Daniel Beer
dlbeer@gmail.com
28 Jun 2012

Katcat is a tool for extracting media files from a Sanyo 6650 CDMA phone (also known as Katana II) via the USB data cable. This phone exposes two interfaces when it's plugged in. One is an ACM interface over which the phone will accept AT commands. The other is a vendor-specific interface with two bulk endpoints. Over this interface, the phone communicates using a binary BREW-like protocol. This tool communicates via the binary interface using libusb.

## Installation

First, you need to ensure that you have libusb installed, including development files. Download katcat.c, and compile it with:

gcc -O1 -Wall -ggdb -o katcat katcat.c -lusb

You might then want to copy the program to /usr/local/bin. You will either need to set up a udev rule to give yourself appropriate permissions for raw USB access, or run the tool as root.

## Usage

If you run the program with no arguments, it will search for the first phone on the USB bus and query it for basic information. The output looks something like this:

$katcat Firmware date1: Jul 31 200709:51:06 Firmware date2: Jul 31 200709:51:06 Firmware rev: SDLZ6760 ESN: ABCD1234 Phone number: 0271234567 Media is stored in the phone in several directories, which are numbered 1 through 3. You can specify a directory to search with the -m option, but by default, directory 1 is searched (the camera directory). Use the list command to get a list of available files: $ katcat list
6 files in directory 1:
0. 665A0038.JPG
1. 665A0037.JPG
2. 665A0036.JPG
3. 665A0034.JPG
4. 665A0033.JPG
5. 665A0032.JPG

You can extract them individually by either slot number or filename. The following two commands, given the listing above, are equivalent:

$katcat -o output.jpg cat 2$ katcat -o output.jpg catfile 665A0036.JPG

Finally, the extract-all command can be used to unpack all files in the media directory and save them in the current directory. Use this command with caution -- names are taken from the phone's media directory, and will overwrite any similarly named files in the current working directory.

Run with --help to get a full list of commands and options.

## Bugs

The protocol for extracting media files transfers data in chunks, but there is no documented mechanism for rewinding the stream, apart from the implicit rewind that occurs when selecting a different file. If you interrupt a transfer part-way through and then attempt to re-transfer the same file, the second transfer will continue from where the first transfer was interrupted.

Copyright (C) 2012 Daniel Beer <>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.