dandroid
dandroid

Reputation: 405

how to intercept and modify tcp packets sent and received by a certain process?

Assuming there is a process under my control (I can run it and send it commands) that sends and receives tcp packets (maybe some other types of protocol)

How can I intercept its outgoing packets and change their payload? Netfilter was suggested as a solution in another question (Intercepting/Rerouting TCP SYN packets to C++ program in linux)

For incoming packets, I only need to read them so that problem can be solved with wireshark or something along that line.

I am trying to understand if there is any better way of doing it given my particular use case (particular known and controlled process).

The final goal is to effectively alter the payload of a packet sent by a process right after it is sent and monitor the rest of the packets.

Thanks

Upvotes: 2

Views: 2770

Answers (1)

dandroid
dandroid

Reputation: 405

Eventually, for my particular use case, proxies solved my issue.

I got the process under my control to use a socks5 proxy.

For incoming connections, I used a reverse proxy.

This allows me to view/tamper with the packets.

Upvotes: 1

Related Questions