sockets - IP is changing when sending UDP packet with spoofed IP in C Ubuntu 12.04 -
i writing code in c, eclipse, ubuntu 12.04. opening socket , sending udp packets spoofed source ip. when run code in virtual machine (the same code, eclipse, ubuntu version) ok, when try run on real ubuntu machine doesn't work properly.
bzero(&spoof_addr, sizeof(spoof_addr)); spoof_addr.sin_family = af_inet; spoof_addr.sin_port = htons(serverport); if (inet_aton("192.168.160.240", &spoof_addr.sin_addr)==0) { fprintf(stderr, "inet_aton() failed\n"); exit(1); } if ((sockfd_spoofed = socket(af_inet, sock_dgram, ipproto_udp))==-1) err("socket"); bind(sockfd_spoofed,(struct sockaddr*)&spoof_addr,sizeof(spoof_addr)); //send packet if (sendto(sockfd_spoofed, buf_port, 5, 0, (struct sockaddr*)&dest_addr, sizeof(dest_addr))==-1) the problem ubuntu/kernel changes source ip real ip of interface have. eclipse runs without errors or warnings. understand, ip changing after packet leaves eclipse application. tried add additional ip this: ifconfig eth0:1 192.168.160.240 netmask 255.255.255.0 (this worked in virtual machine) doesn't affect real pc.
when send udp packets, , udp stack in kernel going set headers correct values.
if want more control on sent, need use raw sockets.
be aware hard , requires root privileges.
Comments
Post a Comment