Click here to Skip to main content
12,503,964 members (57,637 online)
Click here to Skip to main content
Add your own
alternative version

Stats

202.9K views
12.2K downloads
114 bookmarked
Posted

Network Sniffer

, 19 Jul 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Network Sniffer

Sample Image - Sniffer.jpg

Introduction

A "Packet Sniffer" is a utility that sniffs without modifying the network's packets in any way. By comparison, a firewall sees all of a computer's packet traffic as well, but it has the ability to block and drop any packets that its programming dictates. Packet sniffers merely watch, display, and log this traffic.

One disturbingly powerful aspect of packet sniffers is their ability to place the hosting machine's network adapter into "promiscuous mode." Network adapters running in promiscuous mode receive not only the data directed to the machine hosting the sniffing software, but also ALL of the traffic on the physically connected local network.

I hope that this piece of code will help you understand the network better.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Eran Aharonovich
Software Developer
Australia Australia
Been a programmer since 1999.
Experience in:
.Net, C++, C#, VB, VB.NET, ASP, ASP.NET, DLLs, COM etc.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Questionhelp me how to compile and execute the project.... Pin
rahul.csit28-Feb-08 17:36
memberrahul.csit28-Feb-08 17:36 
QuestionIt works in visual c++ 6.0?? Pin
uriel_slp24-Oct-07 10:23
memberuriel_slp24-Oct-07 10:23 
AnswerRe: It works in visual c++ 6.0?? Pin
uriel_slp24-Oct-07 10:27
memberuriel_slp24-Oct-07 10:27 
QuestionPlease I Need Help Pin
mustafa_kh_200710-Sep-07 4:03
membermustafa_kh_200710-Sep-07 4:03 
QuestionWe can catch the TCP packet only? Pin
MD8414-May-07 21:57
memberMD8414-May-07 21:57 
AnswerRe: We can catch the TCP packet only? Pin
Eran Aharonovich14-May-07 22:03
memberEran Aharonovich14-May-07 22:03 
GeneralRe: We can catch the TCP packet only? Pin
priyanka,oberoi110-Aug-09 1:37
memberpriyanka,oberoi110-Aug-09 1:37 
Generalgetting IP address Pin
AYcoder7-Aug-06 9:08
memberAYcoder7-Aug-06 9:08 
Hi,

I'm not using this code but I'm using something similar. I need to get the IP address of where I'm listening from. However, the inet_ntoa command always returns IP address as 0.0.0.0.

here are parts of the code... please let me know if I'm doing something wrong. I'm using Visual Studio C++. Is it possible that I might be missing a header file or something? I think it would give an error if that was the case. I have this in my code: #pragma comment(lib, "Ws2_32.lib")

Thanks!


SOCKADDR_IN recv_addr;
SOCKET sock;

WSADATA data;
if (WSAStartup(MAKEWORD(2,2), &data) != 0) return(0);

int ret;
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (!sock)
{
WSACleanup();
return(0);
}
recv_addr.sin_family = AF_INET;
recv_addr.sin_addr.s_addr = INADDR_ANY;
recv_addr.sin_port = htons(APP_PORT);
ret = bind(sock, (SOCKADDR *)&recv_addr, sizeof(SOCKADDR));
if (ret)
{
WSACleanup();
return(false);
}

case WM_SOCKETREAD:
{
SOCKADDR from;
char buffer[256];
int len = sizeof(SOCKADDR);
memset(buffer, '\0', 256);
recvfrom(sock, buffer, 256, 0, &from, &len);
SetDlgItemText(hDlg, IDC_MESSAGE, buffer);
char* Recv_IP= ReadIP();

}break;

char* ReadIP()
{
int length = sizeof(recv_addr);
getsockname(sock, (SOCKADDR*)&recv_addr, &length);
MessageBox(hDlg, inet_ntoa((in_addr)recv_addr.sin_addr), "IP Address", MB_OK);
return(inet_ntoa((in_addr)recv_addr.sin_addr));
}


QuestionOutbound traffic is not catched Pin
John Ashraf24-Jul-06 12:22
memberJohn Ashraf24-Jul-06 12:22 
Generalrunning the network sniffer Pin
ujal13-Jul-06 7:18
memberujal13-Jul-06 7:18 
GeneralRe: running the network sniffer Pin
Eran Aharonovich13-Jul-06 7:27
memberEran Aharonovich13-Jul-06 7:27 
GeneralRe: running the network sniffer Pin
ujal14-Jul-06 5:33
memberujal14-Jul-06 5:33 
Generaldisplay number of packets Pin
dReAmWoNderS5-Jul-06 4:48
memberdReAmWoNderS5-Jul-06 4:48 
QuestionMore fragments problem Pin
Wouter Dhondt18-Jun-06 5:06
memberWouter Dhondt18-Jun-06 5:06 
GeneralXP SP2 Problem Pin
jopus22-Jul-05 11:31
memberjopus22-Jul-05 11:31 
GeneralI Get Inbound traffic only Pin
jopus28-Apr-05 20:23
memberjopus28-Apr-05 20:23 
GeneralPlease help me! Pin
dSolariuM29-Mar-05 4:45
memberdSolariuM29-Mar-05 4:45 
GeneralRe: Please help me! Pin
Eran Aharonovich30-Mar-05 6:32
memberEran Aharonovich30-Mar-05 6:32 
QuestionAnd the environment is? Pin
abica1-Mar-05 4:42
memberabica1-Mar-05 4:42 
AnswerRe: And the environment is? Pin
Eran Aharonovich25-Jul-05 1:07
memberEran Aharonovich25-Jul-05 1:07 
QuestionHow top begin writing a packet sniffer? Pin
grace4raghu227-Dec-04 4:42
membergrace4raghu227-Dec-04 4:42 
GeneralFeeto Pin
feeto27-Dec-04 3:46
sussfeeto27-Dec-04 3:46 
GeneralRe: Feeto Pin
Anonymous27-Dec-04 4:45
sussAnonymous27-Dec-04 4:45 
GeneralHi Pin
Sanjit Rath1-Nov-04 4:21
memberSanjit Rath1-Nov-04 4:21 
GeneralRe: Hi Pin
Eran Aharonovich25-Jul-05 1:22
memberEran Aharonovich25-Jul-05 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 20 Jul 2004
Article Copyright 2004 by Eran Aharonovich
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid