Jump to content

My Amazing Proxy Set Function - Need a Bit of Help


drego
 Share

Recommended Posts

  • Moderators

Well, just comparing the function to msdn, I know that the dwBufferLength (3rd param in dllcall()) is wrong.  It shouldn't be DllStructGetSize, it should be StringLen.

I'm still reading up on your issue though, I am in need of something like this soon myself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

It's not a solution that's been found easily it seems around the net for that particular urlmon.dll function.  I haven't found anyone that has gotten it working as of yet with username/password.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

For the record, here's the thread from yesterday from my cache.

 

I currently have a function I put together with the help of some users from a long time ago. It uses urlmon.dll to set a proxy for the active program meaning that you don't have to change the global IE proxy setting, you can have a different proxy for each autoit program you have running simultaniously. It's been a long time and I remember a bit of how to use it but I do remember that I never had to login to the proxies I was using. Now I do so I could use some help with how to make an authenticated HTTP proxy connection. Here's the function and how I would normally call it to set a SOCKS5 proxy. Note that now I need to use HTTP proxies with authentication:
Func SetProxy($proxy, $proxybypass = "")


    Local $INTERNET_OPTION_PROXY = 38


    Local $INTERNET_OPEN_TYPE_PROXY = 3


    Local $tBuff = DllStructCreate("dword;ptr;ptr")


    DllStructSetData($tBuff, 1, $INTERNET_OPEN_TYPE_PROXY)


    Local $pproxy = DllStructCreate("char[" & (StringLen($proxy) + 1) & "]")


    DllStructSetData($pproxy, 1, $proxy)


    DllStructSetData($tBuff, 2, DllStructGetPtr($pproxy))


    Local $pproxybypass = DllStructCreate("char[" & (StringLen($proxybypass) + 1) & "]")


    DllStructSetData($pproxybypass, 1, $proxybypass)


    DllStructSetData($tBuff, 3, DllStructGetPtr($pproxybypass))


    $chk_UrlMkSetSessionOption = DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", "dword", $INTERNET_OPTION_PROXY, "ptr", DllStructGetPtr($tBuff), "dword", DllStructGetSize($tbuff), "dword", 0)


EndFunc






SetProxy('socks=127.0.0.1:8080')


So there's that which is pretty impressive for an autoit app as far as embedded browser proxies go. I just dug all this up because I need to use it like I said so any suggestions for how to specify http and username/password would be great. The first thing I'm obviously going to try is http=ip:port:username:pass but of course things don't always turn out so easy. I doubt that will work but I'm about to try and in the meantime if anyone knows the exact answers to this or can improve it in any way please feel free to post.


Thanks everyone.


Edited by drego, Today, 08:57 PM.
Like This
Quote
MultiQuote
Report
#2  My Amazing Proxy Set Function - Need a Bit of Help: post #2 drego
Seeker


Active Members
35 posts
Posted Today, 09:52 PM
Now I can't get it to work again at all. There are no errors but the proxy doesn't get set. I used
SetProxy('mypoxyip:64954:username:pass123')


And it didn't do anything. The embedded browser's IP didn't change at all. I was expecting it to show me an error in the browser control but it just navigated to the site using my normal public IP. It used to work. Not sure what's going on.


Like This
Quote
MultiQuote
Report
#3  My Amazing Proxy Set Function - Need a Bit of Help: post #3 SmOke_N
It's not what you know ... It's what you can prove!


Moderators


16,247 posts
Posted Today, 10:23 PM
Well, just comparing the function to msdn, I know that the dwBufferLength (3rd param in dllcall()) is wrong.  It shouldn't be DllStructGetSize, it should be StringLen.


I'm still reading up on your issue though, I am in need of something like this soon myself.


Like This
Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Quote
MultiQuote
Report
#4  My Amazing Proxy Set Function - Need a Bit of Help: post #4 drego
Seeker


