473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Capturing instant messages

I've been approached by a local business that has been advised that
they need to start capturing and archiving their instant messaging in
order to comply with Sarbanes-Oxley. The company is largely PC, but
has a significant number of Macs running OS X, too.

Googling around quickly turns up IM Grabber for the PC, which would
seem to be just what they need. But there is no equivalent to be
found for OS X. So if anyone knows of any such product, please let me
know and there will be no need for the rest of this post.

But assuming that there is no such product, would it be possible to
create something in Python, using the socket or a similar module?
They have a number of servers that provide NAT for each group of
machines; I was thinking that something on those servers could
capture all traffic on port 5190 and write it to disk. Is this
reasonable, or am I being too simplistic in my approach?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Jul 18 '06 #1
6 2243
Ed Leafe <ed@leafe.comwrites:
But assuming that there is no such product, would it be
possible to create something in Python, using the socket or a similar
module? They have a number of servers that provide NAT for each group
of machines; I was thinking that something on those servers could
capture all traffic on port 5190 and write it to disk. Is this
reasonable, or am I being too simplistic in my approach?
Are you talking about IM's within the company, or over the internet?
According to

http://en.wikipedia.org/wiki/Instant_Message

There are about a bazillion different protocols in use. You have to
make sure everyone's using the same thing. Some of these protocols
use end to end encryption, which means logging at the network side
would just record ciphertext. You need to get these issues figured out.

Also ask them if they're sure they need to log the conversations.
According to some legal decisions, in some states, logging chats
without both parties' permission is illegal, like recording a phone
call. IM's are supposed to be transient communications, unlike email.
As such, logging all the company's IM's is sort of like audio
recording all the company's phone calls. I think the company should
get a lawyer to look at this question if it hasn't already.
Jul 18 '06 #2
Ed,

It depends on what IM protocol the company is using. If there is more
than one, your job might end up being quite complicated. You indicated
port 5190 in your post, does it mean that the company is using only AOL
IM? In general it seems like you would have to:

1) Capture the traffic
2) Decode the IM protocol
3) Record the captured text

1) As far as capturing the traffic, I would use a specific tool like
tcpick ( a cousin of tcpdump but actually dumps the data to console not
just the headers and recreates the tcp streams -- good stuff!). Again
if you know the exact port number and the exact protocol this might be
very easy because you will set up your capturing program to capture
traffic from only 1 port. Let's assume that for now. Here is my quick
and dirty attempt. First install tcpick http://tcpick.sourceforge.net/
if you don't have it, then become root and open a Python prompt. (Use
ipython... because my mom says it's better ;).
In [1]:from subprocess import * #don't do this in your final script
always use 'import subprocess'
In [2]:cmd='/usr/sbin/tcpick -i eth0 -bR tcp port 80' #use your IM port
here instead of 80
#-bR means reconstruct TCP stream and dump data in raw mode to console
(good for ASCII stuff).
In [3]:p=Popen(cmd, shell=True, bufsize=0, stdout=PIPE, stderr=PIPE)
#start a subprocess w/ NO_WAIT
In [4]:p.pid #check the process pid, can use this to issue a 'kill'
command later...
Out[4]:7100
In [5]:p.poll()
In [6]:#Acutally it is None, which means process is not finished
In [7]:#Read some lines one by one from output
In [8]:p.stdout.readline() #Might block here, if so start a browser and
load a page
Out[8]:'Starting tcpick 0.2.1 at 2006-XX-XX XX:XX EDT\n'
In [9]:#
In [10]:#Print some lines from the output, one by one:
In [11]:p.stdout.readline()
Out[11]:'Timeout for connections is 600\n' #first line, tcpick prompt
stuff
In [12]:p.stdout.readline()
Out[12]:'tcpick: listening on eth0\n'
In [13]:p.stdout.readline()
Out[13]:'setting filter: "tcp"\n'
In [14]:p.stdout.readline()
Out[14]:'1 SYN-SENT 192.168.0.106:53498 >
64.233.167.104:www\n'
In [15]:p.stdout.readline()
Out[15]:'1 SYN-RECEIVED 192.168.0.106:53498 >
64.233.167.104:www\n'
In [16]:p.stdout.readline()
Out[16]:'1 ESTABLISHED 192.168.0.106:53498 >
64.233.167.104:www\n'
In [17]:p.stdout.readline() #the good stuff should start right here
Out[17]:'GET /search?hl=en&q=42&btnG=Google+Search HTTP/1.1\r\n'
In [18]:p.stdout.readline()
Out[18]:'Host: www.google.com\r\n'
In [19]:p.stdout.readline()
Out[19]:'User-Agent: blah blah...\r\n'
In [20]:p.stdout.read() #try a read() -- will block, press Ctrl-C
exceptions.KeyboardInterrupt
In [21]:p.poll()
Out[21]:0 #process is finished, return errcode = 0
In [22]:p.stderr.read()
Out[22]:'' #no error messages
In [23]:p.stdout.read()
Out[23]:'\n257 packets captured\n7 tcp sessions detected\n'
In [24]: #those were the last stats before tcpick was terminated.

