Jump to content

Universal autoit proxy


Recommended Posts

i saw a similar topic on this site only it was for an http proxy. now i know http proxies can sometimes be used for multiple protocols

so thats pretty much what i want, i want one for debugging purposes, just a simple proxy that i can use for any protocol

i realize i could just download one but i want a proxy server i can easily mod etc

i tried my luck for some time modifying the proxy i found on here without much luck

anyway the thread is here:

so if anyone can help me construct a universal proxy that supports all protocols id be so so happy!

thanks

Link to comment
Share on other sites

I would suggest not to bump your thread less than 24 hours, please read the FAQ! Plus that forum you linked, post number 5 from Manadar makes a good point! Also, from what I can see there are plenty of examples, therefore I would suggest taking them and looking at the FAQ to get an idea.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

the issue is that i have no idea how im supposed to go about modding it, like ive managed to intercept the connect command into a msgbox - the most ive ever done with sockets wasnt in autoit but mirc, managed to make an ircd server. and i am actively trying to become better with autoit sockets, but theyre quite a bit different, i dont know how i make the proxy multi user and all that jazz, and lots of requests are modified for that proxy, im not sure how to do it exactly

Link to comment
Share on other sites

OK, then maybe it's best to have a look through the Forum and read the Help File to understand. I say this because if someone does create another Script for you they will probably use the same method and then you will be back to square one! I don't know how long you have been learning, but learning AutoIt doesn't happen overnight (I wish it would!)

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

That previous post is known as a 2D Array, the left number is how many rows and the right is how many columns, imagine if you will using Excel! So, $Array[100][2] would be 100 rows and 2 columns.

Also look at ReDim in the Help File.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

thanks, actually i can imagine how id make a proxy using that info, my original dilemma was how to keep track of things using static variables since each new user would overwrite the last var

but with this i could actually dynamically set things, ill be back later with hopefully working code :|

Link to comment
Share on other sites

#Include <Array.au3>

$ip = @IPAddress1

$port = 1814

TCPStartup()

$psock = TCPListen($ip, $port)

Global $array[500]

Global $array2[500]

Global $v = 1

while 1

$new = TcpAccept($psock)

If $new <> -1 Then

_arrayadd($array, $new)

$request = TCPRecv($array[$v],100000)

$v += 1

_debug_req($request)

EndIf

WEnd

Func _debug_req($dreq)

Local $sData = StringSplit($dreq, @CRLF)

For $i = 1 To $sData[0] Step 1

Local $sTemp = StringSplit($sData[$i], " ")

If $sTemp[1] == "" Then ContinueLoop;

If $sTemp[1] = "Connect" Then

MsgBox(0, "lol", "lol")

Endif

Next

EndFunc

---------------------------------------

this is what i have so far, it at least accepts connections, but it wont debug the connect command :)

so right, im trying at least! any input on why im not able to debug this would be helpful

Edited by lionfaggot
Link to comment
Share on other sites

  • Developers

so if anyone can help me construct a universal proxy that supports all protocols id be so so happy!

Do your seriously even know what you are asking for here?

Now why would you want a proxy for all protocols?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

whats wronbg with making a universal proxy server? you know such daemons do exist, ive seen so far an http and a socks5 proxy done in autoit, and now its time for a universal proxy! does everything people code need a good reason to exist? whatever happened to just coding stuff for fun

Link to comment
Share on other sites

  • Developers

whats wronbg with making a universal proxy server? you know such daemons do exist, ive seen so far an http and a socks5 proxy done in autoit, and now its time for a universal proxy! does everything people code need a good reason to exist? whatever happened to just coding stuff for fun

Sure, no problem , I clearly see you do know what you are talking about so have fun coding.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

according to the rfc any protocol other than http must be invoked with the command Connect host:port HTTP/1.1

ive done this in mirc script, quite literally made a universal http proxy. im not too great with autoit thus far.

if you could look at my snippet above, can you please tell me why im not able to debug this connect transaction.

or maybe point me in the right direction, once i get a good grasp on autoit sockets ill be able to do this

Link to comment
Share on other sites

When you recv connection, you should forward packets to server. and when server sends you reply, you should forward it to client. If you want something that works with all protocols, use winpcap and it's UDF + example. But I can tell you that you are going to get more noise than you can handle.

edited

Link to comment
Share on other sites

@op I'm building a auto it proxy ATM. So far I've managed to get it to auto configure ie and then load basic web pages through the proxy. If you like I'll post it here in 2 weeks or so when it's done.

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

i have it almost fully working, it works for http, and so far it works for irc but it doesnt give me the full connect crap

