Web Rarely

The herd instinct among economists makes sheep look like independent thinkers.

Reverse engineering Trepia


Trepia is a cool idea. It's an IM client that finds other people and sorts them by their proximity to you. But while it's a great idea, the client sucks, and it's not open source, so I can't fix its annoying problems myself. So, I decided to take some time to reverse engineer the protocol in hopes that somebody will write a better Trepia client. Maybe we'll be able to run it on *nix soon!

If you discover anything else, please post the additional information in a comment.


I coded up a simple proxy server that would write out the packets as hex dumps, but most of that work turned out to be unnecessary, because Trepia actually uses uncompressed, unencrypted XML to communicate with the server. So I spent a bit of time reverse engineering the Trepia protocol. I've only put about 2 hours into it, but I'm hoping other people will take this information and run with it.


To create a new account in Trepia, the NEWACCT packet is used. After that, when you connect to Trepia, the client sends the CONNECT packet, to which the server replies with the LOGIN packet. From there, it's a loop that simply processes incoming packets. I believe it doesn't need to store any state about packets seen/expected for its basic operation. The exceptions are when logging in, creating a new account, or downloading the current user's profile.


The default trepia server is located at and runs a Trepia server on ports 8201 through 8210.
[update] The server IP seems to have changed to

Data Types

Trepia uses the following data types:
IntegerAn unbroken block of digits1245
String A block of text, encoded using XML entities. Line breaks, etc are also encoded as entities. Line breaks are encoded as a single 
 me & joe went to the store
it wasn't fun
MAC AddressA unique identifier for a network interface00-50-BA-75-10-F7
Hex dataAn unbroken string of lowercase hex charactersee9356e428dd9507b32715da7235
Base64 dataA solid block of data encoded as base64/9j/4AAQSkZJRgAQSkZJRgABAB==
Location An integer that specifies a person's location. I've noticed that people close to me have closer numbers, so the distance between people may be simple subtraction operation between their locations. However, it doesn't sound like it would work, so I'm not sure about that. UNKNOWN FORMAT 1055792857

Packet format

Each packet is an XML block. The root tag specifies the packet type. Inside the root tag are immediate children, usually labeled 'a', 'b', 'c', 'd', etc. These children make up the parameters for the packet. So far, most children have been in a consistent order. However, the ones dealing with profiles or user data (ie DATAREPLY) have not always been in a consistent order. So, it's best not to rely on the order of the child nodes.

In the tables below, parameters are listed in the order the are generally sent/received by the official client.

Incoming Packets (packets from server to client)

Outgoing packets

Packet: LOGIN, Node: L, Parameters: 3
The LOGIN packet is sent in response to a CONNECT packet or a NEWACCT packet.
aIntegerStatus: 0 - login successful, 1 - login incorrect, 2 - nickname taken (during registration), 4 - outdated client version?, OTHERS?
bLocationYour current location
cIntegerUNKNOWN, always 2 so far
Packet: MEMBER, Node: M, Parameters: 4
The MEMBER packet is sent to add/update users in the user list.
aIntegerUser ID
bLocationUser's location
cIntegerUNKNOWN, usually small numbers (1-4), but sometimes not. profile/update type? 1 - profile only?, 2/else - profile+picture?
dIntegerUNKNOWN, can be empty?
Packet: LOCATION, Node: R, Parameters: 2
The LOCATION packet is sent to update the location/insta-blog note for a user.
aIntegerUser ID
bStringUser's location/note
  <b>Memory Leaks Fixed: NEW TREPIA</b>
Packet: QUERY, Node: Q, Parameters: 2
The QUERY packet is sent when a user sends a message to you.
aIntegerUser ID
bStringUser's message
  <b>test message</b>
Packet: DATAREPLY, Node: O, Parameters: variable, 2+
The DATAREPLY packet is sent by the server in response to DATAREQ packets sent by the client.
Many of these fields can be missing or empty.
aIntegerUser ID
bLocationUser's location
cIntegerUNKNOWN, small numbers, always seems to accompany image data
dStringUser name
eStringEmail address
fStringHomepage URL
gStringFirst name
hStringLast name
iInteger (String?)ICQ number
jStringAIM ID
kStringMSN ID
lStringYahoo ID
nStringGender (M/F)
oStringProfile text
pStringCurrent location/insta-blog note?
qBase64Image file encoded as base64 - so far has been jpeg but may be other formats
xStringLocation (dropdown box)
example 1 - profile
  <o>Network &amp; Systems engineer (Cisco, Solaris, Linux, FreeBSD)</o>
  <r>United States</r>
  <t>San Antonio</t>
  <x>US -&gt; Georgia -&gt; Atlanta</x>
