Jump to content



Photo

AutoProxy


  • Please log in to reply
46 replies to this topic

#1 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 01 January 2006 - 01:02 AM

[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! :P
[/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! :lmao:

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.

Attached Files


Edited by erifash, 03 February 2006 - 12:00 AM.






#2 nfwu

nfwu

    I'm not active on these forums

  • Active Members
  • PipPipPipPipPipPip
  • 1,234 posts

Posted 01 January 2006 - 03:53 AM

hmmm.... i can modify this script to work as a database server...

anyway, good job!

#3 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 01 January 2006 - 04:14 AM

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 by erifash, 01 January 2006 - 04:15 AM.


#4 nfwu

nfwu

    I'm not active on these forums

  • Active Members
  • PipPipPipPipPipPip
  • 1,234 posts

Posted 01 January 2006 - 04:28 AM

let me think...
the script sends the request as a GET request:
http://10.0.0.1:80/?q=100

q=100 is the data

And the server returns the data as a html or xml page.

Can't talk more today, gotta go!

#5 pingpong24

pingpong24

    Adventurer

  • Active Members
  • PipPip
  • 105 posts

Posted 01 January 2006 - 11:57 AM

damn it someone implemented a proxy before me :P.

#6 The Kandie Man

The Kandie Man

    All Your Base Are Belong To Us

  • Active Members
  • PipPipPipPipPipPip
  • 950 posts

Posted 01 January 2006 - 12:03 PM

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

#7 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 01 January 2006 - 06:03 PM

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.html

That 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>


#8 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 01 January 2006 - 06:37 PM

Ahhh! The computer that i'm on right now won't let me test anything... :P I guess I will have to wait until tomorrow.

#9 nfwu

nfwu

    I'm not active on these forums

  • Active Members
  • PipPipPipPipPipPip
  • 1,234 posts

Posted 02 January 2006 - 12:36 AM

Ok, this is how it will work:
<center> <form action="<a href='http://10.0.0.1:80/' class='bbc_url' title='External link' rel='nofollow external'>http://10.0.0.1:80/"</a> 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=someinput

where 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 by nfwu, 02 January 2006 - 12:38 AM.


#10 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 02 January 2006 - 04:10 AM

Thank you. For a second there I thought I would need to brush up on my javascript knowledge! :P 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.

#11 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 02 January 2006 - 05:19 PM

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. :P

Edited by erifash, 02 January 2006 - 08:27 PM.


#12 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 17 January 2006 - 08:57 PM

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. :lmao:

#13 ConsultingJoe

ConsultingJoe

    ConsultingJoe.com

  • Active Members
  • PipPipPipPipPipPip
  • 1,667 posts

Posted 27 January 2006 - 04:17 AM

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

#14 xman

xman

    Seeker

  • New Members
  • 2 posts

Posted 01 February 2006 - 04:34 PM

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 by xman, 01 February 2006 - 04:35 PM.


#15 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 02 February 2006 - 09:36 PM

Sorry I've been away for a while... :lmao:

@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 by erifash, 06 February 2006 - 09:12 PM.


#16 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 02 February 2006 - 10:07 PM

Here it is, plain and simple:
Plain Text         
Global $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


#17 ccdust

ccdust

    Seeker

  • New Members
  • 5 posts

Posted 25 February 2006 - 11:07 AM

Here is my combined script:

Plain Text         
#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/

#18 Adam1213

Adam1213

    Adventurer

  • Active Members
  • PipPip
  • 133 posts

Posted 29 March 2006 - 04:16 AM

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)

#19 ConsultingJoe

ConsultingJoe

    ConsultingJoe.com

  • Active Members
  • PipPipPipPipPipPip
  • 1,667 posts

Posted 12 July 2006 - 10:10 PM

Hey guys about this, Why can't this work over WAN, why only over LAN?

#20 spyrorocks

spyrorocks

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 728 posts

Posted 12 July 2006 - 10:59 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users