global security disclosure

promisc.c

promisc.c
Posted Aug 17, 1999

Sniffer detection tool.

tags | tool, sniffer
MD5 | 973ce06473734f205c9259ab3a891d09

promisc.c

Change Mirror Download

This will scan your devices to detect sniffers on your system.
Linux support is ready but SunOS has some problems (mainly in
net/if.h when i tried compiling i got a lot of parse errors in
if.h and socket.h <shrug> maybe the system i was on was damaged.)

Comments welcome :-).

begin promisc.c --
// $Id: promisc.c,v null 1997/03/09 10:35:58 trevorl Exp $
// promisc.c: test devices for sniffers and device moniters.
//
// Copyright (C) 1997 Trevor F. Linton (blind@xmission.com)
//
// Created for Linux based loosely upon linux ioctl controls.
// ioctl() is used to detect different flags set on devices used
// on your system.
//
// gcc -o sys_test promisc.c
//

#include <stdio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
#if defined (__linux__)
#include <linux/if.h>
#else
#include <net/if.h>
#endif
#define size(p) (sizeof(p))

int dev_flags=0,
device_flags=0,
set_look_all=0;

int
main(int argc, char **argv) {
struct ifreq ifreq, *ifr;
struct ifconf ifc;
char buf[BUFSIZ], *cp, *cplim;

if(argc <= 1)
set_look_all++;

if((dev_flags = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
fprintf(stderr, "An error occured establiashing while establishing a socket\n");
perror("socket");
exit(1);
}

ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;

if(ioctl(dev_flags, SIOCGIFCONF, (char *)&ifc) < 0) {
perror("SIOCGIFCONF");
exit(1);
}
ifr = ifc.ifc_req;
cplim=buf+ifc.ifc_len;
for(cp = buf; cp < cplim;
cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr))
{
ifr = (struct ifreq *)cp;

if(argv[1])
if(strcmp(ifr->ifr_name, argv[1]) && !set_look_all)
continue;

ifreq = *ifr;
if(ioctl(dev_flags, SIOCGIFFLAGS, (char *)&ifreq) < 0)
{
fprintf(stderr, "SIOCGIFFLAGS: %s (get interface flags): %s\n", ifr->ifr_name,strerror(errno));
continue;
}

device_flags=0; device_flags = ifreq.ifr_flags;
fprintf(stdout, "%s: ", ifreq.ifr_name);

if((device_flags & IFF_PROMISC) != 0)
fprintf(stdout, "Promiscuous: Sniffer detected.\n");
else
fprintf(stdout, "Not-Promiscous: No Sniffers detected.\n");

if(!set_look_all)
exit(0); // We're finished..
else
continue; // Go onto next device..

}
if(!set_look_all)
fprintf(stdout, "%s: Unknown device.\n", argv[1]);
// Device not found..
}
end promisc.c --

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close