Go Premium for a chance to win a PS4. Enter to Win


Network Sniffer prog needed

Posted on 1998-05-27
Medium Priority
Last Modified: 2010-08-05
Hi C gurus,

This Q is sort of a cross post as I asked it in the CGI area but didn't have much luck. (only unix heads about and while I am a fan of unix I need something that will compile under Micro$oft NT for my laptop).

Does anybody have a utility sitting in their toolbox which listens to a specified port (80 for my web work) and sends everything to the standard out?

Something nice and simple that I can have running in a DOS session would be perfect. No rocket science required. I need to debug some progs (CGI etc...) and do not have anything on hand that will give me this level of access to the network.

Source would be nice so I can fiddle with it (and maybe learn a thing or two about network programming..)

Question by:mravell
  • 3
  • 2
  • 2
  • +1

Expert Comment

ID: 1251011

Author Comment

ID: 1251012
Hi tflai,

I checked this stuff out but was really after something that isn't a commercial / pay through the nose type application.

My needs are very modest.

Monitor Port x (80) and dump everything to standard out.

I don't need a high-end monitoring package, just a scrap of C code that somebody may have lyig around.


Expert Comment

ID: 1251013
Socket Spy is a shareware.  And as far as I know, there are no full-fledge network snooper source code free anywhere.
It is not too difficult conceptually to implement a network snooper.  What you need is a promiscous protoocol driver and a application-layer shell that interact it through device I/O control and decode the packet headers for different protocols:  802.3, IP, TCP, ...  But to actually develop it is another thing...
But if you want a Winsock API snooper, I know where you can get a skeletal code for Winsock DLL replacement.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 32

Expert Comment

ID: 1251014
I'll second tflai's comments here but add a couple of points.  The only free network sniffers that I've seen are for MSDOS and unix/Linux systems.  In fact, there are several really good ones under Linux.  Under Windows, however, there is nothing in the low-price or free range.  

Author Comment

ID: 1251015
What I am after is more of a code snippet than a full package. I don't need any whistles or bells. Just something that listens to port 80 and dumps what it hears to the standard out.

No analysis, fancy graphics or logging features just a few lines of code that can eavesdrop on my own webserver.


Accepted Solution

gadio earned 750 total points
ID: 1251016
 mravell, I think I have an answer for you. I had a problem like that and I solved it in the folowing manner. I set up a small program that does routing to and from the port that you want to snoop and another port (say 1234), and while routing the stream of data, prints them out. When you make your connection make it to the same host but indicate port 1234 (insted of www.xxx.yyy/zzz write www.xxx.yyy:1234/zzz), the routing is tranparent to the client and you get your info. I have such a program written in java. You can actually run it on any machine. If this solution is good for you I'll comment in the source.



Author Comment

ID: 1251017
Hi Gadio,

An interesteing idea. Not exactly what I had in mindbut it sounds as if it could do what I am after.

Please comment the code.


Expert Comment

ID: 1251018
Here it is. For each connection that takes place you get a window opened and shows you the in and out going data. Note that when you monitor http protocol, the client will probably open connection for each image that is on the page. Pages with many images on them will couse a lot of windows to be opend.
Enjoy, G.

------------- snooper.java --------------

 * Program: snooper.java Written by gadio.
 * This program opens a window for each connection to a the port
 * that it bridges. The window have one area for the input and one
 * for the output. Once the communication in finished a close button
 * is enabled.

import java.awt.*;
import java.net.*;
import java.io.*;

public class snooper {

    public snooper (int origport, int newport ) {
        try {
            ServerSocket srvs = new ServerSocket( newport );
            while(1) {
                Socket inconnect = srvs.accept();
                Socket bridge = new Socket("",origport);
                snooperObj so = new snooperObj( inconnect, bridge );
        } catch( IOException e ) {

    public static void main(String args[]) {
        snooper snoopy = new snooper(80, 1234);

class snooperObj extends Frame {
    private Thread inMonitor, outMonitor;
    Socket inconnect;
    Socket bridge;
    TextArea in_txt, out_txt;
    connector con1, con2;
    Button close, clearin, clearout;

    public snooperObj( Socket incon, Socket brdg ) {
        inconnect = incon;
        bridge = brdg;
        setLayout( new BorderLayout());
        in_txt = new TextArea( 20, 20 );
        out_txt = new TextArea( 20, 20 );
        Panel north = new Panel();
        Panel center = new Panel();
        north.setLayout( new GridLayout(2,2));
        center.setLayout( new GridLayout(1,2));
        String time = (new java.util.Date(System.currentTimeMillis())).toString();
        north.add( new Label("into server ("+time+"):"));
        north.add( new Label("out from the server:"));
        north.add( clearin = new Button("Clear input"));
        north.add( clearout = new Button("Clear output"));
        add("North", north);
        add("Center", center);
        add("South", (close = new Button("Close window")));
        con1 = new connector( incon, bridge, in_txt, close );
        con2 = new connector( bridge, incon, out_txt, close );

    public boolean handleEvent( Event e ) {
        if( e.target == close ) {
            con1 = null;
            con2 = null;
            return true;
        if( e.target == clearin ) {
            return true;
        if( e.target == clearout ) {
            return true;
        return false;

class connector extends Thread {
    Socket from, to;
    TextArea txtout;
    Button end_button;

    public connector( Socket from_s, Socket to_s, TextArea txta, Button closeb ) {
        from = from_s;
        to = to_s;
        txtout = txta;
        end_button = closeb;

    public void run() {
        try {
            InputStream is = from.getInputStream();
            OutputStream os = to.getOutputStream();
            while(1) {
                int b = is.read();
                txtout.append( ""+(char)b );
        } catch(IOException e) {


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question