Jump to content

Local Proxy Server v1.00


ripdad
 Share

Recommended Posts

LPS1.png

This script is based on algorithm code from EnrMa.

Updated: January 22, 2018

Made improvements. Changes are in the script header.

Known Issues: AutoIt x64 does not work properly with this script.

Download: LocalProxyServer_v1.00.zip

 

Edited by ripdad
updated

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

I found this on the web and thought the information would be useful.

How to set up a proxy server

Guide: Block websites and protect your network from malware

http://www.techradar.com/news/networking/how-to-set-up-a-proxy-server-704981

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

Can you help, add a feature to connect over another proxy?

I tried the modified version posted by Ka36ek at '?do=embed' frameborder='0' data-embedContent>>.

After found the Base64.au3 to included. I got it to authenticated successfully on the other proxy server but returned blank display on internet explorer or firefox.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=proxy.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
TCPStartup()
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#Include <Array.au3>
#Include <File.au3>
#include <WindowsConstants.au3>
#include <Base64.au3>

Opt("GUIOnEventMode" , 1)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",3)
Opt("TrayOnEventMode",1)

Global $ini = @ScriptDir & "\config.ini"
Global $mainarray[30][10]
Global $proxysocket , $proxysocketssl
Global $GUISHOW = 1
Global $FUseProxy = False
Global $SProxyAuthCode = "" ; ???????? ????? ? ???

$mainarray[0][0] = "Hostport"
$mainarray[0][1] = "Clientsocket"
$mainarray[0][2] = "Hostsocket"
$mainarray[0][3] = "Request"
$mainarray[0][4] = "Hostname"
$mainarray[0][5] = "Timerhandle connection"
$mainarray[0][6] = "Blocked"
$mainarray[0][7] = "State"
$mainarray[0][8] = "connection type"
$mainarray[0][9] = "req count"



