Sign in to follow this  
Followers 0
drego

My Amazing Proxy Set Function - Need a Bit of Help

15 posts in this topic

#1 ·  Posted (edited)

This problem has been figured out. Was very easy and no need for this thread anymore.

Edited by drego

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

This problem has been figured out. Was very easy and no need for this thread anymore.

Edited by drego

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This problem has been figured out. Was very easy and no need for this thread anymore.

Edited by drego

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This problem has been figured out. Was very easy and no need for this thread anymore.

Edited by drego

Share this post


Link to post
Share on other sites

Still others may would have benefited from this thread, dont just edit out the questions, and your progress when you find your solution, noone else can use it then.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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
2 people like this

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

And BTW I am Electron. ~YOUR MIND BLOWN~

Edited by drego

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • Overkill
      By Overkill
      Hi all,
      I am working on a GUI program to update Google's Dynamic DNS (API at https://support.google.com/domains/answer/6147083?authuser=1&hl=en if you scroll to bottom). I am not a programmer by any means - just a sysadmin who has picked up on some things along the way. I am sure that there's better ways to do a lot of things in this script; I'm just going with what I know.
      My challenge right now is that I'd like a better way to store the credentials both in memory as well as in system registry or INI file (not sure which way I want to go for local storage). How should I convert the passwords to a secure string in a manner that can't be easily reversed, yet is still accessible to the script? Is that even an option in AutoIt?
      Can anybody provide me with links to good reference posts, or coding suggestions for how best to achieve this in the script below? I am using the WinHTTP UDF (https://github.com/dragana-r/autoit-winhttp/releases) to make my API calls.
      #include<WinHTTP.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<iNet.au3> #include<Array.au3> DIM $aDomainList[1][4] $aDomainList[0][0] = 0 $gMainGUI = GUICreate("Overkill's Google DNS Updater",800,800) $gDomainLabel = GUICtrlCreateLabel("FQDN",21,8) $gDomainInput = GUICtrlCreateInput("",60,5,300) $gUserLabel = GUICtrlCreateLabel("Username",5,36) $gUserInput = GUICtrlCreateInput("",60,32,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gPasswordLabel = GUICtrlCreateLabel("Password",6,64) $gPassInput = GUICtrlCreateInput("",60,60,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gAddButton = GUICtrlCreateButton("ADD DOMAIN",200,31,160,52) $gCurrentIP = GUICtrlCreateLabel("Current IP: " & _CheckIP(),5,780) $gDomainList = GUICtrlCreateListView("Domain | Resolved IP | Update Status",5,120,600,600) GUISetState(@SW_SHOW,$gMainGUI) while 1 $m = GUIGetMsg() IF $M = $GUI_EVENT_CLOSE then Exit IF $M = $gAddButton Then $sAddDomain = GUICtrlRead($gDomainInput) $sAddUser = GUICtrlRead($gUserInput) $sAddPass = GUICtrlRead($gPassInput) $sResolveIP = _DNSCheck($sAddDomain) ;Google wants you to avoid sending updates when there are no changes If StringCompare($sResolveIP,_CheckIP()) = 0 Then $sStatus = "No change, not sending update" Else $sStatus = _DNSUpdate($sAddDomain,$sAddUser,$sAddPass) EndIf ;Check to make sure all fields are completed before continuing IF StringLen($sAddDomain) = 0 OR StringLen($sAddUser) = 0 OR StringLen($sAddPass) = 0 Then MsgBox(0,"","Please complete all fields") Else ; If the fields all have data, then continue ;Check to see if the entry exists in the array already $iSanity = _ArraySearch($aDomainList,$sAddDomain) IF $iSanity = 0 Then _ArrayAdd($aDomainList,$sAddDomain & "|" & $sAddUser & "|" & $sAddPass ) If @error = 0 Then $aDomainList[0][0] += 1 $aDomainList[$aDomainList[0][0]][3] = GUICtrlCreateListViewItem($sAddDomain & "|" & $sResolveIP & "|" & $sStatus,$gDomainList) Else MsgBox(0,"","Error adding input to list") EndIf Else ; If $iSanity <> 0 ; Update existing info in array and listviewitem $aDomainList[$iSanity][0] = $sAddDomain $aDomainList[$iSanity][1] = $sAddUser $aDomainList[$iSanity][2] = $sAddPass GUICtrlSetData($aDomainList[$iSanity][3],$sAddDomain & "|" & $sResolveIP & "|" & $sStatus) EndIf ; If $iSanity = 0 EndIf ; If StringLen... EndIf ; If $m = $gaddbutton WEnd ;---------------------------------------------------------------------------------------- Func _DNSCheck($sFQDN) $sJSON = _INetGetSource("https://dns.google.com/resolve?name=" & $sFQDN & "&cd=1") ConsoleWrite($sJSON & @CRLF) $sIPAddress = StringRegExpReplace($sJSON,'^.*data": "(.*?)".*?$',"\1") Return $sIPAddress EndFunc ;---------------------------------------------------------------------------------------- Func _DNSUpdate($sFQDN,$sUser,$sPass) Local $sGoogleAPIURI = "https://domains.google.com" Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $sGoogleAPIURI) Local $sHeader = _ 'Authorization: Basic ' & _Base64Encode($sUser & ":" & $sPass) & @CRLF & _ 'Accept: */*' & @CRLF & _ 'User-Agent: AutoITScript/' & @AutoItVersion & @CRLF & _ 'Content-Type: application/x-www-form-urlencoded' Local $aHTTPResponse = _WinHttpSimpleSSLRequest($hConnect, "POST", "/nic/update", Default, "hostname=" & $sFQDN, $sHeader, True, Default, Default, Default, True) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If IsArray($aHTTPResponse) Then $sHTTPResponse = "Header:" & @CRLF & $aHTTPResponse[0] & @CRLF & "Data:" & @CRLF & $aHTTPResponse[1] & @CRLF & @CRLF & @CRLF Return $aHTTPResponse[1] Else $sHTTPResponse = "NO REPLY" Return "No reply from " & $sGoogleAPIURI EndIf EndFunc ;---------------------------------------------------------------------------------------- Func _Base64Encode($sData) Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;---------------------------------------------------------------------------------------- Func _CheckIP() Return _INetGetSource("https://domains.google.com/checkip") EndFunc ;----------------------------------------------------------------------------------------  
    • ripdad
      By ripdad
      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
       
    • Simpel
      By Simpel
      Hi,
      after I recognized that some of my scripts fail if they are at windows startup I researched for a solution. Problem could be fixed if I wait about 120 seconds after login. So how to measure this?
      #include-once #include <AD.au3> #include <Date.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SecondsAfterLogin ; Description ...: Returns how many seconds are gone since last login ; Syntax ........: _SecondsAfterLogin() ; Parameters ....: None ; Return values .: Success - Integer of seconds ; Failure - 0, sets @error to 1 ; Author ........: Conrad Zelck ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _SecondsAfterLogin() Local $sDate Local $iSec $sDate = __GetLogonTime() ; UTC If @error Then $sDate = __GetLogonTime_AD() ; local time If @error Then Return SetError(1, 0, 0) Else $sDate = __LocalTime($sDate) ; UTC to local time EndIf $iSec = __TimeDifference($sDate) Return $iSec EndFunc #region - INTERNAL_USE_ONLY Func __GetLogonTime($sUserName = @UserName, $sComputerName = @ComputerName) ; Idea by trancexx: http://www.autoitscript.com/forum/topic/113611-if-isadmin-not-detected-as-admin/ Local $aRet = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sComputerName, "wstr", $sUserName, "dword", 11, "ptr*", 0) If @error Or $aRet[0] Then Return SetError(1, 0, 0) Local $sSeconds = DllStructGetData(DllStructCreate("ptr;ptr;ptr;ptr;dword;dword;dword;ptr;ptr;dword;dword;dword;dword;ptr;dword;ptr;dword;dword;byte;dword", $aRet[4]), 10) DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aRet[4]) Local $sLastLogon = _DateAdd('s', Number($sSeconds), "1970/01/01 00:00:00") Return $sLastLogon EndFunc Func __GetLogonTime_AD() Local $iSuccess = _AD_Open() If $iSuccess = 1 Then Local $sDate = _AD_GetLastLoginDate() $sDate = __NumberDate_StringDate($sDate) _AD_Close() Return $sDate Else Return SetError(1, 0, 0) EndIf EndFunc Func __NumberDate_StringDate($sDate) Local $y, $m, $d, $h, $min, $s $y = StringMid($sDate,1, 4) $m = StringMid($sDate,5, 2) $d = StringMid($sDate,7, 2) $h = StringMid($sDate,9, 2) $min = StringMid($sDate,11, 2) $s = StringMid($sDate,13, 2) $sDate = $y & "/" & $m & "/" & $d & " " & $h & ":" & $min & ":" & $s Return $sDate EndFunc Func __LocalTime($sDate) Local $iTimeZoneOffset Local $aTimeZone = _Date_Time_GetTimeZoneInformation() If $aTimeZone[0] <> 2 Then $iTimeZoneOffset = ($aTimeZone[1]) * -1 Else $iTimeZoneOffset = ($aTimeZone[1] + $aTimeZone[7]) * -1 EndIf $iTimeZoneOffset /= 60 ; in hours Local $sHour = StringMid($sDate, 12, 2) $sHour += $iTimeZoneOffset $sDate = StringLeft($sDate, 11) & $sHour & StringRight($sDate, 6) Return $sDate EndFunc Func __TimeDifference($sDate) Local $sNow = _NowCalc() Local $sDiff = _DateDiff("s", $sDate, $sNow) Local $iDiff = Number($sDiff) Return $iDiff EndFunc #endregion - INTERNAL_USE_ONLY I had to look what kind of login it is. Some of my computers are logging in with active directory and other not.
      Here is an example:
      #include <SecondsAfterLogin.au3> Local $iSec = _SecondsAfterLogin() MsgBox(0, '', "Time since last login: " & _HHMMSS($iSec, "s")) Exit Func _HHMMSS($iTime, $sType = "ms") If $sType = "s" Then Local $sHHMMSS = StringFormat("%.2d:%.2d:%.2d", (Floor($iTime / 3600)), (Floor(Mod($iTime,3600) / 60)), (Mod(Mod($iTime,3600),60))) Else Local $sHHMMSS = StringFormat("%.2d:%.2d:%.2d", (Floor($iTime / 3600000)), (Floor(Mod($iTime,3600000) / 60000)), (Mod(Mod($iTime,3600000),60000) / 1000)) EndIf Return $sHHMMSS EndFunc I hope someone find it useful.
      Regards, Conrad
      P.S. Review is welcome.
    • VIP
      By VIP
      I can not do anything with any user in the "Local Users Group"
      I tried from my account but I could not change my password (ie set new password)!
      But I was able to activate the Administrator account and I logged into the Administrator account and still could not do anything with my account! But I can set the password and disable the Administrator account from my account or Administrator.
      Any ideas? (Ignore the click on the Sign-in option in the Change Accout settings.)
       

    • kawliga751
      By kawliga751
      I am trying to script the opening of multiple tabs in IE with each tab having a separate login/password. I have been able to make a successful script that will open 3 separate IE sessions with the correct webpage and login or a script that will open 3 tabs in one session (which I want) but will not login. I have tried _IECreate, IEAttach etc. This is the script I am currently using . 
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/AAAA/index.htm') ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) Call ("YYYYYYYSignIn") Func YYYYYYYSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/xxxxxxx/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc Call ("xxxxxxxSignIn") Func xxxxxxxSignIn () __IENavigate($oIE, "https://soa1gui.xxxxxxx.biz/gateway/NFServlet;jsessionid=1E3B8F6520DE0A1EC914A8ABB7E86341?NFH_MessageId=&NFH_Page=%2fpages%2fsearch%2fsearch.jsp", 1, 0x800) Local $domain = _IEGetObjByName ($oIE,"NF_CustomerID") Local $User_Name = _IEGetObjByName ($oIE,"NF_UserName") Local $Password = _IEGetObjByName ($oIE,"NF_Password") _IEFormElementSetValue ($domain, xxxxxxx") _IEFormElementSetValue ($User_Name, "xxxxxxx") _IEFormElementSetValue ($Password, "xxxxxxx") ;Send('{Enter}') EndFunc