Jump to content

Recommended Posts

Posted

I really like to use the Opera Wand for filling in forms buying stuff online. I was kind of disappointed that after all this time they still leave the [Personal Info] section in opera6.ini (that contains the stuff you typed into Wand) in clear text!!

I wasn't able to find any free substitute so I scripted a kludge that at least lets you have your opera6.ini [Personal Info] section encrypted when Opera isn't running.

The idea is to fill in the Wand info and close opera so that opera6.ini has the info stored in the clear. Set the variables in EncryptWand and RunOperaWand scripts so that they match. Run EncryptWand to encrypt the .ini file section. Now RunOperaWand can be used whenever you want to launch Opera and use the Wand Form Fill Tool. RunOperaWand

reads the encrypted section, decrypts it and writes it back. Then it launches Opera and waits. On Opera close it encrypts the [Personal Info] section again. All done using _StringEncrypt() IniReadSection() and IniWriteSection().

Like I said, a kludge. :)

EncryptWand

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         MilesAhead

 EncryptWand - Encrypts the [Personal Info] section of opera6.ini 
 
 1)Run Opera and fill in the Wand Personal Info then close Opera
 2)point the $operaIniFileName variable to point to the opera6.ini 
   with the information you just filled in. Change "PassWord" below
   to what you want to use as your password.
 3)Run the script
 
 Now you can use the RunOperaWand.au3 script to run Opera after setting
its variables to match those in this script. 
 
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <File.au3>
#include <String.au3>

;set this to point to Opera .ini file
$operaIniFileName="C:\Program Files\Opera926\profile\opera6.ini"
_Set_Wand_Info(1,$operaIniFileName,"PassWord")

Func _Set_Wand_Info($encrypt,$operaIniFile,$passWord)
$s=""
Dim $sectionInfo = IniReadSection($operaIniFile,"Personal Info")
For $i = 1 to $sectionInfo[0][0] 
    $s = _StringEncrypt($encrypt,$sectionInfo[$i][1],$passWord)
    $sectionInfo[$i][1] = $s
Next
IniWriteSection($operaIniFileName,"Personal Info",$sectionInfo)
EndFunc

RunOperaWand

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         MilesAhead

 RunOperaWand: RunOperaWand reads the opera6.ini file [Personal Info] section
 that was encrypted with EncryptWand.au3 script.  It decrypts it, and writes
 it back to opera6.ini.  It then runs Opera so you can use the Wand Form Fill
 Tool.  Once you exit Opera, it reencrypts the [Personal Info] section so 
 that your Personal Info isn't just sitting on disk in opera6.ini in clear
 text.
    
1)Set the variables $operaIniFileName to point to the opera6.ini file Opera
is using.  

2)Set $operaExeName variable to point to the corresponding opera.exe 
3)Set $pw to the password you used in EncryptWand.au3 script.
4)Run this script to execute Opera.

Suggestion:  Use AutoIt3 "Compile Script" once you have set and tested all
your variables to compile this script to an .exe file.
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <File.au3>
#include <String.au3>

$operaIniFileName="C:\Program Files\Opera926\profile\opera6.ini"
$operaExeFileName="C:\Program Files\Opera926\opera.exe"
$pw="PassWord"
If Not _Set_Wand_Info(0,$operaIniFileName,$pw) Then
    MsgBox(0,"RunOperaWand","Decrypting Opera Ini File Failed")
    Exit
EndIf
$val = ShellExecuteWait($operaExeFileName)
If Not _Set_Wand_Info(1,$operaIniFileName,$pw) Then
    MsgBox(0,"RunOperaWand","Encrypting Opera Ini File Failed")
EndIf

Func _Set_Wand_Info($encrypt,$operaIniFile,$passWord)
$s=""
Dim $sectionInfo = IniReadSection($operaIniFile,"Personal Info")
For $i = 1 to $sectionInfo[0][0] 
    $s = _StringEncrypt($encrypt,$sectionInfo[$i][1],$passWord)
    $sectionInfo[$i][1] = $s