Global $gui = GUICreate("ProxyServer v0.2",700,700)
$DEBUG=GUICtrlCreateEdit("" , 5 , 30 , 500 ,670,BitOr($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
GUICtrlSetLimit(-1 , 2000000000000000)
Global $button_debug_clear = GUICtrlCreateButton("Clear",5,5,90,20)
GUICtrlSetOnEvent($button_debug_clear,"_debug_clear")
GUICtrlCreateLabel("Listening IP:",515,40,70,20)
GUICtrlCreateLabel("Port HTTP:",515,60,70,20)
GUICtrlCreateLabel("Port HTTPS:",515,80,70,20)
Global $input_proxyip =  GUICtrlCreateInput("",590, 40,100,20)
Global $input_proxyport = GUICtrlCreateInput("",590,60,60,20)
Global $input_proxyportssl = GUICtrlCreateInput("",590,80,60,20)
Global $button_proxy_save = GUICtrlCreateButton("Save and Restart",515,140,180,20)
GUICtrlSetOnEvent($button_proxy_save,"_mainsocket_save")

Global $checkbox_debug = GUICtrlCreateCheckbox("Debugmode", 515 , 240, 120, 20)
Global $checkbox_debug_save = GUICtrlCreateCheckbox("Save Debug to file", 515 , 260, 120, 20)
Global $checkbox_debug_content = GUICtrlCreateCheckbox("Show traffic content", 515 , 280, 120, 20)
Global $button_debug_content = GUICtrlCreateButton("Binary to String",515,320,120,19)
GUICtrlSetOnEvent($button_debug_content,"_debug_binary")
Global $button_debug_array = GUICtrlCreateButton("show mainarray",515,340,120,19)
GUICtrlSetOnEvent(-1,"_show_array")


#Region ### START Koda GUI section ###
Global $Proxy_Form = GUICreate("Settings", 209, 190, 192, 132)
Global $PF_IP = GUICtrlCreateInput("", 8, 24, 121, 24)
Global $PF_Port = GUICtrlCreateInput("", 136, 24, 57, 24)
Global $PF_Login = GUICtrlCreateInput("", 88, 65, 105, 24)
Global $PF_Pass = GUICtrlCreateInput("", 88, 96, 105, 24)
Global $PF_OK = GUICtrlCreateButton("OK", 8, 152, 89, 25, 0)
GUICtrlSetOnEvent($PF_OK,"_close_proxy_settings")
Global $PF_Save = GUICtrlCreateButton("Save", 104, 152, 89, 25, 0)
GUICtrlSetOnEvent($PF_Save,"_save_proxy_settings")
GUICtrlCreateLabel("Pass", 16, 100, 54, 20)
GUICtrlCreateLabel("Username", 16, 65, 33, 20)
GUICtrlCreateLabel("IP Address", 16, 3, 80, 20)
GUICtrlCreateLabel("Port", 136, 3, 39, 20)
Global $PF_CheckboxUse = GUICtrlCreateCheckbox("PF_Use", 16, 128, 137, 17)
GUISetState(@SW_HIDE, $Proxy_Form)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE,"_quit")

Global $tray_showgui = TrayCreateItem("Show gui")
Global $tray_showproxyform = TrayCreateItem("????????? ??????")
TrayItemSetOnEvent($tray_showgui,"_gui_show")
TrayItemSetOnEvent($tray_showproxyform,"_proxy_settings")

GUISetOnEvent($GUI_EVENT_CLOSE,"_close_proxy_settings",$Proxy_Form )
GUISetState(@SW_SHOW,$gui)
_read_ini()



_mainsocket_create()

While 1
    $newclientsock  = TCPAccept($proxysocket)
    If $newclientsock <> -1 Then
        _save("] new HTTP clientconnection :" &_SocketToIP($newclientsock) &@CRLF)
        _clientconnection_to_mainarray($newclientsock,80,"HTTP")
    EndIf
    $newclientsockssl   = TCPAccept($proxysocketssl)
    If $newclientsockssl <> -1 Then
        _save("] new HTTPS clientconnection :" &_SocketToIP($newclientsockssl) &@CRLF)
        _clientconnection_to_mainarray($newclientsockssl,443,"HTTPS","start")
    EndIf
    ;--Recieving Req from Client
    For $i = 1 To UBound($mainarray) -1
        If $mainarray[$i][1] <> "" Then
            $request = TCPRecv($mainarray[$i][1],100000)
            If @error Then

                _save("] Client " & $i & " closed connection after " & Floor(TimerDiff($mainarray[$i][5])) & " ms" & @CRLF)
                _mainarray_deleteclient($i)
            EndIf

            If $request <> "" Then
                _save("] Client " & $i & " requested" & @CRLF  & @CRLF & $request & @CRLF)
                $mainarray[$i][9] += 1
                $mainarray[$i][3] = $request
                If GUICtrlRead($checkbox_debug_content) = 1 Then _save($request & @CRLF)
            EndIf
        EndIf
    Next

    ;--connecting and sending Req to Host
    For $i = 1 To UBound($mainarray) -1
        If $mainarray[$i][3] <> "" Then
            If $mainarray[$i][2] = "" Then

                IF $FUseProxy Then
                    ;
                    $forward = _Get_Address($mainarray[$i][3])
                    $forward = $mainarray[$i][3] ;????? ????? ???????? ?????? ?? ??????
                    _save("]" & $i &" ?????????? ?????? ?? ?????? : " & $forward  & @CRLF)
                    ;
                Else
                    ;
                    $forward = _Get_Address($mainarray[$i][3]) ;????? ????? ???????? ?????? ?? ??????
                    _save("]" & $i &" Got Host Address : " & $forward  & @CRLF)
                    ;
                EndIf

                $mainarray[$i][6] = 0
                $mainarray[$i][4] = $forward
                If $forward = "0" Then
                    _Send_Response($mainarray[$i][1],400)
                    _save("]" & $i &" Host is 0 , Error 400" & @CRLF)
                Else
                        IF $FUseProxy Then
                            ;
                            $serverip   = GUICtrlRead($PF_IP)
                            $mainarray[$i][0]=GUICtrlRead($PF_Port)
                            ;
                        Else
                            ;
                            $serverip   = TCPNameToIP($forward)
                            ;
                        ENDIF

                        $serversock = TCPConnect($serverip,$mainarray[$i][0])
                        If $serversock <> -1 Then
                            _save("]" & $i &" Connected to Host: " & $forward & @CRLF)
                            $mainarray[$i][2] = $serversock

                        Else
                            _save("]" & $i &" Not Connected to Host: " & $forward & @CRLF)
                            _Send_Response($mainarray[$i][1],400)
                            _mainarray_deleteclient($i)
                        EndIf
                EndIf
            Else
                $forward = _Get_Address($mainarray[$i][3])
                If $forward <> $mainarray[$i][4] Then
                    _save("]" & $i &" Host Address changed from: " & $mainarray[$i][4] & " to: " & $forward & @CRLF)
                    $mainarray[$i][4] = $forward
                    TCPCloseSocket($mainarray[$i][2])
                    $mainarray[$i][2] = ""
                EndIf
            EndIf
            If $mainarray[$i][2] <> "" Then
                $prevlen = StringLen($mainarray[$i][3])
                $mainarray[$i][3] = _request_modify($mainarray[$i][3],$mainarray[$i][4])
                If $mainarray[$i][7] = "" Then
                    ;$mainarray[$i][3] = _request_modify($mainarray[$i][3],$mainarray[$i][4])
                    TCPSend($mainarray[$i][2] , $mainarray[$i][3])
                        If Not @error Then
                            _save("]" & $i &" Sending HTTP to Host " & $mainarray[$i][4] & " successfull prevlen:" & $prevlen & " now:" & StringLen($mainarray[$i][3]) & @CRLF)
                            $mainarray[$i][3] = ""
                        Else
                            _save("]" & $i &" Error Sending HTTP to Host " & @CRLF)
                        EndIf
                EndIf
            EndIf
        EndIf
    Next
    ;--Waiting for Response from Host and Sending to client
    For $i = 1 To UBound($mainarray) -1
        If $mainarray[$i][2] <> "" Then
            $serverresponse     = TCPRecv($mainarray[$i][2],400000,1)
            If @error Then
                _mainarray_hostkillclient($i)
            EndIf
            If $serverresponse <> Binary("") Then
                If $mainarray[$i][6] = 0 Then
                    _save("]" & $i &" Got Host response" & @CRLF)
                    If  $mainarray[$i][1] <> "" And $mainarray[$i][7] = "" Then
                        TCPSend($mainarray[$i][1],$serverresponse)
                        If Not @error Then
                            _save("]" & $i &" Sent data to Client " & @CRLF)

                            If GUICtrlRead($checkbox_debug_content) = 1 Then _save(BinaryToString($serverresponse) & @CRLF)
                        EndIf
                    EndIf
                ElseIf $mainarray[$i][6] = 1 Then
                    TCPSend($mainarray[$i][1],"HTTP/1.1 " & "403")
                    _mainarray_hostkillclient($i)
                EndIf
            EndIf
        EndIf
    Next
    ;---only for HTTPS
    For $i = 1 To UBound($mainarray) -1
        If $mainarray[$i][1] <> "" And $mainarray[$i][3] <> "" And $mainarray[$i][8] = "HTTPS" And $mainarray[$i][7] = "start" Then
            _Send_Response($mainarray[$i][1],200) ;,$data="")
            $mainarray[$i][3] = ""
            $mainarray[$i][7] = ""
        EndIf
    Next