Well anyway, your readline()'s will block on process IO when no data
supplied from tcpick. Might have to start a thread in Python to manage
the thread that spawns the capture process. But in the end the
readlines will get you the raw data from the network (in this case it
was just one way from my ip to Google, of course you will need it both
ways).

2) The decoding will depend on your protocol, if you have more than one
IM protocol then the capture idea from above won't work too well, you
will have to capture all the traffic then decode each stream, for each
side, for each protocol.

3) Recording or replay is easy. Save to files or dump to a MySQL table
indexed by user id, timestamp, IP etc. Because of buffering issues you
will probably not get a very accurate real-time monitoring system with
this setup.

Hope this helps,
Nick Vatamaniuc


Ed Leafe wrote:
I've been approached by a local business that has been advised that
they need to start capturing and archiving their instant messaging in
order to comply with Sarbanes-Oxley. The company is largely PC, but
has a significant number of Macs running OS X, too.

Googling around quickly turns up IM Grabber for the PC, which would
seem to be just what they need. But there is no equivalent to be
found for OS X. So if anyone knows of any such product, please let me
know and there will be no need for the rest of this post.

But assuming that there is no such product, would it be possible to
create something in Python, using the socket or a similar module?
They have a number of servers that provide NAT for each group of
machines; I was thinking that something on those servers could
capture all traffic on port 5190 and write it to disk. Is this
reasonable, or am I being too simplistic in my approach?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
Jul 18 '06 #3
On Jul 18, 2006, at 7:36 AM, Nick Vatamaniuc wrote:
It depends on what IM protocol the company is using. If there is more
than one, your job might end up being quite complicated. You indicated
port 5190 in your post, does it mean that the company is using only
AOL
IM?
Yes, they've told me that the users routinely use AIM to contact
clients and each other. I don't believe that their firewalls permit
other IM protocols.
1) As far as capturing the traffic, I would use a specific tool like
tcpick ( a cousin of tcpdump but actually dumps the data to console
not
just the headers and recreates the tcp streams -- good stuff!). Again
if you know the exact port number and the exact protocol this might be
very easy because you will set up your capturing program to capture
traffic from only 1 port.
Thanks; I'll have to play around with tcpick today.
2) The decoding will depend on your protocol, if you have more than
one
IM protocol then the capture idea from above won't work too well, you
will have to capture all the traffic then decode each stream, for each
side, for each protocol.
I guess I'll have to start googling for AIM decoding information.
3) Recording or replay is easy. Save to files or dump to a MySQL table
indexed by user id, timestamp, IP etc. Because of buffering issues
you
will probably not get a very accurate real-time monitoring system with
this setup.
They aren't interested in real-time monitoring; their main concern
is Sarb-ox compliance.

Thanks for your help!

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Jul 18 '06 #4
Assuming a one person per one machine per one chat protocol it might be
possible to recreate the tcp streams (a lot of packet capturing devices
already do that). So the gateway would have to have some kind of a
dispatch that would recognize the initialization of a chat loggon and
start a capture process for each such connection. I imagine with a 1000
employess he will end up with a 1000 processes running at the same
time. Another way is to capture all the streams at once that deal with
the chat protocol and ports and then replay them later and somehow
cre-create the tcp streams and chat messages in a cron batch job (at
night or weekend).

Nick V.
Yu-Xi Lim wrote:
Ed Leafe wrote:
I've been approached by a local business that has been advised that
they need to start capturing and archiving their instant messaging in
order to comply with Sarbanes-Oxley. The company is largely PC, but has
a significant number of Macs running OS X, too.

This is going to be quite off-topic.

I'm not entirely familiar with SOX regulations. Is it necessary to
capture it at the gateway? The best solution would be to provide logging
at the individual chat clients. Piecing together conversation threads
from individual packets while filtering out other non-chat junk can be
extremely tedious.

I understand the standard AIM client doesn't provide logging. Probably
won't any time soon, since it wasn't made for enterprise. There are
enterprise gateways for AIM, but I'm not sure of the cost or other
deployment issues. (Try looking at Jabber) You should consider those. Or
a switch to a more enterprise-friendly protocol if that's possible.

