twitchyliquid64 Posted January 31, 2011 Share Posted January 31, 2011 Hi all. I am Currently Building a HTTP Proxy/VPN Hybrid system and am having trouble with TCP Framing. There are 2 components to my program. 1. Client – A program locally runs on the users computer, hosting a HTTP Proxy server. It connects to the VPN server, and routes the HTTP proxy requests through that. 2. Server – This runs on a separate machine and is responsible for getting the HTTP Data sent down from the client, and connecting to the various hosts and making it happen. So it goes like this: Browser -> Local (127.0.0.1) HTTP Proxy -> VPN Server -> Host, and back again. Parts of the VPN Link are encrypted. The issue Im having is that everything that’s not a html or css document, or overhead, isn’t getting sent correctly. The Structure for a section of the HTTP Data is as follows: SEND:(SOCKET ON VPN):(CONTENT LEN):(CONTENT) This should allow multiple packets to be ‘stacked up’ without it failing. But somewhere, some how, something its working as intended. I have spent hours debugging and have no idea. Here is my code: Receiving HTTP Data from VPN Server: $conrecv = TCPRecv( $conn_sock, 9999) $Portal_BUFFER &= $conrecv ;Some irrelevant bits in the middle if StringLeft( $Portal_BUFFER, 4) = "SEND" Then $split = StringSplit( $Portal_BUFFER, ":") $pos = Locate_portal( $split[2]) if $split[1] = "SEND" Then $startcutlen = StringLen("SEND:::"&$split[2]&$split[3]) ConsoleWrite("INCOMING DATA:" & @CRLF & BinaryToString(_Crypt_DecryptData(StringMid($Portal_BUFFER, $startcutlen+1, $split[3]),$hKey,$CALG_USERKEY)) & @CRLF) TCPSend( $DEVICE_SOCKET[$Portal_USERID[$pos]], _Crypt_DecryptData(StringMid($Portal_BUFFER, $startcutlen+1, $split[3]),$hKey,$CALG_USERKEY)) EndIf $Portal_BUFFER = StringTrimLeft($Portal_BUFFER, $startcutlen+StringLen( StringMid($Portal_BUFFER, $startcutlen+1, $split[3]))) ConsoleWrite(@CRLF &@CRLF & "SEND FIN, BUFFER: " & $Portal_BUFFER) EndIf Sending HTTP Data from VPN Server: $server_data = TCPRecv( $SERVER_Socket[$x], 9999) if @error then Close_Server_Socket( $x) ContinueLoop EndIf $count = StringLen( $server_data) if $server_data <> "" then ;LOOpY DOOPY Round to send all data. $snd = $server_data Do $senddata = _Crypt_EncryptData(StringLeft( $snd, 4558),$hKey,$CALG_USERKEY) $snd = StringTrimLeft( $snd, StringLen($senddata)) TCPSend( $User_Socket_array[$SERVER_User[$x]], "SEND:"&$SERVER_Socket[$x]&":"&StringLen($senddata)&":"&String($senddata)) ConsoleWrite("Sending: " & "SEND:"&$SERVER_Socket[$x]&":"&StringLen($senddata)&":"&$senddata & @CRLF) Sleep(150) Until StringLen($snd)<=0 EndIf Thanks in advance. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
twitchyliquid64 Posted February 1, 2011 Author Share Posted February 1, 2011 BUMP come on guys I really need some help. Thanks in advance. ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now