WEnd



Func _proxy_settings()
    ;
    _read_ini()
    GUISetState(@SW_SHOW, $Proxy_Form)
    ;
EndFunc

Func _close_proxy_settings()
    ;
    GUISetState(@SW_HIDE, $Proxy_Form)

    ;
EndFunc

Func _read_ini()
    ;
    _GUICtrlEdit_SetText($PF_Port, IniRead($ini, "PROXY", "PROXYPORT", ""))
    _GUICtrlEdit_SetText($PF_IP, IniRead($ini, "PROXY", "PROXYIP", ""))
    _GUICtrlEdit_SetText($PF_Login, IniRead($ini, "PROXY", "PROXYUSER", ""))
    _GUICtrlEdit_SetText($PF_Pass, IniRead($ini, "PROXY", "PROXYPASS", ""))
    IF IniRead($ini, "PROXY", "PROXYUSE", 0) = 1 Then
        ;
        GUICtrlSetState ($PF_CheckboxUse, $GUI_CHECKED)
        $FUseProxy=True

        $SProxyAuthCode=_Base64Encode(IniRead($ini, "PROXY", "PROXYUSER", "") & ":" & IniRead($ini, "PROXY", "PROXYPASS", ""))
        ; $SProxyAuthCode=B64Encode(IniRead($ini, "PROXY", "PROXYUSER", "") & ":" & IniRead($ini, "PROXY", "PROXYPASS", ""))
        ;
    Else
        ;
        GUICtrlSetState ($PF_CheckboxUse, $GUI_UNCHECKED)
        $FUseProxy=False
        ;
    ENDIF
    ;
