Jump to content

Morthawt

Active Members
  • Posts

    680
  • Joined

  • Last visited

  • Days Won

    5

Morthawt last won the day on September 27 2017

Morthawt had the most liked content!

2 Followers

About Morthawt

  • Birthday 04/12/1984

Profile Information

  • Member Title
    aka TutsTeach
  • Location
    UK
  • WWW
    http://www.morthawt.com
  • Interests
    Neuro-Linguistic Programming (NLP), AutoIt coding, Computers, Thinking...

Recent Profile Visitors

2,182 profile views

Morthawt's Achievements

  1. Edit (I'd delete but I don't think I can) I think I figured it out. The documentation was a bit spread out but I think I have it figured out. Just not sure about the text alignment thing. Hi. Just experimenting on a little program I am re-making. I have not dealt much with status bars. But I see a minor mention of simple mode but I see no documentation, that I have found any way, to say what it is? I had to do a consolewrite and add the constants include to even find out what number the supplied variable went to (I figured they'd always supply the number as well as the variable, but that's besides the point here lol) What is a simple mode status bar? How come there's no simple mode for the create function but there is for the SetText function for it? I am just a bit confused. I eventually managed to get it to where I can set text which is good for what I need but I would like to know what simple mode is? Also a bonus question, is it possible to align the text like centre, right etc on a status bar?
  2. I have a friend learning Python and he asked me if AutoIt has Associative Arrays (Dictionaries) and if I could write something in AutoIt to help him. Firstly, I never even heard of that kind of array and I found some reference from a couple years or so ago saying it was in the beta. Is that still in the pipeline to come into the final release of AutoIt?
  3. My snippit for the modern Yubikeys (where you have USB Descriptor option enabled on it, via the personalisation tool settings screen) This simply waits until it detects that you inserted your Yubikey and then when you remove it, it locks the PC. But you could use it for all kinds of things, make the PC shutdown, sound an alarm, who knows. Just a cool little thing I threw together. I do not know, really, about "Objects" and dealing with the indepth Microsoft device info but I was able to tweak a basic "here's a list of all USB devices" I found, into something that can detect the presence of the Yubikey. I also have an alternative to USB\\ which will look for smartcards but I stopped using that and reverted back to USB since I am not entirely sure if the numbers represented on there are unique, at least the USB one I can clearly see it has the serial number on my Yubikey. AutoItSetOption('TrayAutoPause', 0) Global $Status, $InitialLaunch = True While 1 $checking = CheckForYubikeyExistence() Switch $checking Case True ;;;;;;;; Area to run commands after the Yubikey is inserted BELOW ConsoleWrite('DETECTED!' & @LF) ;;;;;;;; Area to run commands after the Yubikey is inserted ABOVE While 1 If CheckForYubikeyExistence() = False Then ExitLoop Sleep(100) WEnd Case False If $InitialLaunch = True Then ; Treat it as ready but actually nothing will happen until the Yubikey is inserted and then removed... ConsoleWrite('Launching and waiting for Yubikey insertion...' & @LF) While 1 ; This waits until the Yubikey is plugged in the first time, to initiate the protection readiness or at least, the forthcoming detection of Yubikey removal. If CheckForYubikeyExistence() = True Then $InitialLaunch = False ContinueCase EndIf Sleep(100) WEnd EndIf ;;;;;;;; Area to run commands after the Yubikey is pulled out BELOW ConsoleWrite('WARNING, YUBIKEY NOT PRESENT!!' & @LF) Run('rundll32.exe user32.dll,LockWorkStation') ;;;;;;;; Area to run commands after the Yubikey is pulled out ABOVE While 1 ; This waits until the Yubikey is inserted again before doing anything next. If CheckForYubikeyExistence() = True Then ExitLoop Sleep(100) WEnd EndSwitch WEnd Func CheckForYubikeyExistence($_list_all = False) ; Calling this with a True parameter puts it into debugging mode, to list all the user input or smart card devices depending on what type of devices it is looking for. $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity where DeviceID like 'USB\\%'") ; SCFILTER\\% for smartcards and USB\\% for all USB devices If IsObj($colItems) Then For $objItem In $colItems If $_list_all = True Then ConsoleWrite($objItem.DeviceID & @LF) ; Show all the ID's of all smartcards, so you know which ones are allowed (only plug in ones you want to allow when listing them all) Switch $objItem.DeviceID Case 'USB\VID_1050&PID_0407\0006297461' ; An allowed Yubikey device ID (Your Yubikey needs enabling, on the Settings section of the YK personalisation tool, the "USB Descriptor" option. Else it won't show up. $InitialLaunch = False SetError(0) Return True Case 'USB\VID_1050&PID_0116\0005286976' ; An allowed Yubikey device ID two $InitialLaunch = False SetError(0) Return True EndSwitch Next SetError(1) Return False ;Nothing by now was detected as being an authorised Yubikey. EndIf EndFunc ;==>CheckForYubikeyExistence
  4. When you are encrypting data, I am used to setting the algorithm. But I saw $CALG_USERKEY in the documentation but I have no context as to what algorithm that is. The documentation says it is value 0. I would appreciate a heads up on what $CALG_USERKEY is for? Thanks.
  5. I have been trying to send text to "controls" which I left the last clicked thing on the window but all attempts to controlsend to the window are failing. Controlclicks are not working. I cannot seemingly set text, interact with anything on the window even with specific window-based coordinates using controlclicks?
  6. I finally got around to making a new tutorial on ini files https://www.youtube.com/watch?v=0_cPWYQ6iIs&index=20&list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z I had several requests to do the video on the additional way to pull multiple unknown things from ini files, so I have now done the video.
  7. I'd rather stick with the 3 gram practically bomb proof sealed black-box design of the Yubikey which is designed in all aspects to keep the encryption private keys stuck inside never to be released.
  8. I don't think you understand what a Yubikey is. It is not just something that spits out a password or something. It is capable of doing that as one of it's features, but it is a cutting edge cryptographic security token. It has U2F (universal 2-factor authentication), various OTP (one-time password) capabilities, OpenPGP key based operations like decryption and signing from within the unit, smartcard operations like digital signature authentication, physical access, etc etc. You can also set in the modern ones the QR codes to your 2-factor using services so that rather than have an app on your computer or phone with all the private data, your private data is in the Yubikey and the resulting one-time codes are accessible at the time they are needed with the private keys never leaving the device.
  9. It has been some years since this was posted. I had made my own just now and I thought I would share it here than make a whole new thread: #include <Crypt.au3> Global $otp, $APIid = 00000000, $error, $CustSalt = '7F34E3F39F7967B38A9CEB3C3EE55F17BF9552F8F7A5B74', $AuthorisedHashedPubID = '0x6F25B171D3563C000F75455EAFFA1AA967EAB605' ; Get your API ID ($APIid) by registering for an API key: https://upgrade.yubico.com/getapikey/ ; Use your own custom salt value above so that all the hashes will be entirely unique to your implementation. $otp = InputBox('Yubikey OTP Request', 'Press the OTP Button on your Yubikey', Default, '*') ; Obtain the OTP from the user, by them pressing the button on their Yubikey that is inserted. $nousedonce = StringTrimLeft(HashThis(StringReplace(Random(), '.', '') & @MSEC & StringReplace(Random(), '.', '') & StringReplace(Random(), '.', '') & @SEC & @MSEC), 2) ; This is the "number, used once" which actually is random data, not a number. ;;;;; Prep area, uncomment to generate a working hash to check the person's Yubikey "Public Identity" prefix to generate a salted hash you can check in the future to authenticate their Yubikey ;~ ClipPut(HashThis('ccccccjlgpht')) ; Paste the first 12 characters of a genuine Yubikey OTR that you wish to authorise to access this program and copy the resulting salted hash ;~ Exit ;;;;; $url = 'https://api.yubico.com/wsapi/2.0/verify?otp=' & $otp & '&id=' & $APIid & '&nonce=' & $nousedonce & '&timestamp=1' ; Constructing the URL needed to check with the remote server about a Yubikey's OTP output. $results = InetRead($url, 1) ; Sending the request to the API server. If Not @error Then $results = BinaryToString($results) $split = StringSplit($results, @CRLF, 3) ; Breaking the resulting feedback from the API server up into lines (array rows) so parameters can be ensured they start from the beginning of each line. If StringInStr($results, 'otp=' & $otp) And StringInStr($results, 'nonce=' & $nousedonce) And StringInStr($results, 'status=OK') Then ; If OTP and nonce that were sent to server are the same ones returned & status is OK, continue validation. For $a In $split If StringInStr($a, 'otp=', 1) Then ; If this row of the array contains the otp parameter (it starts at the beginning of the string) then... $a = StringReplace($a, 'otp=', '') ; Strip away the parameter prefix of "otp=" If HashThis(StringMid($a, 1, 12)) = $AuthorisedHashedPubID Then ; If the newly salted & hashed Yubikey's Public ID matches the existing salted hash of the authorised user, then do the immediately following thing... MsgBox(0, 'SUCCESS', 'Successfully authenticated the authorised user''s Yubikey') Else ; If we got here, the OTP that was generated was valid but the particular Yubikey was not one authorised for use with this program, so instead, do the following thing. MsgBox(0, 'Error', 'While the Yubico OTP was validated as genuine,' & @CRLF & 'this Yubikey is not authorised for access.') EndIf EndIf Next ElseIf Not StringInStr($results, 'status=OK') Then ; If the status is anything other than "OK" there is a problem with the OTP that was generated, perhaps it was an old used one? etc. For $a In $split If StringInStr($a, 'status=', 1) Then $error = StringReplace($a, 'status=', '') ; set the error code supplied by the API server in the $error variable. Next MsgBox(0, 'Error', 'Yubico authentication error: ' & $error) ; Display the error to the user. EndIf Else MsgBox(0, 'Error', 'Error accessing Yubico API address.') ; There was a problem accessing the API server, perhaps an internet problem or SSL problem. EndIf Func HashThis($_input) ; Simply does the salted hashing and provides the result $_hash = StringTrimLeft(_Crypt_HashData($CustSalt & $_input, $CALG_SHA1), 0) Return $_hash EndFunc ;==>HashThis My goal was to not have the required public ID stored in the source of the program, yet be able to check when it is the correct one.
  10. Well it was providing the serial number as part of what ever it was. But now it no longer works for the new Yubikeys. I would need to know the new device type and possibly a different thing that contains the serial number in it to check. Here is what the preferences of the Yubikey personalisation tool says:
  11. Someone here gave me some help in order to detect if my Yubikey is inserted or not, by checking the Windows system for all "keyboard" devices for the presence of the serial number of my Yubikey. Then once unplugged and found to be missing, take some action like lock the PC. The problem is it does not work with the newer Yubikeys because, I think, they act as smartcards or something. So the code looking for a keyboard is no good. There was some kind of tool which I used to help me find what to search for I think, I do not remember. Here is the function which did the original checking, but I am totally clueless on how to tweak it to again be able to find the serial number of my new (no longer acting as a keyboard) Yubikey. Func CheckForYubikey($input) $Output = "" $object = ObjGet("winmgmts:\\" & $strComputer & "\ROOT\CIMV2") $items = $object.ExecQuery("SELECT DeviceID FROM Win32_Keyboard", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($items) Then For $objItem In $items FileWriteLine('test.txt', $objItem.DeviceID) If StringInStr($objItem.DeviceID, $YubikeySerialNumber) Then Return True Next Else Return False EndIf Return False EndFunc ;==>CheckForYubikey Any help would be appreciated.
  12. You're welcome. Glad there are people out there finding this capability as useful as I have over the years. It has really helped me when API's are not available and pages need breaking down, as well as API's where JSON information needs breaking down so I can get a particular parameter's data from it. I've used it for getting bitcoin exchange rates, finding new products on websites, seeing a new entry in a top40 charts, seeing when show notes for a new podcast are added to a site, see when the price of a product online goes down and alert me about the lower price, alert me to new threads in a "need help" section of my phone carrier's website. Just endless use I have gotten out of my original Chunk. This new ChunkV2 is so much nicer. If the site gets updated and your chunk zones no longer work, all you need to do is just make new chunk zones that will re-acquire the chunks you need and the rest of your code should be fine still.
  13. I have updated and added a new option 32. I was having problems with some product pages that the site owner would comment out, modularly, products for which are no longer sold or are entirely out of stock. So me trying to make a program to scan for new products was causing all kinds of problems by showing tons of items that appear in the source code, all formatted nicely but in fact aren't actually "there", so if he uncommented those products I would not get notified because ChunkV2 had technically seen the items listed in the page's sourcecode. I had to google for the regex string and add a !? on the end because the guy's site I am interacting with finished some comments with --!> and sometimes --> By the way, here is a real-world example of using ChunkV2 #include <includes\ChunkV2.au3> #include <Array.au3> AutoItSetOption('TrayAutoPause', 0) Global $Zones[4][2], $Zones2[2][2], $PreviouslySeen[0], $url = "https://www.heinnie.com/all-products" $PreviouslySeen = FileReadToArray('productlist.txt') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Zones[0][0] = '<ul id="productlist"' $Zones[0][1] = '</ul>' $Zones[1][0] = '<li class="item">' $Zones[1][1] = '</li>' $Zones[2][0] = '<h2 class="product-name">' $Zones[2][1] = '</h2>' $Zones[3][0] = '" title="' $Zones[3][1] = '">' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Zones2[0][0] = '<ul id="productlist"' $Zones2[0][1] = '</ul>' $Zones2[1][0] = '<li class="item">' $Zones2[1][1] = '</li>' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 $source = _INetGetSource($url, False) $Results = ChunkV2($source, $Zones) ; Returns raw product names $Results2 = ChunkV2($source, $Zones2) ; Returns the entire block of code for each product, so the count will be the same as the product names above. (no subscript errors) Local $new = False For $a = 0 To UBound($Results) - 1 $product = ((StringInStr($Results2[$a], '<div class="ukfriendlycarry">')) ? ('(UK Legal)' & @TAB) : (@TAB & @TAB & @TAB)) & $Results[$a] $test = _ArraySearch($PreviouslySeen, $product) If $test < 0 Then $new = True ConsoleWrite($product & @LF) FileWriteLine('productlist.txt', $product) If Not IsArray($PreviouslySeen) Then Global $PreviouslySeen[0] ReDim $PreviouslySeen[UBound($PreviouslySeen) + 1] $PreviouslySeen[UBound($PreviouslySeen) - 1] = $product EndIf Next If $new Then Beep(500, 1000) Sleep(300000) WEnd
  14. Updated: I have simplified the user's options/flags using BitAND rather than arithmetically processing them to whittle them down. I have tested it and it appears to be working well. Maybe it will slightly increase the speed at which it operates but it has certainly dropped the line count.
×
×
  • Create New...