الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في برنامجي keylogger

بدأه Rasool Micro في 28 نوفمبر 2011 · 10 رد · 1,612 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام وعليكم اخواني كيف الحال :)

في البداية ارجوا ان تعذروني لاني انزل اسئلة كثيرة وخصوصاً حول keylogger وارجوا ان تتحملونني :blush:

لدي مشكلة خطيرة وهي :

لقد قمت بصناعة برنامج keylogger والحمد لله يعمل جيداً ويجلب لي ايضاً حالة المفاتيح في اي نافذة نشطة واي لغة كانت ولكن المشكلة انه عندما افتح صفحة ويب للاسف لا يجلب لي حالة اللغة في تلك الصفحة ؟؟؟ :wacko: وهذه مشكلة خطيرة حيث برنامج يجب ان يراقب المفاتيح جيداً وباي لغة كانت :sad:

وهذا الكود هو يوضح العمل الذي قمت به وهو فقط يوضح كيف يجلب حالة اللغة في النافذة النشطة

Public Class Form1
    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByVal lpdwProcessId As Integer) As Integer
    Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Integer) As Integer
    Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr
    Private Function GetActiveWindowLayout() As String
        Dim hwnd As Integer = GetForegroundWindow()
        Dim intTemp As Integer = 0
        Dim activeWindowThreadId As Integer = GetWindowThreadProcessId(hwnd, intTemp)
        Dim currentHKL As Integer = GetKeyboardLayout(activeWindowThreadId)
        currentHKL = currentHKL + 65535
        Dim strOutput = String.Format("{0:X}", currentHKL)
        While (strOutput.Length < 8)
            strOutput = "0" + strOutput
        End While
        Return strOutput
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 10
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = GetActiveWindowLayout()
    End Sub
End Class

ارجوا ان تفيدونني وشكراً

تم تعديل هذه المشاركة بواسطة Rasool Micro في 28 نوفمبر 2011 في 10:03

#2

وعليكم السلام ورحمه الله وبركاته ’,.

الأفضل تاخذ عنوان النافذه من البروسيس

مثال

Public Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr

Public Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer

Function ActiveWND() As String ' njq8 :_)

Dim id As Integer = 0

GetWindowThreadProcessId(GetForegroundWindow.ToInt32, id)

Return "[x]".Replace("x", Process.GetProcessById(id).ProcessName) & Process.GetProcessById(id).MainWindowTitle

End Function

بالتوفيق ..

#3
njq8 كتب:

وعليكم السلام ورحمه الله وبركاته ’,.

الأفضل تاخذ عنوان النافذه من البروسيس

مثال

Public Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr

Public Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer

Function ActiveWND() As String ' njq8 :_)

Dim id As Integer = 0

GetWindowThreadProcessId(GetForegroundWindow.ToInt32, id)

Return "[x]".Replace("x", Process.GetProcessById(id).ProcessName) & Process.GetProcessById(id).MainWindowTitle

End Function

بالتوفيق ..

اخي لقد جربت الكود لكن الدالة ترجع لي قيمة = [idl]............ ممكن توضح اكثر ؟؟؟؟؟

#4

الكود يطلع لك اسم العمليه + عنوان النافذه

[notepad] Untitled - Notepad

جرب تحطها بـ تايمر

Me.Text = ActiveWND()

شغل المشروع وروح لأي نافذه ثانيه راح تشوف عنوان الفورم تغير

#5
njq8 كتب:

الكود يطلع لك اسم العمليه + عنوان النافذه

[notepad] Untitled - Notepad

جرب تحطها بـ تايمر

Me.Text = ActiveWND()

شغل المشروع وروح لأي نافذه ثانيه راح تشوف عنوان الفورم تغير

اخي الجليل انا أستعملت التايمر من البداية

وانا لم اقل بأن الكود لم يعمل اي لم يخرج لي output

ولكن هذا الكود لم يحل مشكلتي مازال عندما افتح صفحة ويب عندما اغير اللغة لم يخرج لي اللغة التي انتقلت اليها او لجأت اليها ............

#6

أخوي لو حبيت مساعده بالإيميل ضيفني

yu@hotmail.com

لان الكود بالنسبه لي شغال تمام Win7 64bit وجربته على كثير اجهزه بدون مشاكل

ودامك مهتم ببرمجه الكيلوجر انا مبرمج برنامج إختراق كامل :)

