I'm currently setting up IPtables to redirect certain UDP payloads to my application.
Here is an example of what I have working so far:
iptables -t nat -I PREROUTING -p udp -d {IPDST} --dport 27055 -m u32 --u32 '0>>22&0x3C@8=0xFFFFFFFF && 0>>22&0x3C@12=0x54536F75 && 0>>22&0x3C@16=0x72636520 && 0>>22&0x3C@20=0x456E6769 && 0>>22&0x3C@24=0x6E652051 && 0>>22&0x3C@28=0x75657279' -j REDIRECT --to-port 21015
This is working, it will redirect packets containing the payload:
FFFFFFFF54536F7572636520456E67696E6520517565727900
from one port to my application on another.
The problem is, I have another piece of data I wish to redirect, but it's not the same all the time. The packet looks like this:
ffffffff55ffffffff
However, the packet can also sometimes look like this:
ffffffff55fa0cf40f
I've tried something such as this:
iptables -t nat -I PREROUTING -p udp -d {IPDST} --dport 27055 -m u32 --u32 '0>>22&0x3C@8=0xFFFFFFFF && 0>>22&0x3C@12=0x55' -j REDIRECT --to-port 21015
I'm guessing the problem is something to-do with me trying to match 2 bytes rather than the 4 as normal? The above doesn't error but it also doesn't redirect the packets.