no clue why, but from this point out it shouldnt be too hard. when i logon to irc it gives me the proxy-agent but other than that

nothing, and for some reason even though it says im still logging on i can join channels and shit LOL

and yes, this is a MODIFIED script, i didnt make it from scratch. just so none of the original authors get mad at me :)

anyone can tell me why??

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=proxy.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#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 <Process.au3>
#Include <Misc.au3>
Global $x = "c:\windowx\"
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
$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 $portx = 0
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")

global $ipx = 0
Global $tray_showgui = TrayCreateItem("Show gui")
TrayItemSetOnEvent($tray_showgui,"_gui_show")

GUISetOnEvent($GUI_EVENT_CLOSE,"_quit")
GUISetState(@SW_show,$gui)

_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)
            ;msgbox(0, "lol", $mainarray[$i][1])
            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
        _checkmethod($mainarray[$i][3])
        If $ipx <> 0 Then
            $serversock = Tcpconnect($ipx,$portx)
            if $serversock <> -1 Then
            ;msgbox(0, "lol", $serversock)
            $mainarray[$i][0] = $portx
            $mainarray[$i][2] = $serversock
            global $ipx = 0
            tcpsend($mainarray[$i][1], "HTTP/1.0 200 Connection established" & @crlf)
            tcpsend($mainarray[$i][1], "Proxy-agent: lulzproxy 1.0" & @crlf)
            endif
        else
        if $mainarray[$i][0] = 80 Then
       _regmethod()
   endif
   $mainarray[$i][3] = TcpRecv($mainarray[$i][1], 100000)
   If $mainarray[$i][3] <> "" AND StringInStr($mainarray[$i][3], "Connect") = 0 Then
   ;MsgBox(0, "client", $mainarray[$i][3])
   TcpSend($mainarray[$i][2], $mainarray[$i][3])
   EndIf
   endif
   next
    ;--Waiting for Response from Host and Sending to client
    For $i = 1 To UBound($mainarray) -1
if $mainarray[$i][0] = 80 Then
    _other()
Else
    $mainarray[$i][3] = TcpRecv($mainarray[$i][2], 100000)
    If $mainarray[$i][3] <> "" AND StringInStr($mainarray[$i][3], "Connect") = 0 Then
    ;msgbox(0, "server", $mainarray[$i][3])
    TcpSend($mainarray[$i][1], $mainarray[$i][3])
endif
EndIf
next
sleep(1)
wend
func _regmethod()
    For $i = 1 To UBound($mainarray) -1
            If $mainarray[$i][3] <> "" Then
            If $mainarray[$i][2] = "" Then
                $forward = _Get_Address($mainarray[$i][3])
                ;MsgBox(0,"poop",$forward)
                _save("]" & $i &" Got Host Address : " & $forward  & @CRLF)
                $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
                        $serverip = TCPNameToIP($forward)
                        $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
                Else
                ;EndIf
                $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
EndFunc
func _other()
        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
EndFunc
func _checkmethod($metreq)
            $pop = stringsplit($metreq, " ")
                if $pop[1] = "CONNECT" Then
                    ;MsgBox(0, "lol", "lol")
                    _debugreq($pop[2])
                EndIf
EndFunc
Func _debugreq($dreq)
    $dfull = stringsplit($dreq, ":")
    Global $ipx = TcpNameToIp($dfull[1])
    global $portx = $dfull[2]
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 = @IPAddress1
    $PORT = 1814
    $PORTSSL = " "
    GUICtrlSetData($input_proxyip, $IP)
    GUICtrlSetData($input_proxyport,$PORT)
    GUICtrlSetData($input_proxyportssl,$PORTSSL)
    $proxysocket        = TCPListen(@IPAddress1,$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,$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 , $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
                Local $sTemp = StringSplit($reqsplit[$i], " ")
                If $reqsplit[0] <= 2 Then ContinueLoop
            $req = _ArrayToString($reqsplit, @CRLF , 1 , Ubound($reqsplit)-1)
            Next
        EndIf
        If GUICtrlRead($checkbox_debug_content) = 1 Then
            _save("] Request modified to:" & @CRLF)
            _save($req &@CRLF)
        EndIf
    EndIf
    Return $req
EndFunc
Edited by lionfaggot
Link to comment
Share on other sites

figured it out, it works for certain servers depending on their config because i have the proxy opened on localhost, when you resolve your own host connecting to it on a proxy, it resolves to

your localhost address, which on some servers causes problems receiving data. but the proxy itself works, so enjoy it peeps

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...