#define _GNU_SOURCE #include #include #include #include #include static void execute1(const int fd) { // sendmsg$nl_route arguments: [ // fd: sock_nl_route (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_route]] { // msghdr_netlink[netlink_msg_route] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_route]] { // iovec[in, netlink_msg_route] { // addr: ptr[in, netlink_msg_route] { // union netlink_msg_route { // ipv6_newnexthop: netlink_msg_t[const[RTM_NEWNEXTHOP, int16], // nhmsg_new[AF_INET6], rtm_nh_policy_new] { // len: len = 0x1c (4 bytes) // type: const = 0x68 (2 bytes) // flags: netlink_msg_flags = 0x5fb9a818fb7378e9 (2 bytes) // seq: int32 = 0x0 (4 bytes) // pid: int32 = 0x0 (4 bytes) // payload: nhmsg[AF_INET6, flags[rtm_protocol, int8], // flags[rtnh_flags, int32]] { // nh_family: const = 0xa (1 bytes) // nh_scope: const = 0x0 (1 bytes) // nh_protocol: rtm_protocol = 0x0 (1 bytes) // resvd: const = 0x0 (1 bytes) // nh_flags: rtnh_flags = 0x0 (4 bytes) // } // attrs: array[rtm_nh_policy_new] { // union rtm_nh_policy_new { // NHA_BLACKHOLE: nlattr_t[const[NHA_BLACKHOLE, int16], // void] { // nla_len: offsetof = 0x4 (2 bytes) // nla_type: const = 0x4 (2 bytes) // payload: buffer: {} (length 0x0) // size: buffer: {} (length 0x0) // } // } // } // } // } // } // len: len = 0x1c (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000000100 = 0; *(uint32_t*)0x200000000108 = 0; *(uint64_t*)0x200000000110 = 0x2000000000c0; *(uint64_t*)0x2000000000c0 = 0x200000000140; *(uint32_t*)0x200000000140 = 0x1c; *(uint16_t*)0x200000000144 = 0x68; *(uint16_t*)0x200000000146 = 0x78e9; *(uint32_t*)0x200000000148 = 0; *(uint32_t*)0x20000000014c = 0; *(uint8_t*)0x200000000150 = 0xa; *(uint8_t*)0x200000000151 = 0; *(uint8_t*)0x200000000152 = 0; *(uint8_t*)0x200000000153 = 0; *(uint32_t*)0x200000000154 = 0; *(uint16_t*)0x200000000158 = 4; *(uint16_t*)0x20000000015a = 4; *(uint64_t*)0x2000000000c8 = 0x1c; *(uint64_t*)0x200000000118 = 1; *(uint64_t*)0x200000000120 = 0; *(uint64_t*)0x200000000128 = 0; *(uint32_t*)0x200000000130 = 0; syscall(__NR_sendmsg, /*fd=*/fd, /*msg=*/0x200000000100ul, /*f=*/0ul); } static void execute2(const int fd) { // sendmsg$nl_route arguments: [ // fd: sock_nl_route (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_route]] { // msghdr_netlink[netlink_msg_route] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_route]] { // iovec[in, netlink_msg_route] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {30 00 00 00 18 00 dd 8d 00 00 00 00 00 // 00 00 00 02 00 00 00 00 00 00 06 00 00 00 00 08 00 1e 00 // 02} (length 0x21) // } // } // } // len: len = 0x30 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x4090 (8 bytes) // ] *(uint64_t*)0x200000000180 = 0; *(uint32_t*)0x200000000188 = 0; *(uint64_t*)0x200000000190 = 0x200000000780; *(uint64_t*)0x200000000780 = 0x200000000380; memcpy((void*)0x200000000380, "\x30\x00\x00\x00\x18\x00\xdd\x8d\x00\x00\x00\x00\x00\x00\x00\x00\x02" "\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x08\x00\x1e\x00\x02", 33); *(uint64_t*)0x200000000788 = 0x30; *(uint64_t*)0x200000000198 = 1; *(uint64_t*)0x2000000001a0 = 0; *(uint64_t*)0x2000000001a8 = 0; *(uint32_t*)0x2000000001b0 = 0; syscall(__NR_sendmsg, /*fd=*/fd, /*msg=*/0x200000000180ul, /*f=MSG_PROBE|MSG_NOSIGNAL|MSG_EOR*/ 0x4090ul); } int main(int argc, char *argv[]) { syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); if (unshare(CLONE_NEWNET)) return 1; int fd = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (fd == -1) return 1; execute1(fd); execute1(fd); execute2(fd); return 0; }