FALHA DE SEGURANCA NO VB E OS 95/98/ME

USUARIO.EXCLUIDOS 11/05/2006 20:03:45
#146218
LUIS HERREIRA, me passe um executavél teste pra ver se meu programa consegue capturar ou não...
DIOGENES.DIAS 11/05/2006 20:34:33
#146220


Existe uma técnica que é: Escrever na caixa de texto um valor criptografado e armazenar o valor real em uma variável públic ao form. Qundo for ler este valor pega-se da variável e não da caixa de texto. Acho esta solução mais simples, se houver alguma falha e ou brecha de segurança, por favor informem isto. Vamos ao código.

Em um módulo Bas Coloque:

Option Explicit
'
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
'> NÃO MODIFIQUE ESTA CONSTANTE DE FORMA ALGUMA <
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
'
Private Const ENCRYPT_KEY = "VBMANIA"
'
Public Function XOR_Encrypt(ToCrypt As String, Optional PassWordKey As String)
'
Dim PosS As Long
Dim PosC As Long
Dim Tempstring As String
'
If Len(Trim(PassWordKey)) = 0 Then
PassWordKey = ENCRYPT_KEY 'LIC_CLSID
End If
'
Tempstring = Space(Len(ToCrypt))
'
PosC = 1
For PosS = 1 To Len(ToCrypt)
'
If PosC > Len(PassWordKey) Then
PosC = 1
End If
'
Mid(Tempstring, PosS, 1) = Chr(Asc(Mid(ToCrypt, PosS, 1)) Xor Asc(Mid(PassWordKey, PosC, 1)))
'
If Asc(Mid(Tempstring, PosS, 1)) = 0 Then
Mid(Tempstring, PosS, 1) = Mid(ToCrypt, PosS, 1)
End If
'
PosC = PosC + 1
'
Next PosS
'
XOR_Encrypt = Tempstring
'
End Function
'
Em Um form coloque:
Option Explicit
'
Private Type POINTAPI
x As Long
y As Long
End Type
'
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'
Private IPAGE As String
Private Tmp As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Command1_Click()
MsgBox Tmp, vbInformation, "Valor Real"
End Sub
'
Private Sub Form_Load()
Me.Timer1.Interval = 100
Me.Timer1.Enabled = True
End Sub

Private Sub Text3_Change()
If Len(Text3.Text) = 0 Then Tmp = ""
End Sub

Private Sub Text3_GotFocus()
Text3.SelStart = 0
Text3.SelLength = Len(Text3.Text)
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
Tmp = Left(Tmp, Len(Tmp) - 1 * Abs(Len(Tmp) > 1))
Case Else
IPAGE = ""
Tmp = Tmp & Chr$(KeyAscii)

IPAGE = XOR_Encrypt(Chr$(KeyAscii))
Text3.Text = Text3.Text & IPAGE
Text3.SelStart = Len(Text3.Text)
KeyAscii = 0
End Select
End Sub

Private Sub Timer1_Timer()
'
Dim cursorPos As POINTAPI
Dim TextLength As Integer
Dim hWnd As Long
Dim winText As String
Static prevHWnd As Long
'
Call GetCursorPos(cursorPos)
hWnd = WindowFromPoint(cursorPos.x, cursorPos.y)

If prevHWnd <> hWnd Then
Text1.Text = "Log:"
Text1.Text = Text1.Text & vbCrLf & "Hwnd do cursor:" & vbCrLf & hWnd
TextLength = GetWindowTextLength(hWnd) + 1
winText = Space(TextLength)
Call GetWindowText(hWnd, winText, TextLength)
Text1.Text = Text1.Text & vbCrLf & "Texto do campo: " & vbCrLf & winText
prevHWnd = hWnd
End If
End Sub


"O Homem diante das soluçoes simples é cego como o morcego diante da luz"

ThatÂÂÂ's all
Página 2 de 2 [18 registro(s)]
Tópico encerrado , respostas não são mais permitidas