This is what I want to do:
web browser -> connect to a remote server via telnet (server1) -> to squid-proxy (which requires authentication) via telnet on port 80 (server2)
I wrote a small python script that uses Twisted (here:
#! /usr/bin/python from twisted.internet import reactor, protocol from twisted.web import http from telnetlib import Telnet import getpass from sys import stdout class datareceiver(protocol.Protocol): def dataReceived(self,data): self.telnet_con.write(data) stdout.write( self.telnet_con.read_all() ) def connectionMade(data): stdout.write("\nA connection was made to this server\n") def main(): server1 = "10.1.1.1" #user = raw_input("Enter your remote account: ") password = getpass.getpass() tn = Telnet(server1) if password: tn.read_until("Password: ") tn.write(password + "\n") #This is server2 tn.write("telnet 10.1.1.10 80 \n") #serverfac = protocol.Factory() serverfac = http.HTTPFactory() datareceiver.telnet_con = tn serverfac.protocol = datareceiver reactor.listenTCP(9229,serverfac) reactor.run() tn.write("exit\n") print tn.read_all() if __name__ == "__main__": main()
But then I realized that I was doing it wrong, my shell receives all the responses from squid instead of the browser. Can someone just outline the right way to do this? Should I use something else instead of twisted?
vivek source share