TiVo Community Forum banner

Help with man in the middle setup using netcat on the tivo to redirect ports

4791 Views 3 Replies 4 Participants Last post by  wintifrosch
I need the advice of a unix guru. I've been trying to create a man in the middle situation using NC and piped output. I tried
nc -l -p 81 | nc x.x.x.1 80 | nc -l -p 81
but that isnt able to bind to the same port as the first one. I can't seem to get the connection to go both ways. Here is an example of what I have tried against my routers administration page to test

bash-2.02# tail -f /var/hack/io | nc -l -p 82 &
[11] 574
bash-2.02# nc x.x.x.1 80 > /var/hack/io

Code:
GET / HTTP/1.1
Host: 172.18.19.51:82
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.
070725 Firefox/2.0.0.6
Accept: text/xml,application/xml,application/xhtml+xml,text/html;
n;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
[b]At which point I get an error page in the browser
I break out of the command and the error page is exactly what is in my IO file[/b]

bash-2.02# cat /var/hack/io
HTTP/1.0 400 Bad Request
Server: httpd
Date: Tue, 14 Aug 2007 23:42:22 GMT
Content-Type: text/html
Connection: close

<HTML><HEAD><TITLE>400 Bad Request</TITLE></HEAD>
<BODY BGCOLOR="#cc9999"><H4>400 Bad Request</H4>
No request found.
</BODY></HTML>
Does this mean my "tunnel" is working but tail is saying "file truncated" when the connection is established which is confusing everything?
See less See more
1 - 4 of 4 Posts
Hi,

you have to use a pipe:

mknod tmp_pipe p
nc -l 1231 < tmp_pipe |nc hostname 80 > tmp_pipe

you can also search and replace for strings and copy the intermediate traffic to your file system:

nc -l 9080 < tmp_pipe |nc 10.100.0.219 9080 |tee original.txt |sed 's/HTTP\/1.1 771 Undefined/HTTP\/1.1 200 OK/' |tee modified.txt > tmp_pipe

best Regards,

Romeo

---------------
Romeo Kienzler
r o m e o . k i e n z l e r ( a - t ) g m a i l . c o m
See less See more
After more than 5 years, I seriously doubt the OP is still seeking a solution.
@lrhorer: I was VERY HAPPY about the reply of ormium. More than a year ago, he wrote exactly what I was looking for!

A question is a question. We google them.
A solution is a solution. We find them.

I thank cypher for asking my question years ago.
And i thank ormium for serving the answer long time before I was asking!

That's why we love forums :up:
What is your contribute?
1 - 4 of 4 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top