Active Members
35 posts
Posted 44 minutes ago
That's the 9th parameter in the call. Can you show me what you mean? If you can help me get this function working again it would help a lot. I'm not sure how I wound up with a messed up version of it. This is the page I'm sure you're referring to: http://msdn.microsoft.com/en-us/library/ms775125(VS.85).aspx


This is the original thread years ago where the code started: http://www.autoitscript.com/forum/topic/122933-need-help-using-urlmondll-please/?hl=%2Burlmon+%2Bproxy#entry854193


In that thread it is used for the user agent and proxy. Please post any modifications you can think of so we can fix it. It's the only way to set a proxy for your program.


Like This
Quote
MultiQuote
Report
#5  My Amazing Proxy Set Function - Need a Bit of Help: post #5 SmOke_N
It's not what you know ... It's what you can prove!


Moderators


16,247 posts
Posted 41 minutes ago
It's not a solution that's been found easily it seems around the net for that particular urlmon.dll function.  I haven't found anyone that has gotten it working as of yet with username/password.


Like This
Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Quote
MultiQuote
Report
#6  My Amazing Proxy Set Function - Need a Bit of Help: post #6 drego
Seeker


Active Members
35 posts
Posted A minute ago
SmOke_N, on 18 Jan 2015 - 10:47 PM, said:
It's not a solution that's been found easily it seems around the net for that particular urlmon.dll function.  I haven't found anyone that has gotten it working as of yet with username/password.


I just got it to work with TOR (Tor doesn't use username/password) using the exact function I posted. You said there was an error in my function? If something is wrong can you post the modified function?


About logins: Do you think it's possible that a new option needs to be set when calling the DLL?

EDIT:

drego "figured out" that his proxy was broke, and the function by Electon in >this post was the solution.

 

Here it is formatted.

Func _SetProxy($proxy, $proxybypass = "")
    Local $INTERNET_OPTION_PROXY = 38
    Local $INTERNET_OPEN_TYPE_PROXY = 3
    Local $tBuff = DllStructCreate("dword;ptr;ptr")
    DllStructSetData($tBuff, 1, $INTERNET_OPEN_TYPE_PROXY)
    Local $pproxy = DllStructCreate("char[" & (StringLen($proxy) + 1) & "]")
    DllStructSetData($pproxy, 1, $proxy)
    DllStructSetData($tBuff, 2, DllStructGetPtr($pproxy))
    Local $pproxybypass = DllStructCreate("char[" & (StringLen($proxybypass) + 1) & "]")
    DllStructSetData($pproxybypass, 1, $proxybypass)
    DllStructSetData($tBuff, 3, DllStructGetPtr($pproxybypass))
    $chk_UrlMkSetSessionOption = _
            DllCall("urlmon.dll", "long", "UrlMkSetSessionOption", _
            "dword", $INTERNET_OPTION_PROXY, _
            "ptr", DllStructGetPtr($tBuff), _
            "dword", DllStructGetSize($tBuff), _
            "dword", 0)
EndFunc   ;==>_SetProxy
Richard Robertson showed drego how to use it.

I'm not familiar with the code at all. I merely translated it from MSDN. I'll look around and see what I can find on SOCKS proxy.

Ok, pass the parameter like "socks=127.0.0.1:12345" And replace the IP and port with whatever you have.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Uhm... SmOke_N will back me up on this. From the moment I requested the thread be deleted I was in private communication with him on how to improve it and create a UDF. We've been going back and forth about it since yesterday. Here's the thread: '?do=embed' frameborder='0' data-embedContent>>

There's no need for this thread anymore because we were coming up with something better. If you read my UDF thread (which has user-agent switching as well) you'll see why.

lol way to jump to conclusions guys.

This thread can be removed as it is redundant.

Edited by drego
Link to comment
Share on other sites

  • Moderators

This issue has been addressed.  Multiple accounts is against the forum rules, no need to ask me anything, I agree that posts should not be removed, and you should not have multiple accounts.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...