EndFunc

Func _save_proxy_settings()
    ;
    IniWrite($ini,"PROXY","PROXYPORT",GUICtrlRead($PF_Port))
    IniWrite($ini,"PROXY","PROXYIP",GUICtrlRead($PF_IP))
    IniWrite($ini,"PROXY","PROXYUSER",GUICtrlRead($PF_Login))
    IniWrite($ini,"PROXY","PROXYPASS",GUICtrlRead($PF_Pass ))

    ;
    IF GUICtrlRead($PF_CheckboxUse)=$GUI_CHECKED Then
        ;
        $FUseProxy=True
        IniWrite($ini,"PROXY","PROXYUSE",1)
        $SProxyAuthCode=_Base64Encode(GUICtrlRead($PF_Login) & ":" & GUICtrlRead($PF_Pass ))
        _mainsocket_create()
        ;
    Else
        ;
        $FUseProxy=False
        IniWrite($ini,"PROXY","PROXYUSE",0)
        _mainsocket_create()
        ;
    ENDIF
    ;
EndFunc

Func _show_array()
    _ArrayDisplay($mainarray)
EndFunc

Func _mainsocket_save()
    IniWrite($ini,"SYSTEM","PROXYPORT",GUICtrlRead($input_proxyport))
    IniWrite($ini,"SYSTEM","PROXYIP",GUICtrlRead($input_proxyip))
    IniWrite($ini,"SYSTEM","PROXYPORTSSL",GUICtrlRead($input_proxyportssl))
    _mainsocket_create()
EndFunc

Func _mainsocket_create()
    TCPShutdown()
    TCPStartup()
    $IP = IniRead($ini,"SYSTEM","PROXYIP","127.0.0.1")
    $PORT = IniRead($ini,"SYSTEM","PROXYPORT","8080")
    $PORTSSL = IniRead($ini,"SYSTEM","PROXYPORTSSL","8043")
    GUICtrlSetData($input_proxyip, $IP)
    GUICtrlSetData($input_proxyport,$PORT)
    GUICtrlSetData($input_proxyportssl,$PORTSSL)
    $proxysocket        = TCPListen($IP,$PORT)
    If @error Then
        _GUICtrlEdit_AppendText($DEBUG , "] Error HTTP Proxy couldn't bind socket on IP :" & $IP & " Port :" & $PORT & @CRLF)
    Else
        _GUICtrlEdit_AppendText($DEBUG , "] HTTP Proxy listening on IP :" & $IP & " Port :" & $PORT & @CRLF)
    EndIf
    $proxysocketssl     = TCPListen($IP,$PORTSSL)
    If @error Then
        _GUICtrlEdit_AppendText($DEBUG , "] Error HTTPS Proxy couldn't bind socket on IP :" & $IP & " Port :" & $PORTSSL & @CRLF)
    Else
        _GUICtrlEdit_AppendText($DEBUG , "] HTTPS Proxy listening on IP :" & $IP & " Port :" & $PORTSSL & @CRLF)
    EndIf
EndFunc


Func _Get_Address($text)
    If IsBinary($text) Then
        $text = BinaryToString($text)
    EndIf
        $serversock=StringSplit($text , @CRLF,1)
        For $i=1 To $serversock[0]
            If StringLeft($serversock[$i],6)="Host: " Then
                Return StringTrimLeft($serversock[$i],6)
            EndIf
        Next
    Return 0
