Have fun with it

Code: Select all
;Code for erasing IE form data (aka AutoComplete) and the passwords
;Tested with IE 5.5 and 7.0, 32 bit XP, ASCII, PB 4.40 B5
;Created by Alexandru Trutia, www.bytessence.com
;Credits appreciated (but it's not a must)
;Would be good to add some error checking as this is just
;proof-of-concept code
;Contributors:
;Inspired by sec's code
;Registry functions by GPI/TS-Soft
;THE CODE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
;NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;NONINFRINGEMENT. USE AT YOUR OWN RISK, YOU'VE BEEN WARNED.
Structure INTERNET_CACHE_ENTRY_INFO
dwStructSize.l
lpszSourceUrlName.l
lpszLocalFileName.l
CacheEntryType.l
dwUseCount.l
dwHitRate.l
dwSizeLow.l
dwSizeHigh.l
LastModifiedTime.FILETIME
ExpireTime.FILETIME
LastAccessTime.FILETIME
LastSyncTime.FILETIME
lpHeaderInfo.l
dwHeaderInfoSize.l
lpszFileExtension.s
StructureUnion
dwReserved.l
dwExemptDelta.l
EndStructureUnion
Buffer.b[4096]
EndStructure
Structure PST_PROMPTINFO
cbSize.l
dwPromptFlags.l
hwndApp.l
szPrompt.s
EndStructure
Interface IPStorePtr Extends IUnknown
getInfo(a)
getProvParam(a,b,c,d)
SetProvParam(a,b,c,d)
CreateType(a,b,c,d)
GetTypeInfo(a,b,c,d)
DeleteType(a,b,c)
CreateSubtype(a,b,c,d,e,f)
GetSubtypeInfo(a,b,c,d,e)
DeleteSubtype(a,b,c,d)
ReadAccessRuleset(a,b,c,d,e)
WriteAccessRuleset(a,b,c,d,e)
EnumTypes(a,b,c)
EnumSubtypes(a,b,c,d)
DeleteItem(a,b,c,d,e,f)
ReadItem(a,b,c,d,e,f,h,g)
WriteItem(a,b,c,d,e,f,h,g,k)
OpenItem(a,b,c,d,e,f,h)
CloseItem(a,b,c,d,e)
EnumItems(a,b,c,d,e)
EndInterface
Interface IEnumPStoreTypesPtr Extends IUnknown
Next(a,b,c)
Skip(a)
Reset()
Clone(a)
EndInterface
Interface IEnumPStoreItemsPtr Extends IUnknown
Next(a,b,c)
Skip(a)
Reset()
Clone(a)
EndInterface
;-----------------------------------------------------------------------------------
Procedure.i Reg_KeyExists(TopKey, RegKeyName.s)
Protected GetHandle, HKey, ReturnCode, KeyExists
If Left(RegKeyName, 1) = "\"
RegKeyName = Right(RegKeyName, Len(RegKeyName)-1)
EndIf
GetHandle = RegOpenKeyEx_(TopKey, RegKeyName, 0, #KEY_READ, @HKey)
If GetHandle = #ERROR_SUCCESS
GetHandle = RegCloseKey_(HKey)
KeyExists = #True
Else
KeyExists = #False
EndIf
ProcedureReturn KeyExists
EndProcedure
Procedure.i Reg_DeleteKey(TopKey, RegKeyName.s)
Protected GetHandle, ReturnCode, DeleteKey
If Left(RegKeyName, 1) = "\"
RegKeyName = Right(RegKeyName, Len(RegKeyName)-1)
EndIf
GetHandle = RegDeleteKey_(TopKey, @RegKeyName)
If GetHandle = #ERROR_SUCCESS
GetHandle = RegCloseKey_(HKey)
DeleteKey = #True
Else
DeleteKey = #False
EndIf
ProcedureReturn DeleteKey
EndProcedure
Procedure.i Reg_ValueExists(TopKey, RegKeyName.s, ValueName.s)
Protected LPData.s, GetValue.s = ""
If Left(RegKeyName, 1) = "\"
RegKeyName = Right(RegKeyName, Len(RegKeyName) - 1)
EndIf
GetHandle = RegOpenKeyEx_(TopKey, RegKeyName, 0, #KEY_READ, @HKey)
Retn = 0
If GetHandle = #ERROR_SUCCESS
GetHandle = RegQueryValueEx_(HKey, ValueName, 0, @Type, 0, 0)
If GetHandle = #ERROR_SUCCESS
Retn = 1
EndIf
EndIf
RegCloseKey_(HKey)
ProcedureReturn Retn
EndProcedure
Procedure.s Reg_GetValue(TopKey, RegKeyName.s, RegValueName.s)
Protected LPData.s = Space(8192), GetValue.s, GetHandle, HKey, ReturnCode, LPCBData, Type, LPType, LPDataDWORD
If Left(RegKeyName, 1) = "\"
RegKeyName = Right(RegKeyName, Len(RegKeyName)-1)
EndIf
GetHandle = RegOpenKeyEx_(TopKey, RegKeyName, 0, #KEY_READ, @HKey)
If GetHandle = #ERROR_SUCCESS
LPCBData = 8192
GetHandle = RegQueryValueEx_(HKey, RegValueName, 0, @Type, @LPData, @LPCBData)
If GetHandle = #ERROR_SUCCESS
Select Type
Case #REG_SZ
GetHandle = RegQueryValueEx_(HKey, RegValueName, 0, @Type, @LPData, @LPCBData)
If GetHandle = 0
GetValue = Left(LPData, LPCBData-1)
Else
GetValue = ""
EndIf
Case #REG_DWORD
GetHandle = RegQueryValueEx_(HKey, RegValueName, 0, @LPType, @LPDataDWORD, @LPCBData)
If GetHandle = 0
GetValue = Str(LPDataDWORD)
Else
GetValue = "0"
EndIf
Case #REG_BINARY
BinaryBytes = 8192
*RegBinary = AllocateMemory(BinaryBytes)
GetHandle = RegQueryValueEx_(HKey,RegValueName,0,@Type,*RegBinary,@BinaryBytes)
If GetHandle = 0 ; SUCCESS
GetValue = PeekS(*RegBinary,BinaryBytes,#PB_Unicode)
EndIf
If *RegBinary
FreeMemory(*RegBinary)
EndIf
EndSelect
EndIf
EndIf
RegCloseKey_(HKey)
ProcedureReturn GetValue
EndProcedure
;-----------------------------------------------------------------------------------
Procedure.s IE_GetVersion()
If Reg_ValueExists(#HKEY_LOCAL_MACHINE,"Software\Microsoft\Internet Explorer","Version") = 1
ProcedureReturn Trim(Reg_GetValue(#HKEY_LOCAL_MACHINE,"Software\Microsoft\Internet Explorer","Version"))
Else
ProcedureReturn ""
EndIf
EndProcedure
Procedure.i IE_CleanFormData(ClearForms.i,ClearPasswords.i)
Protected Version.s = IE_GetVersion()
Protected VersionMajor = Val(StringField(Version,1,"."))
Protected VersionMinor = Val(StringField(Version,2,"."))
Protected VersionBuild = Val(StringField(Version,3,"."))
Protected VersionRevision = Val(StringField(Version,4,"."))
If VersionMajor < 7
; IE4 - IE6
Protected hpsDLL, pPStoreCreateInstance, PStore.IPStorePtr, hRes
Protected EnumPStoreTypes.IEnumPStoreTypesPtr, EnumSubTypes.IEnumPStoreTypesPtr, TypeGUID.GUID, subTypeGUID.GUID, spEnumItems.IEnumPStoreItemsPtr
hpsDLL = OpenLibrary(#PB_Any,"pstorec.dll")
If IsLibrary(hpsDLL) <> 0
pPStoreCreateInstance = GetFunction(hpsDLL,"PStoreCreateInstance")
CallFunctionFast(pPStoreCreateInstance,@PStore, 0, 0, 0)
hRes = PStore\EnumTypes(0, 0, @EnumPStoreTypes)
While EnumPStoreTypes\Next(1,@TypeGUID,0) = #S_OK
hRes = PStore\EnumSubtypes(0, @TypeGUID, 0, @EnumSubTypes)
While EnumSubTypes\Next(1,@subTypeGUID,0) = #S_OK
SubType.s = Hex(subTypeGUID\Data1 & $FFFFFFFF)
hRes = PStore\EnumItems(0, @TypeGUID, @subTypeGUID, 0, @spEnumItems)
While spEnumItems\Next(1,@ItemNameP,0) = #S_OK
ItemName.s = PeekS(ItemNameP)
*Pstiinfo.PST_PROMPTINFO
hRes = PStore\ReadItem(0,@TypeGUID,@subTypeGUID,ItemNameP,@pcbData,@ppbData,*Pstiinfo,0)
Select UCase(SubType)
Case "E161255A"
If FindString(ItemName,"StringIndex",0) = 0 ;Autocomplete
If ClearForms = 1
PStore\DeleteItem(0,@TypeGUID,@subTypeGUID,ItemNameP,*Pstiinfo,0)
EndIf
ElseIf FindString(ItemName,"StringIndex",0) <> 0 ;Password
If ClearPasswords = 1
PStore\DeleteItem(0,@TypeGUID,@subTypeGUID,ItemNameP,*Pstiinfo,0)
EndIf
EndIf
EndSelect
Wend
Wend
Wend
CloseLibrary(hpsDLL)
EndIf
Else
;IE7 - IE8
If ClearForms = 1
If Reg_KeyExists(#HKEY_CURRENT_USER,"Software\Microsoft\Internet Explorer\IntelliForms\Storage1") = 1
Reg_DeleteKey(#HKEY_CURRENT_USER,"Software\Microsoft\Internet Explorer\IntelliForms\Storage1")
EndIf
EndIf
If ClearPasswords = 1
If Reg_KeyExists(#HKEY_CURRENT_USER,"Software\Microsoft\Internet Explorer\IntelliForms\Storage2") = 1
Reg_DeleteKey(#HKEY_CURRENT_USER,"Software\Microsoft\Internet Explorer\IntelliForms\Storage2")
EndIf
EndIf
EndIf
ProcedureReturn 1
EndProcedure
;-----------------------------------------------------------------------------------
;!!! EXAMPLE !!!
;!!! Uncomment the following lines to test the code !!!
;!!! Note that this will DELETE ALL the InternetExplorer passwords and form data !!!
;OpenConsole()
;PrintN("IE "+IE_GetVersion()+" detected")
;PrintN("Cleaning...")
;IE_CleanFormData(1,1)
;PrintN("Cleaned...")
;Input()