After learning modern PHP in past few days, I decide GIVING UP this language now. :(
I wrote an MiTM proxy in PHP for TCP connection forwarding and hijacking, code can be found on github.
This project is based on ReactPHP.
It can be also installed from composer / packagist.org.
I’ve coded some examples in that project, you can try those out and write your own. Including: forward DNS TCP query, forward HTTP query, modify HTTP request.
If you have a linux router/box, you can add some iptables rules forwarding requests to your running instance.