0

I have a question regarding HTTP requests. I don't even know if this is possible, but was trying to figure a way out to implement this.

Check out this function in Python:

def send_this(url):

        this_browser=mechanize.Browser()
        this_browser.set_handle_robots(False)
        this_browser.addheaders=[('User-agent','Chrome')]

        test_output=this_browser.open(url).read().decode("UTF-8")
        return test_output

So when I run this from my machine, quite obviously, the value is returned and written into the variable translated.

What I'd like to know is, is there a way in which the request could be sent to the URL and the output (this_browser.open(url).read().decode("UTF-8")), instead of begin written into this variable, is sent to another destination altogether without coming back to the place of origin?

This is a diagrammatic representation of what I want to achieve.

test

My Machine and Another Server are both under my control. The server to which the request is sent is not.

  • First, is implementing this possible?
  • Second, what implementations/technologies should I look into to implement this?
rahuL
  • 3,330
  • 11
  • 54
  • 79
  • related: [Is it possible to pass TCP handshake with spoofed IP address?](http://security.stackexchange.com/q/37481/438) – jfs Dec 21 '13 at 10:04

5 Answers5

2

You can't make the "The Internet" server send its reply somewhere else, but you could read the reply and send it to your server in a 2nd http connection, with a corresponding receiver script reading what you send and process it in whichever way you want to.

Guntram Blohm
  • 9,667
  • 2
  • 24
  • 31
0

You might listen at a certain Port onto these machines and use TCP/IP sockets or You might do that by a PHP-script, which reads GET (or POST) Data referenced by its URL and write it to a textfile/XML, your current running program at Destination recognizes then for further work with data.

Flo
  • 27
  • 3
0

No, this is not possible. At least not within the confines of HTTP.

Unlike FTP, which opens separate data channels for transferring stuff (and thus could do this), HTTP does all its stuff over a single TCP connection. So the only place the server will send a response, is to the machine that sent it the request.

What you could do is connect to "Another Server" and tell it to initiate the HTTP request (and consequently get the response).

cHao
  • 84,970
  • 20
  • 145
  • 172
0

You might be able to hoodwink "The Internet" server that request from "my machine" is actually coming from "another machine" so that it would send its response to it.

You could use scapy to spoof your ip.

As you might have guessed, it is much easier to use the approach that you've mentioned in the comment: connectivity diagram

Or just send requests to "the internet" server from "another server" directly.

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670
0

You could potentially use scapy to generate the request for the page with the originator details set to that of the other machine - that should result in the data being sent to the other machine but for a web page request the other machine is likely not to update the page as it is not expecting any data as it has not requested any.

You might be better off to use python on the other machine with pyro to control a web page display and your first machine could ask the remote machine to request and display the required page.

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
  • Theoretically, if I could have a small bit of code listening for this sort of request specifically on the other machine, would that work? – rahuL Dec 21 '13 at 16:42
  • That is what pyro, https://pypi.python.org/pypi/Pyro4, does for you - it listens for remote execution requests and runs just about __any__ python code you choose on the local machine and returns the results to the originator. You could roll your own but when it has been done for you.... – Steve Barnes Dec 21 '13 at 17:07