erifash Posted January 1, 2006 Share Posted January 1, 2006 (edited) [old version]I have created a program named AutoProxy that will, when run, accept traffic to your network ip address (@IPADDRESS1) on port 80 (you may change the port in the code). If you open a web browser and go to http://put.your.networkip.here:port the program will send the web browser (through tcp) an html page named 'local.htm'. Anyone on the local network may view the page. The special thing about this html document is that AutoProxy will dynamically replace variables in the html (beginning and ending with '%') with variables specified in the file 'variables.ini'. You may edit the variables.ini to add your own variables/macros. The best thing about this program is that it is so versatile. Going to my network ip even works on my psp! [/old version]AutoProxy has been recently updated. Now the default file is index.htm. It has custom commands and webserver functionality (untested). Some minor bugs were fixed. See post #12 for details.Everything required is in the zip attached.Questions/comments are greatly appreciated! EDIT: Added %port% to variables.ini.EDIT: Added %get% variable and example html form.EDIT: Rebuilt with many new features! See post #12 for details.EDIT: Made a simple version. This will just display a page to anyone who connects. See post #16.AutoProxy.zip Edited February 3, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
nfwu Posted January 1, 2006 Share Posted January 1, 2006 hmmm.... i can modify this script to work as a database server... anyway, good job! TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
erifash Posted January 1, 2006 Author Share Posted January 1, 2006 (edited) Thanks! I wanted to make this as useful as possible because I can see it being used for many different things. All I need to do now is somehow get input from the web page back to the script (AutoItX anyone? hmmm...). Edited January 1, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
nfwu Posted January 1, 2006 Share Posted January 1, 2006 let me think...the script sends the request as a GET request:http://10.0.0.1:80/?q=100q=100 is the dataAnd the server returns the data as a html or xml page.Can't talk more today, gotta go! TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
pingpong24 Posted January 1, 2006 Share Posted January 1, 2006 damn it someone implemented a proxy before me . NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 1, 2006 Share Posted January 1, 2006 Hmm, this looks promising. Too bad nobody has made an FTP server that can actually work through my firewall. Tried many, failure occured. My router doesn't like FTP servers, even though i configured the port forwarding to allow incoming and outgoing UDP and TCP connections for FTP servers using the correct port and everything. This will only work on LAN right? It would be neat if it worked for WAN as well. As in: http://<your ISP assigned WAN IP>/index.html "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
erifash Posted January 1, 2006 Author Share Posted January 1, 2006 This will only work on LAN right?True. It would be neat if it worked for WAN as well. As in: http://<your ISP assigned WAN IP>/index.htmlThat would be cool. I really wanted it to work over the internet but for $IP I can't use the computer's public ip. It would be nice to have your computer be a webserver using AutoIt. @nfwu: Would this html work? I haven't tested it as of yet. I am trying to figure out what exactly it would send the script.<center> <form action="http://%ip%:80/?q=textarea" method="get" name="AutoExecute"> <textarea name="textarea" cols="40" rows="5" wrap="virtual"></textarea><br> <input name="execute" type="submit" value="Execute AutoIt Code on Server"> </form> </center> My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
erifash Posted January 1, 2006 Author Share Posted January 1, 2006 Ahhh! The computer that i'm on right now won't let me test anything... I guess I will have to wait until tomorrow. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
nfwu Posted January 2, 2006 Share Posted January 2, 2006 (edited) Ok, this is how it will work:<center> <form action="http://10.0.0.1:80/" method="get" name="AutoExecute"> <textarea name="data1" cols="40" rows="5" wrap="virtual"></textarea><br> <textarea name="data2" cols="40" rows="5" wrap="virtual"></textarea><br> <input type="submit" value="Execute AutoIt Code on Server"> </form> </center>then the url that the web browser would request for is:http://10.0.0.1:80/?data1=whateva&data2=someinputwhere whateva and someinput are what the user inputed.spaces in the data will be send as %20 like:http://10.0.0.1:80/?data1=spaces%20rock!&data2=How%20do%20you%20do?with the input being "spaces rock!" and "How do you do?"so, to recap, format:http://<url>?<name_of_input>=<data>&<name_of_input2>=<data> Edited January 2, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
erifash Posted January 2, 2006 Author Share Posted January 2, 2006 Thank you. For a second there I thought I would need to brush up on my javascript knowledge! All that's left to do for now is figure out what information the script is recieving ($recv) when the user presses 'execute'. I can't test it at the moment so all I can do now is add the variable %port% to variables.ini. It is updated in the first post. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
erifash Posted January 2, 2006 Author Share Posted January 2, 2006 (edited) I added the %get% variable to variables.ini plus gave an example on how to use it in the html. Now AutoProxy can store information from the browser/user into a variable for later use! Keep in mind that AutoProxy is just an example of what AutoIt can accomplish and think up new ways to use this code. Edited January 2, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
erifash Posted January 17, 2006 Author Share Posted January 17, 2006 Okay, I have rebuilt AutoProxy with lots of new features: 1. Custom commands: It will now execute mini-scripts defined in autoproxy.ini with included functions in functions.au3. 2. Webserver functionality! If you configure port forwarding correctly, AutoProxy will act as a webserver. (sorry untested, stupid port forwarding...) 3. Other pages/files: If any files are requested by the client, AutoProxy will send it to them. 4. Error pages: AutoProxy will put up the appropriate error page when it encounters an error. 5. Various improvements and bug fixes. If you have any problems, bug reports, comments, or questions post them here! The new zip is in the first post. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
ConsultingJoe Posted January 27, 2006 Share Posted January 27, 2006 wow, I really like this. I would like to see if i can get this into my script if you wouldn't mind. i am confused on how it works completely, is there some way it can be more simple. and for some reason the script uses my router assigned ip instead of my internet ip. please help. Thank you very much Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
xman Posted February 1, 2006 Share Posted February 1, 2006 (edited) Question from an autoit newbie here... Why do I get an error when I try to run the script? Line 76 (file c:\.......\AutoProxy.au3) Case "goto" Error : "Case" statement with no matching "Select" statement Thanks.. :-) Edited February 1, 2006 by xman Link to comment Share on other sites More sharing options...
erifash Posted February 2, 2006 Author Share Posted February 2, 2006 (edited) Sorry I've been away for a while... @zerocool: I will put up a simple version of this script soon. To fix your problem just use 127.0.0.1. @xman: You need the latest beta version of AutoIt. Edited February 6, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
erifash Posted February 2, 2006 Author Share Posted February 2, 2006 Here it is, plain and simple: expandcollapse popupGlobal $session = 1 Global $listen Global $sock TCPStartup() HotKeySet('{ESC}', 'OnAutoItExit') Global Const $IP = @IPAddress1 Global Const $PORT = 54321 Global Const $HEADER = 'HTTP/1.0 200 OK' & @CRLF & 'Content-Type: text/html' & @CRLF & @CRLF Global $file = @ScriptDir & '\index.htm' Global $html Global $recv If FileExists($file) Then $html = FileRead($file) Else $html = '<b>This is a test.<b>' EndIf $listen = TCPListen($IP, $PORT, 100) If $listen = -1 Then mError('Unable to connect.') Run(@ComSpec & ' /c start http://' & $IP & ':' & $PORT, @ScriptDir, @SW_HIDE) While 1 $sock = TCPAccept($listen) If $sock >= 0 Then $recv = _SockRecv($sock) $send = _SockSend($sock, $header & $html) TCPCloseSocket($sock) Else Sleep(10) EndIf Wend Func mError($sText, $iFatal = 0, $sTitle = 'Error', $iOpt = 0) Local $ret = MsgBox(48 + 4096 + 262144 + $iOpt, $sTitle, $sText) If $iFatal Then Exit Return $ret EndFunc Func _SockRecv($iSocket, $iBytes = 2048) Local $sData = '' While $sData = '' $sData = TCPRecv($iSocket, $iBytes) Wend Return $sData EndFunc Func _SockSend($iSocket, $sData) Return TCPSend($iSocket, $sData) EndFunc Func OnAutoItExit() TCPCloseSocket($sock) TCPCloseSocket($listen) TCPShutdown() Exit EndFunc My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
ccdust Posted February 25, 2006 Share Posted February 25, 2006 Here is my combined script: expandcollapse popup#include <Array.au3> Global $session = 1 Global $listen Global $sock TCPStartup() Global Const $IP = @IPAddress1 Global Const $PORT = 80 Global $header Global $html Global $recv Global $write Global $lista[255] ResetNormal() $listen = TCPListen($IP, $PORT, 100) If $listen = -1 Then mError('Unable to connect.') Func ResetNormal() ResetHeader() LoadHTML(@ScriptDir & "\index.htm") EndFunc ;==>ResetNormal Func ResetHeader($sType = "text/html", $sNum = "200") $header = 'HTTP/1.0 ' & $sNum & ' OK' & @CRLF & 'Content-Type: ' & $sType & @CRLF & @CRLF EndFunc ;==>ResetHeader While 1 $sock = TCPAccept($listen) If $sock >= 0 Then $recv = _SockRecv($sock) If StringLeft($recv, 11) <> "GET / HTTP/" Then _GET($recv) $send = _SockSend($sock, $header & $html) TCPCloseSocket($sock) ResetNormal() $session += 1 DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Else Sleep(10) EndIf WEnd Func URLUnformat($sURL) Local $sNew = '' $sURL = StringSplit(StringReplace($sURL, "+", " "), "") For $i = 1 To $sURL[0] If $sURL[$i] = "%" Then $sNew &= Chr('0x' & $sURL[$i + 1] & $sURL[$i + 2]) $i += 2 Else $sNew &= $sURL[$i] EndIf Next Return $sNew EndFunc ;==>URLUnformat Func _GET($sData) $sData1 = StringSplit($sData, @CRLF, 1) $sData = StringSplit($sData, @CRLF, 1) If @error Or Not IsArray($sData) Then ResetHeader('text/html', '500') LoadHTML(@ScriptDir & "\404.htm") Return EndIf $sData = StringTrimRight(StringTrimLeft($sData[1], 5), 9) If $sData == "?" Or $sData == "?=" Then ResetHeader('text/html', '500') LoadHTML(@ScriptDir & "\500.htm") Return EndIf $ime1 = StringSplit($sData1[1], " ", 1) $ime2 = StringSplit($ime1[2], "=", 1) If $ime2[1] == "/?command" And $ime2[2] > "" Then Select Case $ime2[2] = "exit" Exit Case $ime2[2] = "result" WriteHTML('Result:<br>' & ArrayDisplayHTML($sData1)) Case Else _ArrayAdd($lista, $ime2[2]) WriteHTML('Result at write:<br>' & ArrayDisplayHTML($lista)) EndSelect ResetHeader() Return EndIf Local $sGetFile = @ScriptDir & "\" & StringReplace(URLUnformat($sData), "/", "\") If FileExists($sGetFile) And Not StringInStr(FileGetAttrib($sGetFile), "D") Then Local $sExt = StringSplit($sGetFile, ".") ResetHeader(IniRead(@ScriptDir & "\nastavitve.ini", "Extentions", $sExt[$sExt[0]], "*/*")) LoadFILE($sGetFile) Return Else ResetHeader('text/html', '404') LoadHTML(@ScriptDir & "\404.htm") Return EndIf If $sData == "" Then ResetNormal() Return Else ResetHeader('text/html', '404') LoadHTML(@ScriptDir & "\404.htm") Return EndIf EndFunc ;==>_GET Func LoadHTML($sFile) $html = FileRead($sFile) EndFunc ;==>LoadHTML Func WriteHTML($write) $html = $write EndFunc ;==>WriteHTML Func LoadFILE($sFile) $html = FileRead($sFile) EndFunc ;==>LoadFILE Func mError($sText, $iFatal = 0, $sTitle = 'Error', $iOpt = 0) Local $ret = MsgBox(48 + 4096 + 262144 + $iOpt, $sTitle, $sText) If $iFatal Then Exit Return $ret EndFunc ;==>mError Func _SockRecv($iSocket, $iBytes = 2048) Local $sData = '' While $sData = '' $sData = TCPRecv($iSocket, $iBytes) WEnd Return $sData EndFunc ;==>_SockRecv Func _SockSend($iSocket, $sData) Return TCPSend($iSocket, $sData) EndFunc ;==>_SockSend Func ArrayDisplayHTML(Const ByRef $avArray) Local $iCounter = 0, $sMsg = "" If (Not IsArray($avArray)) Then SetError(1) Return 0 EndIf For $iCounter = 0 To UBound($avArray) - 1 $sMsg = $sMsg & StringStripCR($avArray[$iCounter]) & "<and>" Next SetError(0) Return $sMsg EndFunc ;==>ArrayDisplayHTML Func OnAutoItExit() TCPCloseSocket($sock) TCPCloseSocket($listen) TCPShutdown() Exit EndFunc ;==>OnAutoItExit Ponosen prebivalec Slovenije!My blog http://blog.babnopolje.net/ Link to comment Share on other sites More sharing options...
Adam1213 Posted March 29, 2006 Share Posted March 29, 2006 It is good but when it opens a page it does it in an exisiting window. If IniRead(@ScriptDir & "\autoproxy.ini", "Server", "startbrowser", "0") == "1" Then Run(@ComSpec & " /c start explorer http://" & $IP & ":" & $PORT, @ScriptDir, @SW_HIDE) will solve the problem (line 22) (just added explorer) IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
ConsultingJoe Posted July 12, 2006 Share Posted July 12, 2006 Hey guys about this, Why can't this work over WAN, why only over LAN? Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
spyrorocks Posted July 12, 2006 Share Posted July 12, 2006 can you make this an actual proxy that you can use like The Proxomitron? or similer? Im looking for some code that can be used as a transperent proxy that sits on your computer and hooks requests for sertin webpages. [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center] 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