EndFunc

Func _clientconnection_to_mainarray($sock,$port = 80,$type = "HTTP",$state = "")
    For $i = 1 To UBound($mainarray) -1
        If $mainarray[$i][1] = "" And $mainarray[$i][2] = "" Then
            $mainarray[$i][1] = $sock
            $mainarray[$i][0] = $port
            $mainarray[$i][5] = TimerInit()
            $mainarray[$i][7] = $state
            $mainarray[$i][8] = $type
            _save("] Added new client to mainarray , pos: " & $i & @CRLF)
            If $i + 5 > UBound($mainarray) Then ReDim $mainarray[UBound($mainarray)+5][10]
            Return
        EndIf
    Next
EndFunc

Func _mainarray_deleteclient($line)
    TCPCloseSocket($mainarray[$line][1])
    $mainarray[$line][0] = ""
    $mainarray[$line][1] = ""
    $mainarray[$line][3] = ""
    $mainarray[$line][4] = ""
    $mainarray[$line][5] = ""
    $mainarray[$line][6] = ""
    $mainarray[$line][7] = ""
    $mainarray[$line][8] = ""
    $mainarray[$line][9] = ""
    If $mainarray[$line][2]<> "" Then
        TCPCloseSocket($mainarray[$line][2])
        $mainarray[$line][2] = ""
    EndIf
EndFunc

Func _mainarray_hostkillclient($line)
    _save("]" & $line &" Connection Closed by Host after " & Floor(TimerDiff($mainarray[$line][5])) & " ms" & @CRLF)
    $mainarray[$line][2] = ""
    $mainarray[$line][4] = ""
    $mainarray[$line][5] = ""
    If $mainarray[$line][1]<> "" Then
        TCPCloseSocket($mainarray[$line][1])
        _mainarray_deleteclient($line)
    EndIf
EndFunc

Func _Send_Response($browsersock,$code,$data="")
    If $data="" Then
        $data=@CRLF & @CRLF
    Else
        $data=@CRLF & $data & @CRLF & @CRLF
    EndIf
    TCPSend($browsersock , "HTTP/1.0 " & $code & " Message" & $data)
EndFunc


Func _quit()
    TCPShutdown()
    Exit
EndFunc

Func _gui_show()
    If $GUISHOW = 0 Then
        Local $pw = InputBox("Enter Password","Enter Password","","*",150,130)
        If Not @error Then
            If $pw = "1234" Then
                GUISetState(@SW_SHOW)
                $GUISHOW = 1
                Return
            EndIf
        EndIf
    ElseIf $GUISHOW = 1 Then
        GUISetState(@SW_HIDE)
        $GUISHOW = 0
        Return
    EndIf
EndFunc