Next
return IniWriteSection($operaIniFileName,"Personal Info",$sectionInfo)
EndFunc
Posted (edited)

I broke the .ini file section encryption bit out into something more generally useful: _CryptIniSection()

#include-once
#include <File.au3>
#include <String.au3>

#cs ----------------------------------------------------------------------------
    Function:
    _CryptIniSection($encrypt,$iniFile,$sectionName,$passWord,$testKey="",$testVal="")
    
    Author: MilesAhead
    
    Action:
    Uses _StringEncrypt to encrypt or decrypt a section of an .ini file
    
    Params:
    $encrypt: 0 for decrypt non-zero for encrypt
    $iniFile: .ini file name
    $sectionName: name of .ini file Section
    $passWord: password used with _StringEncrypt
    $testKey: key to detect if already encrypted : optional
    $testVal: val to detect if already encrypted : optional
    
    Returns:
    True if Section is already in desired state of encryption
    False on error
    otherwise returns the result of IniWriteSection
    
#ce ----------------------------------------------------------------------------


Func _CryptIniSection($encrypt, $iniFile, $sectionName, $passWord, $testKey = "", $testVal = "")
    Local $s = ""
    Local $sectionInfo = IniReadSection($iniFile, $sectionName)
    If @error Then Return False
    If $testKey <> "" And $testVal <> "" Then
        Select
            Case $encrypt = 0
                If _IsIniSectionUnencrypted($sectionInfo, $testKey, $testVal) Then
                    Return True
                EndIf
            Case Else
                $encrypt = 1
                If Not _IsIniSectionUnencrypted($sectionInfo, $testKey, $testVal) Then
                    Return True
                EndIf
        EndSelect
    EndIf
    For $i = 1 To $sectionInfo[0][0]
        $s = _StringEncrypt($encrypt, $sectionInfo[$i][1], $passWord)
        If @error Then Return False
        $sectionInfo[$i][1] = $s
    Next
    Return IniWriteSection($iniFile, $sectionName, $sectionInfo)
EndFunc  ;==>_CryptIniSection

#cs ----------------------------------------------------------------------------
    Function:
    _IsIniSectionUnencrypted($sectionArray,$key,$val)
    
    Author:
    MilesAhead
    
    Action:
    Scans a two-dimensional array that was filled with IniReadSection
    for a key matching $key with a value matching $val.  The assumption
    being if "in the clear" key and value match those expected then the
    .ini file Section is not encrypted
    
    Params:
    $sectionArray: 2 dimensional array filled by IniReadSection
    $key: the key to search for
    $val: the value to match
    
    Returns:
    True if a match is found
    False otherwise
#ce ----------------------------------------------------------------------------

Func _IsIniSectionUnencrypted($sectionArray, $key, $val)
    For $x = 1 To $sectionArray[0][0]
        If $sectionArray[$x][0] == $key And $sectionArray[$x][1] == $val Then
            Return True
        EndIf
    Next
    Return False
EndFunc  ;==>_IsIniSectionUnencrypted
Edited by MilesAhead
Posted

Hi,

Nice idea.

For the "files path get" part you can use Opera Library. Like this:

#include-once
#include <File.au3>
#include <String.au3>
#include "Opera_Library.au3"

....

$Opera6Ini_Path = _OperaGetProfileDir() & "\opera6.ini"
$OperaExe_Path = _OperaGetDir() & "\opera.exe"

....

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 8 years later...
Posted
  On 3/14/2008 at 3:35 PM, MrCreatoR said:

Hi,

 

Nice idea.

 

For the "files path get" part you can use Opera Library. Like this:

 

 

#include-once
#include <File.au3>
#include <String.au3>
#include "Opera_Library.au3"

....

$Opera6Ini_Path = _OperaGetProfileDir() & "\opera6.ini"
$OperaExe_Path = _OperaGetDir() & "\opera.exe"

....
Expand  

Hi @milesahead can you please share opera_library.au3 . I am automating opera in autoit this will be great help :) Thanks in Advance

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...