Overkill
Active Members-
Posts
73 -
Joined
-
Last visited
About Overkill
- Birthday 01/11/1988
Profile Information
-
Location
USA
Overkill's Achievements
Wayfarer (2/7)
0
Reputation
-
Running back into this issue for a different script...same concept though. Anybody have input on this? Should I be looking at a full programming language that I can compile in instead?
- 3 replies
-
- best practice
- encryption
-
(and 3 more)
Tagged with:
-
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 ;----------------------------------------------------------------------------------------
- 3 replies
-
- best practice
- encryption
-
(and 3 more)
Tagged with:
-
Extended Message Box - New Version: 16 Feb 24
Overkill replied to Melba23's topic in AutoIt Example Scripts
Just tried this UDF - loving it! Quick question/possible bug though... I am a keyboard ninja and I hate mice. So, when I have a dialog pop up and I press tab + spacebar, it returns the default button (in this case, the "No" button) regardless of which one has been selected. When I do the same behavior with the enter key instead, it works fine. Any idea what's going on here? Thanks, Overkill -
At my work, most ports including the one used by the Internet Time sync are blocked by a firewall. Some systems (especially those with bad CMOS batteries) need to have the clock set before Windows Update works, so I wrote this for our software toolkit. Any changes, corrections, or criticisms welcome. I am always looking to improve my code! #RequireAdmin #include<Date.au3> ; For the ActiveTimeBias registry key: ; 4294967296 = 0 for UTC +X:YZ time zones; subtract value of key to get time zone offset. ; EG: 4294976296-4294976236 = 60 = UTC +1:00 ; ; UTC time zone uses 0 for the value ; ; UTC -A:BC time zones use the number of minutes of the offset ; EG: 480 = UTC -8:00 ; To-Do: ; 1. Add a timezone check to make sure the system is properly configured for its area ; EG: Time Zone is currently "Pacific Standard Time", is this correct? [Y/N] ; 2. Add error checking to _EndOfMonth() should the need arise [user editing of code] ; EG: -2 is not a valid month, you silly goose! ; ---------------------------------------------------------------------------------------------------------------------------------- ; Get time from HTTP server (Defaults to google.com ... pool.ntp.org is a good alternative) ; ---------------------------------------------------------------------------------------------------------------------------------- $site = "www.google.com" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://" & $site & "/", False) $oHTTP.Send() $date = $oHTTP.GetResponseHeader("Date") ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set Global variables used throughout the script ; ---------------------------------------------------------------------------------------------------------------------------------- ; $tzo: TimeZoneOffset (the number of hours by which the local machine varies from UTC) Global $tzo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation","ActiveTimeBias") Global $y = StringMid($date,13,4) ; The current year Global $m = StringMid($date,9,3) ; The current month Global $d = StringMid($date,6,2) ; The current day of month Global $h = StringMid($date,18,2) ; The current hour Global $n = StringMid($date,21,2) ; The current minute Global $s = StringMid($date,24,2) ; The current second IF $M = "JAN" THEN $M = 1 ; 31 days in month IF $M = "FEB" THEN $M = 2 ; 28/29 days in month IF $M = "MAR" THEN $M = 3 ; 31 days in month IF $M = "APR" THEN $M = 4 ; 30 days in month IF $M = "MAY" THEN $M = 5 ; 31 days in month IF $M = "JUN" THEN $M = 6 ; 30 days in month IF $M = "JUL" THEN $M = 7 ; 31 days in month IF $M = "AUG" THEN $M = 8 ; 31 days in month IF $M = "SEP" THEN $M = 9 ; 30 days in month IF $M = "OCT" THEN $M = 10 ; 31 days in month IF $M = "NOV" THEN $M = 11 ; 30 days in month IF $M = "DEC" THEN $M = 12 ; 31 days in month Global $epm = _EndOfMonth($M-1) ; The last day of the previous month (28-31) Global $ecm = _EndOfMonth($M) ; The last day of the current month (28-31) ; Correct value for $tzo from the registry value to a +/- number of hours IF $tzo < 1500 Then $tzo /= -60 Else $tzo = (4294967296 - $tzo)/60 EndIf ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Calculate time zone changes (correct the hour/day/month/year based on timezone/hour/day/month changes ; ---------------------------------------------------------------------------------------------------------------------------------- $h += $tzo ; Set the local hour based on offset from UTC Select ; If the hour changes day forward/backward, correct appropriate values. Case $h >= 24 $d += 1 $h -= 24 Case $h < 0 $d -= 1 $h += 24 EndSelect Switch $d ; If the day changes month forward/backward, correct appropriate values. Case $ecm+1 $m += 1 $d = 1 Case 0 $m -= 1 $d = $epm EndSwitch Switch $m ; If the month changes year forward/backward, correct appropriate values. Case 0 $m = 12 $d = 31 $y -= 1 Case 13 $m = 1 $d = 1 $y += 1 EndSwitch ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set system date/time using functions from #include<Date.au3> ; ---------------------------------------------------------------------------------------------------------------------------------- _SetDate($d,$m,$y) _SetTime($h,$n,$s) ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; FUNCTION: _EndOfMonth ::: Determine the ending date of the month (28, 29, 30, or 31) ; ---------------------------------------------------------------------------------------------------------------------------------- Func _EndOfMonth($vMON) local $end Switch $vMON Case 0, 1, 3, 5, 7, 8, 10, 12, 13 $end = 31 Case 4, 6, 9, 11 $end = 30 Case 2 If IsInt(@YEAR/4) Then $end = 29 Else $end = 28 EndIf Case Else SetError(-1) Return(0) EndSwitch Return($end) EndFunc ; ---------------------------------------------------------------------------------------------------------------------------------- ; ----------------------------------------------------------------------------------------------------------------------------------
-
We're trying to run our store's tech toolkit, written in autoit, on an XP machine and this error pops up when we try to run. Is there something like the VB runtime we need to install first (note: we tried VB and .NET first, no luck), but it seems like the computer isn't recognizing the commands being passed to it. This is the first time we've seen this in the 20 months I've been with the company. Thanks, Overkill
-
Getting latest software versions
Overkill replied to Overkill's topic in AutoIt General Help and Support
Thanks for all the help guys, I'll take a look into all this! -
Windows 7 "New" context menu
Overkill replied to Overkill's topic in AutoIt General Help and Support
I'm going to be using the Administrator account to do everything from now on because I'm sick of Windows trying to save me from myself...if only I could just stick "sudo" in front of everything... Anyway, I'll try doing that when I get around to logging back over to the other account so that people who search for this later will see some how to steps ^.^ -
I'm planning on writing a script that will check to see if my installer library of several dozen programs (I do a lot of installs for clients >.>) is up to date. I've been looking at using _IEBodyReadText and regular expressions to determine the latest version available, then comparing that against the current installer version. I'm sitting here thinking that this is way too complicated, and that there has to be an easier way to do it...but I can't find anything that fits. I figured I'd ask here and see if anybody had an idea or two that'd be helpful xD
-
I suspect that this has something to do with the way the installer is packaged, since "Run as Administrator" didn't help at all...but when I installed AutoIt on my machine the "New" > "AutoIt v3 Script" context menu item isn't there. I checked under HKCR/.au3/ShellNew and it's set up properly, but it won't show up even after a reboot. When I run the installer directly from the Administrator account, however, it shows up immediately following installation (but only for the Admin account!) I edited the "Classes" entry under the PostSetup key, but the changes will not stick even when run as admin. This is probably the source of the problem, but I can't find a way to fix this. Any ideas? -Overkill +EDIT 3/12 19:27 GMT Just tried running an AU3 script with #requireadmin to change the value, still won't stay changed (it shows, then disappears) Also, I can't see the MRU values for the Run dialog...may be something bigger at play here.
-
We sell a lot of floor models this time of year and I'd much prefer to have a script set up that we can remove quickly and easily when needed without making any software changes to the computer so that if the customer doesn't want to wait to for the computer to be re-imaged we can get them out the door in a timely manner. I appreciate your alternative ideas but there is a method to my madness, and at this point I'd like to focus on the question asked instead of different theories.
-
1) CTRL+SHIFT+ESC is the hotkey combo for taskmgr in Windows ME II (Vista) and Windows 7. 2) I suppose in the stop function you could have a password window pop up instead of exiting the script, but I'd really just like to have this installed as a service that restarts itself when the script is closed like many AV programs, netlimiter, and others do. As for DeepFreeze/HDGuard - retail store = corporate licensing = costs money = declined. This script is officially unsanctioned by the management (though unofficially they like the idea), so they're going to be "unaware" of my actions and will "take appropriate action" if something goes wrong. We're not even allowed to use our own toolkits on virus removals when the provided AV software fails, so something like this is of course very much a violation of policy.
-
The short version is that we may need access to all of that stuff at the drop of a hat, and rather than go through something complicated I can enter a password into the admin login for my script and it will give me or another associate control of whatever is needed. The svchost.exe idea is something that I've used in the past but this needs to be a little smarter than that since Win7 has the "full path" option in the task manager. Running it as a service may be the best way to do this but I don't have the experience/knowledge needed to do this quickly and efficiently.
-
System/global variable??
Overkill replied to Allochthonous's topic in AutoIt General Help and Support
You rang? Use the RegRead/RegDelete commands to check for and delete entries in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU The key names used are MRUList and the letters a through z. -
I work as a tech/salesperson for a retail outlet and one of our biggest problems is kids messing with our floor models (adding passwords, changing homepage, etc) and I'm writing a script that will stop all that once and for all. The question I have for you guys is what's the most effective way to prevent the script from being closed via the task manager? Would it be to write a second script and have each script ProcessExists($otherscript), or is there a more elaborate way that would take more than fast fingers to get around?
-
Remove button border (and a few other things)
Overkill replied to Overkill's topic in AutoIt GUI Help and Support
Worked perfectly! Thanks =) Getting the last kinks worked out of my first 'major' script...this was bugging me for a while lol.