عالعموم اشرح لك الاكواد اللي كتبتها لك بالمشاركه الاولى

GetForegroundWindow

يعطيك الـ handle للنافذه الفعاله active window

واذا ماكان فيه نافذه فعاله يرجع لك handle = 0

واعتقد هذي المشكله معاك انه مايكتشف النافذه الفعاله ويعطيك handle=0

اللي اهي عمليه idle بجهازك

يا انها حاله خاصه بجهازك او تحتاج تغير نوع الـ GetForegroundWindow

من IntPtr إلى integer

وهذي تفرق على حسب نظام الجهاز 64bit او 32bit

وبالنسبه لـ GetWindowThreadProcessId

يحول لك الـ handle إلى رقم العمليه

handle to process ID

وبعدها نطلع عنوان النافذه الفعاله من البروسيس

Process.GetProcessById(id).MainWindowTitle

وهذي صوره توضح ان الكود اللي عطيتك فعال .. حسب اللي فهمته من كلامك انه مايطلع لك اللغات فقط انجليزي لان كل اللغات تعتبر unicode ماعدا الانجليزيه تعتبر Text

Test.png

Test.png

تم تعديل هذه المشاركة بواسطة njq8 في 8 ديسمبر 2011 في 10:06

#7
njq8 كتب:

أخوي لو حبيت مساعده بالإيميل ضيفني

yu@hotmail.com

لان الكود بالنسبه لي شغال تمام Win7 64bit وجربته على كثير اجهزه بدون مشاكل

ودامك مهتم ببرمجه الكيلوجر انا مبرمج برنامج إختراق كامل :)

عالعموم اشرح لك الاكواد اللي كتبتها لك بالمشاركه الاولى

GetForegroundWindow

يعطيك الـ handle للنافذه الفعاله active window

واذا ماكان فيه نافذه فعاله يرجع لك handle = 0

واعتقد هذي المشكله معاك انه مايكتشف النافذه الفعاله ويعطيك handle=0

اللي اهي عمليه idle بجهازك

يا انها حاله خاصه بجهازك او تحتاج تغير نوع الـ GetForegroundWindow

من IntPtr إلى integer

وهذي تفرق على حسب نظام الجهاز 64bit او 32bit

وبالنسبه لـ GetWindowThreadProcessId

يحول لك الـ handle إلى رقم العمليه

handle to process ID

وبعدها نطلع عنوان النافذه الفعاله من البروسيس

Process.GetProcessById(id).MainWindowTitle

وهذي صوره توضح ان الكود اللي عطيتك فعال .. حسب اللي فهمته من كلامك انه مايطلع لك اللغات فقط انجليزي لان كل اللغات تعتبر unicode ماعدا الانجليزيه تعتبر Text

Test.png

Test.png

اخي الواضح انك اسأت الفهم

انا قلت اللغة بمعنى ليست لغة اسم النافذة النشطة وانما اللغة المستخدمة في لوحة المفاتيح في تلك النافذة

سأقرب لك المعنى:

عندما استدعيت الدالة التي هي GetForgroundWindow واعطاني الhandle الخاص لهذه النافذة قمت بتمرير قيمة الدالة الى دالة اخرى تدعى بالGetWindowThreadProcessId ومن ثم مررت قيمة هذه الدالة الى دالة اخرى ايضا اسمها GetKeyboardLayout وهذه الدالة تقوم بإرجاع حالة اللغة في تلك النافذة اي :

اذا كانت 04020800 يعني عربي

واذا كانت 040A0408 يعني انكليزي

(هذا القيم تكون بهذه الطريقة بعد اجراء عدة عمليات عليها)

المهم

وهذا هو كود الدالة التي تجلب لي حالة اللغة المستخدمة في الكيبورد في النافذة النشطة

Private Function GetActiveWindowLayout() As String
        Dim hwnd As Integer = GetForegroundWindow()
        Dim intTemp As Integer = 0
        Dim activeWindowThreadId As Integer = GetWindowThreadProcessId(hwnd, intTemp)
        Dim currentHKL As Integer = GetKeyboardLayout(activeWindowThreadId)
        currentHKL = currentHKL + 65535
        Dim strOutput = String.Format("{0:X}", currentHKL)
        While (strOutput.Length < 8)
            strOutput = "0" + strOutput
        End While
        Return strOutput
    End Function