example 2 - photo data
Packet: NIX, Node: N, Parameters: 1
The NIX packet is sent by the server when a user has logged off.
aIntegerUser ID
Packet: PROFILE, Node: P, Parameters: 2
The PROFILE packet is sent by the server in response to the PROFREQ packet. The client can send an UPDPROF packet to alter the profile.
aIntegerUser ID
bStringUser's password, sent as plaintext
cStringEmail address
dStringHomepage URL
eStringFirst name
fStringLast name
gInteger (String?)ICQ number
hStringAIM ID
iStringMSN ID
lStringGender (M/F)
mStringProfile text
nBase64photo data - base64 encoded image file
uStringLocation (dropdown box)
  <m>this is my profile</m>
  <q>San Diego</q>
  <r>English, Japanese</r>
  <u>US -&gt; California -&gt; San Diego</u>
Packet: RATED, Node: V, Parameters: 2
The RATED packet is sent when another user has rated you.
aIntegerUser ID
bIntegerRating (1 - Cool, 2 - Interesting, etc)

Outgoing Packets (packets from client to server)

Incoming packets

Packet: CONNECT, Node: C, Parameters: 5
The CONNECT packet is sent as soon as the client connects to the server. The server replies with the LOGIN packet.
aMAC AddressYour MAC address
b1MAC AddressUNKNOWN, gateway MAC address???
cStringYour User ID
dHex dataMD5 hash of the password
eStringClient version
Packet: DATAREQ, Node: D, Parameters: 2
The DATAREQ packet is sent by the client to request data about a particular user. The server will respond with corresponding DATAREPLY packets.
aIntegerUser ID
bIntegerData requested, 1 - profile, 2 - photo, POSSIBLY OTHERS
Packet: PROFREQ, Node: I, Parameters: 0
The PROFREQ packet is sent when the client wants to request its own profile. The server replies with a PROFILE packet.
Packet: MSG, Node: F, Parameters: 2
The MSG packet is sent by the client when the client wants to send a message to another user.
aIntegerUser ID
bStringMessage to send to user
  <b>send message to pf</b>
Packet: UPDPROF, Node: K, Parameters: variable
The UPDPROF packet is sent when the client wants to update its profile.

The parameters consist of the items to change and the new values.
aStringUser's password, sent as plaintext
bStringEmail address
cStringHomepage URL
dStringFirst name
eStringLast name
fInteger (String?)ICQ number
gStringAIM ID
hStringMSN ID
kStringGender (M/F)
lStringProfile text
mBase64photo data - base64 encoded image file
tStringLocation (dropdown box)
  <t>US -&gt; California -&gt; San Jose</t>
Packet: UPDNOTE, Node: G, Parameters: 1
The UPDNOTE packet is sent when the client wants to update its location/insta-blog note.
aStringNew note
<G><a>change my blog note</a></G>
Packet: RATEUSER, Node: U, Parameters: 2
The RATEUSER packet is sent when the client wants to rate another user.
aIntegerUser ID
bIntegerRating (1 - Cool, 2 - Interesting, etc)
Packet: NEWACCT, Node: J, Parameters: 14
The NEWACCT packet is sent to create a new Trepia account. The server will reply with a LOGIN packet.
Many of these fields may be empty, but I think none can be omitted.
aMAC AddressYour MAC address
bMAC AddressUNKNOWN, gateway MAC address???
cStringClient version
dStringUser name
eStringPassword in plain text
fStringEmail address
gStringHomepage URL
hStringFirst name
iStringLast name
kStringGender (M/F)
lStringProfile text
mBase64 dataBase64 encoded image file
nStringLocation (from dropdown box)
  <l>my profile</l>
  <n>US -&gt; California -&gt; San Diego</n>


No comments yet.

Add a comment

Note: The information you enter (including your name and email address) will be displayed publicly.

Line breaks are converted to <br>'s, and all HTML tags except b, u, i, tt, and pre are filtered out.