Other alternatives would be to use a better client. Multi-protocol
clients like GAIM, Trillian, Miranda, and Adium X generally provide
logging. Most provide the ability to toggle logging for specific
sessions, thus reducing privacy issues.
Jul 18 '06 #5
Nick Vatamaniuc wrote:
Assuming a one person per one machine per one chat protocol it might be
possible to recreate the tcp streams (a lot of packet capturing devices
already do that). So the gateway would have to have some kind of a
dispatch that would recognize the initialization of a chat loggon and
start a capture process for each such connection. I imagine with a 1000
employess he will end up with a 1000 processes running at the same
time. Another way is to capture all the streams at once that deal with
the chat protocol and ports and then replay them later and somehow
cre-create the tcp streams and chat messages in a cron batch job (at
night or weekend).
As I said, it's tedious, not impossible. :) The AIM Sniff project (perl,
not Python) does most of what you describe, but has bugs because of the
approach.

You're also ignoring the fact that each person may chat with more than
one person. Some protocols route all messages through a central server,
making it impossible to use the IP of the other party as a unique
identifier (not that it's a good idea to use the IP anyway, since the
assumption of one unique and consistent IP per person is weak).
Furthermore, you have to deal with failed messages, resends, etc at the
application layer. And there are also other non-trivial (but thankfully
rarely occurring) issues with TCP stream reconstruction.

Basically, it's looking at the wrong OSI layer. An application layer
protocol is best handled at the application where all the necessary
semantics are easily available. It /is/ an business/organization trying
to conform to SOX, so something as minor as switching and standardizing
IM clients (not necessarily protocols) would be probably the least of
their problems. And probably more manageable than a custom script for a
non-trivial activity.

There are definitely enterprise solutions available. And if you want to
get Python involved in this discussion, consider GAIM, which can be
scripted using Python via a plugin.
Jul 18 '06 #6
On Jul 18, 2006, at 3:17 PM, Yu-Xi Lim wrote:
This is going to be quite off-topic.
But helpful nonetheless.
I'm not entirely familiar with SOX regulations. Is it necessary to
capture it at the gateway?
I'm no lawyer either, so I probably know as much about this as you
do. It was the client who proposed this type of solution; I'm in the
process of figuring out if it's at all possible.
The best solution would be to provide logging
at the individual chat clients. Piecing together conversation threads
from individual packets while filtering out other non-chat junk can be
extremely tedious.
I got the impression that they want to capture the IM traffic and
record it somewhere JIC they are ever audited or subpoenaed, but that
most of it would never get looked at again.
I understand the standard AIM client doesn't provide logging. Probably
won't any time soon, since it wasn't made for enterprise. There are
enterprise gateways for AIM, but I'm not sure of the cost or other
deployment issues. (Try looking at Jabber) You should consider
those. Or
a switch to a more enterprise-friendly protocol if that's possible.

Other alternatives would be to use a better client. Multi-protocol
clients like GAIM, Trillian, Miranda, and Adium X generally provide
logging. Most provide the ability to toggle logging for specific
sessions, thus reducing privacy issues.
Thanks for the suggestions; I'll run them by the client. They don't
want to do it at the individual desktop level; they want a central
location to ensure that someone doesn't have the capability to
disable the logging, so perhaps an enterprise gateway might be a
better solution.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Jul 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dimitris | last post by:
I'm using ADO.NET to call a stored procedure that runs the "BACKUP" command on selected databases. Is there any way I can capture the text output of the stored proc and return it to ADO.NET for...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
1
by: John Davis | last post by:
How do I send Instant Messages through VBA?
1
by: Mark R | last post by:
Hi All, I am trying to create an instant messenger tool within the database, mainly so messages can be left for colleagues on different shifts (not all of them have a mail account). I have created...
0
by: BK Kim | last post by:
Hello. I am tryring to find a way to capture some of the windows messages ( eg. messages for creating, deleting files ) in c#. In windows application, i can override wndProc method to capture...
0
by: Colin Tiernan | last post by:
Hi, Can someone please put me right here. I've been asked to send messages to instant messenger through my asp.net 1.1 website, as a feature of a message board that I had to hand code. I...
5
by: Luigi | last post by:
Hi to all! I'd like to execute an external program capturing the stdout/stderr messages at "real-time". I mean that I don't want to wait for the end of the process. If I write a code like this:...
1
by: trytobreak | last post by:
Hey guys, I have a netscreen firewall which is configured to forward syslog messages to port 514 of my machine (specific ip on the network) and I am really puzzled as on how to capture these log...
1
by: trytobreak | last post by:
Hey guys, I have a netscreen firewall which is configured to forward syslog messages to port 514 of my machine (specific ip on the network) and I am really puzzled as on how to capture these log...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.