هذه الدالة تعمل بشكل فعال جداً وفي جميع النوافذ عدا صفحات الويب حيث لا تجلب لي اللغة المستخدمة في الكبيبورد

هذه هي مشكلتي؟

اظن ان شرحي الان واضح

بالنسبة الى موضوع اضافتك على الايميل فانا من مستخدمي الياهو

r_picasa@yahoo.com

وهذا هو اسمي في الفيس بوك اذا اردت ارسال دعوة صداقة على الفيس بوك

Rasool Ahmed

#8

آسف أخوي مافهمت عليك من البدايه

لكن الحين فهمت قصدك انك تبي تاخذ لغه الكتابه بالنافذه الفعاله ..

بأذن الله انحلت مشكلتك

تابع الاكواد

Public Class Form1

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByVal lpdwProcessId As Integer) As Integer

Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr

Dim max As Integer = InputLanguage.InstalledInputLanguages.Count - 1

Public Hwd As New List(Of Integer) ' list of window handle

Public K As New List(Of Integer) ' list of keyboard index

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Control.CheckForIllegalCrossThreadCalls = False ' this will let our new thread access form or any other control

Dim t As New Threading.Thread(AddressOf Watch, 10) ' make new thread so our form will not freezed

t.Start()

End Sub

Function GetActiveWindowLayout() As String

Try

Return InputLanguage.InstalledInputLanguages.Item(K(Hwd.IndexOf(GetForegroundWindow.ToInt32))).LayoutName

Catch ex As Exception

Return InputLanguage.InstalledInputLanguages.Item(0).LayoutName

End Try

End Function

Sub Watch()

While True

If Me.IsDisposed Then Exit Sub ' check if form closed exit sub

Dim h As IntPtr = GetForegroundWindow ' get active window

If Hwd.Contains(h.ToInt32) = False Then ' if new window then add it to list of hwnd

Hwd.Add(h) ' add window handle

K.Add(0) ' add first keyboad languge index of 0

Else

For Each x As Integer In Hwd.ToArray ' clear closed hwnd

If GetWindowThreadProcessId(x, 0) = 0 Then ' if window closed remove it from our List

K.RemoveAt(Hwd.IndexOf(x)) ' remove keyboard

Hwd.RemoveAt(Hwd.IndexOf(x)) ' remove handle

End If

Next

End If

If My.Computer.Keyboard.AltKeyDown And My.Computer.Keyboard.ShiftKeyDown Then ' if shiftkey + alt is down mean change languge

Do Until My.Computer.Keyboard.AltKeyDown = False And My.Computer.Keyboard.CtrlKeyDown = False ' wait for keys up

Threading.Thread.CurrentThread.Sleep(1)

Loop

K(Hwd.IndexOf(h.ToInt32)) += 1 ' key index+1 = next installed languge

If K(Hwd.IndexOf(h.ToInt32)) > max Then ' see if out of index or not

K(Hwd.IndexOf(h.ToInt32)) = 0

End If

Me.Text = Me.Text = GetActiveWindowLayout() ' <<<<<<<<<<<<<<<<<<<<<

End If

Threading.Thread.CurrentThread.Sleep(1)

End While

End Sub

End Class

بالبدايه علشان تتأكد من فعاليه الكود انسخه و ألصقه بـ مشروع جديد

وعند تشغيل المشروع اذهب ألى اي نافذه وغير لغه الكتابه راح تشوف عنوان نافذه مشروعك تغيرت إلى نفس لغه الكيبورد

كتبت تعليقات انجليزيه عند تقريبا كل سطر واسمحلي ماكتبتها بالعربي لان بالعربي صعب اوضحها لك

صوره توضح >>

activ.png

وإن شاء الله تكون فاهم لـ التعامل مع الـ threads

لاني خليتها بـ ثريد لـ حالها علشان لا يتجمد مشروعك وقت الـ do until + sleep

بالتوفيق ..

#9
njq8 كتب:

آسف أخوي مافهمت عليك من البدايه

لكن الحين فهمت قصدك انك تبي تاخذ لغه الكتابه بالنافذه الفعاله ..

بأذن الله انحلت مشكلتك

تابع الاكواد

Public Class Form1

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByVal lpdwProcessId As Integer) As Integer

Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr

Dim max As Integer = InputLanguage.InstalledInputLanguages.Count - 1

Public Hwd As New List(Of Integer) ' list of window handle

Public K As New List(Of Integer) ' list of keyboard index

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Control.CheckForIllegalCrossThreadCalls = False ' this will let our new thread access form or any other control

Dim t As New Threading.Thread(AddressOf Watch, 10) ' make new thread so our form will not freezed

t.Start()

End Sub

Function GetActiveWindowLayout() As String

Try

Return InputLanguage.InstalledInputLanguages.Item(K(Hwd.IndexOf(GetForegroundWindow.ToInt32))).LayoutName

Catch ex As Exception

Return InputLanguage.InstalledInputLanguages.Item(0).LayoutName

End Try

End Function

Sub Watch()

While True

If Me.IsDisposed Then Exit Sub ' check if form closed exit sub

Dim h As IntPtr = GetForegroundWindow ' get active window

If Hwd.Contains(h.ToInt32) = False Then ' if new window then add it to list of hwnd

Hwd.Add(h) ' add window handle

K.Add(0) ' add first keyboad languge index of 0

Else

For Each x As Integer In Hwd.ToArray ' clear closed hwnd

If GetWindowThreadProcessId(x, 0) = 0 Then ' if window closed remove it from our List

K.RemoveAt(Hwd.IndexOf(x)) ' remove keyboard

Hwd.RemoveAt(Hwd.IndexOf(x)) ' remove handle

End If

Next

End If

If My.Computer.Keyboard.AltKeyDown And My.Computer.Keyboard.ShiftKeyDown Then ' if shiftkey + alt is down mean change languge

Do Until My.Computer.Keyboard.AltKeyDown = False And My.Computer.Keyboard.CtrlKeyDown = False ' wait for keys up

Threading.Thread.CurrentThread.Sleep(1)

Loop

K(Hwd.IndexOf(h.ToInt32)) += 1 ' key index+1 = next installed languge

If K(Hwd.IndexOf(h.ToInt32)) > max Then ' see if out of index or not

K(Hwd.IndexOf(h.ToInt32)) = 0

End If

Me.Text = Me.Text = GetActiveWindowLayout() ' <<<<<<<<<<<<<<<<<<<<<

End If

Threading.Thread.CurrentThread.Sleep(1)

End While

End Sub

End Class

بالبدايه علشان تتأكد من فعاليه الكود انسخه و ألصقه بـ مشروع جديد

وعند تشغيل المشروع اذهب ألى اي نافذه وغير لغه الكتابه راح تشوف عنوان نافذه مشروعك تغيرت إلى نفس لغه الكيبورد

كتبت تعليقات انجليزيه عند تقريبا كل سطر واسمحلي ماكتبتها بالعربي لان بالعربي صعب اوضحها لك

صوره توضح >>

activ.png

وإن شاء الله تكون فاهم لـ التعامل مع الـ threads

لاني خليتها بـ ثريد لـ حالها علشان لا يتجمد مشروعك وقت الـ do until + sleep

بالتوفيق ..

اشكرك اخي الكود يعمل مئة بالمئة

ولكن لدي طلب ارجوا ان لا اكون قد اتعبتك

هل تستطيع أن تجعل هذا البرنامج يعمل بواسطة الدالة التي تكلمت عليها في ردي الاخير وهي GetKeyboardLayout؟

اظن العمل مع هذه الدالة افضل لانه المستخدم في بعض الاحيان لا يستعمل هذا الاختصار alt+shift قد يحول اللغة يدوياً حيث يذهب الى الtaskbar ومن ثم يضغط بالماوس على الايكونه التي تحوي على اللغة الحالية

ارجوا ان لا اكون قد اثقلت عليك

#10

الســـــــــــــــــــلام عليكم

ممكن تساااااعدوني !! الدكتور طلب منا نعمل برنامج Keylogger بلغة vb علماً بأننا لم ندرس هذه اللغه من قبل !!! :sad:

ان لــم ترونــي يومـاً هنـا فلتعلمــوا اننــي قـد رحلــت

فأتمنــى ان تكــون القلــوب صآفيــه والنفــوس عنــي رآضيــه

بــ الاخوةِ لاقـــيتكم وبهآ اودعــكم ..

فــ آسف لكــل القلوب التــي اسات

#11

مشكورر

مواضيع مشابهة