Func _save($text)
    If GUICtrlRead($checkbox_debug_save) = 1 Then
        $file = FileOpen(@ScriptDir & "\log\" & @Year & @MON & @MDAY & "-log.txt",9)
        FileWrite ($file,$text)
        FileClose($file)
    Endif
    If GUICtrlRead($checkbox_debug) = 1 Then _GUICtrlEdit_AppendText($DEBUG , $text)
Endfunc

Func _SocketToIP($SHOCKET)
    Local $sockaddr, $aRet
    $sockaddr = DllStructCreate("short;ushort;uint;char[8]")
    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
            "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf
    $sockaddr = 0
    Return $aRet
EndFunc   ;==>SocketToIP

Func _debug_binary()
    Local $aSel = _GUICtrlEdit_GetSel($DEBUG)
    Local $text = StringMid(GUICtrlRead($DEBUG),$aSel[0]+1,$aSel[1]-$aSel[0])
    If $text <> "" Then

    Else
        $text = InputBox("Binary to String","Enter Binary Data")

    EndIf
    If StringLower(StringLeft($text,2)) <> "0x" Then $text = "0x" & $text
    $tempfile = FileOpen(@ScriptDir & "\temp.txt",2)
    FileWrite($tempfile,BinaryToString($text))
    FileClose($tempfile)
    ShellExecute(@ScriptDir & "\temp.txt")
EndFunc

Func _debug_clear()
    GUICtrlSetData($DEBUG,"")
EndFunc



Func _request_modify($req,$host)
Local $encoding = "Accept-Encoding: identity" ;deflate, gzip, compress,
Local $reqsplit
Local $modified_method = 0 , $modified_connection = 0 , $modified_encoding = 0
    ;

    If $req <> "" And Not IsBinary($req) Then
        $reqsplit = StringSplit($req,@CRLF,1)
        If IsArray($reqsplit) Then
            For $i = 1 to $reqsplit[0] - 1
                _save("] modifying :" & $i & " " & $reqsplit[$i])
                IF Not $FUseProxy Then ; ???? ???????? ??? ??????
                    If StringLeft($reqsplit[$i],3) = "GET" Or StringLeft($reqsplit[$i],4) = "POST" Or StringLeft($reqsplit[$i],7) = "CONNECT" And $modified_method = 0 Then
                        $reqsplit[$i] = StringReplace($reqsplit[$i],$host,"")
                        $reqsplit[$i] = StringReplace($reqsplit[$i],"http://","")
                        $reqsplit[$i] = StringReplace($reqsplit[$i],":443","")
                        $modified_method = 1
                    EndIf
                    If StringInStr(Stringlower($reqsplit[$i]),"proxy-connection: keep-alive") And $modified_connection = 0 Then
                        $reqsplit[$i] = "Connection: keep-alive"
                        $modified_connection = 1
                    EndIf
                    If StringInStr(Stringlower($reqsplit[$i]),"accept-encoding") And $modified_encoding = 0 Then
                        $reqsplit[$i] = $encoding
                        $modified_encoding = 1
                    EndIf
                EndIf




                _save(" -> to :" & $reqsplit[$i] & @CRLF)
            Next
            $req = _ArrayToString($reqsplit, @CRLF , 1 , Ubound($reqsplit)-1)
            IF $FUseProxy Then  $req=StringReplace($req, @CRLF & @CRLF,  @CRLF & "Proxy-Authorization: Basic " & $SProxyAuthCode & @CRLF & @CRLF,-1) ; ???? ???????? ????? ?????? ????????? ???????????
        EndIf
        If GUICtrlRead($checkbox_debug_content) = 1 Then
            _save("] Request modified to:" & @CRLF)
            _save($req &@CRLF)
        EndIf
    EndIf
    Return $req
EndFunc
Link to comment
Share on other sites

stalliont,

Are you planning on running a local proxy server to an external proxy,

permanently?

I personally have not attempted it, nor do I have a need for an external proxy,

so I have nothing to test with to see if it is working properly or not.

Can you elaborate why you need an external proxy with this script?

Do you know for sure that the proxy only accepts a Base64 Encoded login?

I ask these questions out of curiosity - so I might contemplate how to go

about it and be stable - and to find out what your goal is concerning it.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

hi ripdad, thanks for quick reply.

I am trying to setup this local proxy under coorporate network and the only way to get to internet is through this proxy. Once i can get this working. Then my next step to run on a server with set commands for user can choose for automated reporting as we have different external websites that need to get source data for manipulation.

Ah 'Base64 Encoded login' you mentioned might be the culprit. I might starting checking which encode type login the proxy is using could fix my problem.

It could be better to have this with your version of proxy server as its so simple and clean.

Link to comment
Share on other sites

The next question would be - is the corporate proxy a 1:1 pass-through type

or does it handle https connections separately, etc?

The reason I ask this is because the local proxy server discards the initial

request after it has connected to the host server. (Line: 237)

Afterwards, it passes the following requests to the host as they are received.

It seems to me that there would have to be some inter-action here to make

a secure connection. If this is the case, then the script would have to

be modified to handle it.

-edit-

The script would also need to know how the corporate proxy responds

if a connection could not be made, etc.

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

hi ripdad, thanks for answering my queries. I got the autenticate working, connecting thru my corporate proxy using http, but https would not work, getting an error bad request.

Things getting a little more technical trying to find out how my corporate proxy works handling https

Here is an example log connect to https://www.yahoo.com, as what you are saying that you are probably right about my corporate proxy handling https connection differently not 1 on 1 passthru.

] HTTP Proxy listening on IP :10.44.27.36 Port :8081
] HTTPS Proxy listening on IP :10.44.27.36 Port :8082
] new HTTPS clientconnection :10.44.27.36
] Added new client to mainarray , pos: 1
] Client 1 requested

CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443


CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443


]1 Proxy Server : CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443


]1 Connected to Host: CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443


] modifying :1 CONNECT www.yahoo.com:443 HTTP/1.1 -> to :CONNECT www.yahoo.com:443 HTTP/1.1
] modifying :2 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0 -> to :User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
] modifying :3 Proxy-Connection: keep-alive -> to :Proxy-Connection: keep-alive
] modifying :4 Connection: keep-alive -> to :Connection: keep-alive
] modifying :5 Host: www.yahoo.com:443 -> to :Host: www.yahoo.com:443
] modifying :6  -> to :
] Request modified to:
CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443
Proxy-Authorization: Basic ZmFsXHRyYW5sOiFwaXNzb2ZmOTkh



] Client 1 requested

0x16030100AF010000AB03030104FAE2AEAF84659D21029E3DA34074AE396AFE653FC6809FE294A1E2D02A0000002EC02BC02FC00AC009C013C014C012C007C0110033003200450039003800880016002F004100350084000A000500040100005400000012001000000D7777772E7961686F6F2E636F6DFF01000100000A00080006001700180019000B000201000023000033740000000500050100000000000D0012001004010501020104030503020304020202
0x16030100AF010000AB03030104FAE2AEAF84659D21029E3DA34074AE396AFE653FC6809FE294A1E2D02A0000002EC02BC02FC00AC009C013C014C012C007C0110033003200450039003800880016002F004100350084000A000500040100005400000012001000000D7777772E7961686F6F2E636F6DFF01000100000A00080006001700180019000B000201000023000033740000000500050100000000000D0012001004010501020104030503020304020202
]1 Sending HTTP to Host CONNECT www.yahoo.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0
Proxy-Connection: keep-alive
Connection: keep-alive
Host: www.yahoo.com:443

 successfull prevlen:362 now:362
]1 Got Host response
]1 Sent data to Client 
HTTP/1.1 400 Bad Request ( The data is invalid.  )
Via: 1.1 SYD0364
Connection: close
Proxy-Connection: close
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 615

I think I just play around and do my codes with http connection, and troubleshoot https on the other thread for 'autoit proxy server',

but i like your continued work with the local proxy server, and the TCP Passive Proxy Filter, these are great alternatives...

Link to comment
Share on other sites

Glad to hear you got the http authentication working.

Good luck to you with the https part of it.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

  • 2 weeks later...

Updated first post  to v0.6b

---

stalliont,

I think I found your https problem with the corporate proxy -- refer to first post update notes.

From your log,

Host: www.yahoo.com:443 --> HTTP/1.1 400 Bad Request  ( The data is invalid.  )
 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

  • 2 weeks later...
  • 9 months later...

Thanks Fire.

Have not had the time to work on it till recently. Made some changes and improvements.

If anyone has any issues with it, Now would be a good time to voice them.

Will update soon.

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

  • 3 months later...

I just downloaded the v012b update and I must be doing something wrong.  When I attempt to execute or compile it, I get a syntax error on line 41 (screenshot attached).

The error appears below line 41 and reads:

Local Const Enum $PortNumber, $ClientSocket, $RemoteSocket, $ProtocolState, $RemoteHost, $RemoteIP, $ContentLength, $ReceivedBytes, $RemoteClose, $Inactivity
error:  syntax error
error:  Statement cannot be just an expression.

 

I'm running AutoIt v3.3.14.0

Any help or tips on what I might be doing wrong with the script would be greatly appreciated.

Thanks,

TBWalker

 

 

 

Script_v012b_Error.JPG

Link to comment
Share on other sites

Remove the Const part of that line, Enums are already constants, so it's redundant anyways.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...