分享
 
 
 

最新Viking(维金)病毒专杀工具,纯VB编写。

王朝vb·作者佚名  2007-11-06
窄屏简体版  字體: |||超大  

(声明:魏滔序原创,转贴请注明出处。)

Viking的肆虐让很多受害者忍无可忍,更可气的是专业软件公司提供的专杀工具竟然无法彻底清除。

无奈之余自己动手写了一个,请需要的朋友到这里下载:http://www.chenoe.com

该工具可以有效解除被感染的exe中的病毒并还原exe文件,网上的大部分工具是直接删除exe文件。另外,本工具还具有Viking免疫功能。

下载后直接运行即可查杀,如果查杀几次都有无法关闭的进程的,重新启动一下计算机继续查杀应该可以杀掉。直到病毒数为0时为止。

另外提供该工具中结束进程部分的代码,结束进程一般采用TerminateProcess函数,但是对于比较顽固的进程就要用非常规的手段来Kill了。

我的方法是,先提高本程序为Debug级别的权限。再用TerminateProcess关闭,如果失败就枚举该进程中的线程并用TerminateThread关闭。然后再用TerminateProcess结束进程。这样就基本上可以关闭99%的非系统进程了。

还有,对于被注入了病毒dll的进程,要先枚举进程中的模块并判断。然后决定是否Kill,Kill方法同上。

以下为进程、线程、模块相关的代码:

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long

Private Declare Function Thread32First Lib "KERNEL32.dll" (ByVal hSnapshot As Long, ByRef lpte As THREADENTRY32) As Long

Private Declare Function Thread32Next Lib "KERNEL32.dll" (ByVal hSnapshot As Long, ByRef lpte As THREADENTRY32) As Long

Private Declare Function Module32First Lib "KERNEL32.dll" (ByVal hSnapshot As Long, ByRef lppe As MODULEENTRY32) As Long

Private Declare Function Module32Next Lib "KERNEL32.dll" (ByVal hSnapshot As Long, ByRef lpme As MODULEENTRY32) As Long

Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

Private Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function OpenThread Lib "KERNEL32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwThreadId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Const TH32CS_SNAPPROCESS = &H2

Private Const TH32CS_SNAPTHREAD = &H4

Private Const TH32CS_SNAPMODULE As Long = &H8

Private Const PROCESS_TERMINATE As Long = (&H1)

Private Const MAX_PATH As Integer = 260

Private Type PROCESSENTRY32

dwsize As Long

cntusage As Long

th32ProcessID As Long

th32DefaultHeapID As Long

th32ModuleID As Long

cntThreads As Long

th32ParentProcessID As Long

pcPriClassBase As Long

dwFlags As Long

szExeFile As String * MAX_PATH

End Type

Private Type MODULEENTRY32 '模块

dwsize As Long

th32ModuleID As Long

th32ProcessID As Long

GlblcntUsage As Long

ProccntUsage As Long

modBaseAddr As Byte

modBaseSize As Long

hModule As Long

szModule As String * 256

szExePath As String * 1024

End Type

Private Type THREADENTRY32 '线程

dwsize As Long

cntusage As Long

th32threadID As Long

th32OwnerProcessID As Long

tpBasePri As Long

tpDeltaPri As Long

dwFlags As Long

End Type

Public Function KillThread(ByVal ProcessID As Long) As Boolean

Dim hThread As Long, r As Long, i As Long

Dim TList() As THREADENTRY32

TList = GetThreadList(ProcessID)

For i = 0 To UBound(TList)

With TList(i)

hThread = OpenThread(PROCESS_TERMINATE, False, .th32threadID) '获取进程句柄

If hThread <> 0 Then

r = TerminateThread(hThread, 0) '关闭进程

End If

End With

Next

KillThread = r <> 0

End Function

Public Function KillProcess(ByVal ProcessName As String, Optional ByVal bKillThread As Boolean) As Boolean

Dim hProcess As Long, r As Long

Dim PList() As PROCESSENTRY32

Dim Name As String, i As Long

PList = GetProcessList

For i = 0 To UBound(PList)

With PList(i)

Name = Left(.szExeFile, InStr(1, .szExeFile, vbNullChar) - 1)

DoEvents

Form1.lbState.Caption = "正在内存查毒: " & Name

r = InModule(.th32ProcessID, ProcessName)

If LCase(Trim(Name)) = LCase(Trim(ProcessName)) Or r Then

hProcess = OpenProcess(PROCESS_TERMINATE, False, .th32ProcessID) '获取进程句柄

If hProcess <> 0 Then

r = TerminateProcess(hProcess, 0) '关闭进程

If r Then

AddLog Name, "已结束进程"

Else

If bKillThread Then

If KillThread(.th32ProcessID) Then

AddLog Name, "已结束线程"

Else

AddLog Name, "线程结束失败"

End If

End If

r = TerminateProcess(hProcess, 0) '关闭进程

If r Then

AddLog Name, "已结束进程"

Else

AddLog Name, "进程结束失败"

End If

End If

Else

AddLog Name, "无法获得进程句柄"

End If

End If

End With

Next

End Function

Private Function GetThreadList(ByVal ProcessID As Long) As THREADENTRY32()

Dim i As Long

Dim TList() As THREADENTRY32

Dim TE32 As THREADENTRY32

Dim hThreadSnap As Long

Dim TheLoop As Long

hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, ProcessID)

TE32.dwsize = Len(TE32)

TheLoop = Thread32First(hThreadSnap, TE32)

While TheLoop <> 0

If TE32.th32OwnerProcessID = ProcessID Then

ReDim Preserve TList(i)

TerminateThread TE32.th32threadID, 0

TList(i) = TE32

i = i + 1

End If

TheLoop = Thread32Next(hThreadSnap, TE32)

Wend

CloseHandle hThreadSnap

GetThreadList = TList

End Function

Private Function GetProcessList() As PROCESSENTRY32()

Dim i As Long

Dim PList() As PROCESSENTRY32

Dim PE32 As PROCESSENTRY32

Dim hProcessSnap As Long

Dim TheLoop As Long

hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)

PE32.dwsize = Len(PE32)

TheLoop = Process32First(hProcessSnap, PE32)

While TheLoop <> 0

ReDim Preserve PList(i)

PList(i) = PE32

i = i + 1

TheLoop = Process32Next(hProcessSnap, PE32)

Wend

CloseHandle hProcessSnap

GetProcessList = PList

End Function

Private Function GetModuleList(ByVal ProcessID As Long) As MODULEENTRY32()

Dim i As Long

Dim MList() As MODULEENTRY32

Dim ME32 As MODULEENTRY32

Dim hModuleSnap As Long

Dim TheLoop As Long

hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID)

ME32.dwsize = Len(ME32)

TheLoop = Module32First(hModuleSnap, ME32)

While TheLoop <> 0

ReDim Preserve MList(i)

MList(i) = ME32

i = i + 1

TheLoop = Module32Next(hModuleSnap, ME32)

Wend

CloseHandle hModuleSnap

GetModuleList = MList

End Function

Private Function InModule(ByVal ProcessID As Long, ByVal ModuleName As String) As Boolean

Dim i As Long

Dim MList() As MODULEENTRY32

Dim Name As String

On Error GoTo Err:

MList = GetModuleList(ProcessID)

For i = 0 To UBound(MList)

With MList(i)

Name = Left(.szModule, InStr(1, .szModule, vbNullChar) - 1)

If LCase(Name) = LCase(ModuleName) Then

InModule = True

Exit For

End If

End With

Next

Err:

End Function

'这个是显示的杀毒记录

Sub AddLog(txt1 As String, txt2 As String)

Dim Item As ListItem

Set Item = Form1.lv.ListItems.Add(, , txt1)

Item.SubItems(1) = txt2

End Sub

以下为设置本程序权限级别的代码,在程序加载前调用EnableDebugPrivilege即可:

Private Type LARGE_INTEGER

lowpart As Long

highpart As Long

End Type

Private Const ANYSIZE_ARRAY As Long = 1

Private Const SE_PRIVILEGE_ENABLED As Long = &H2

Private Const TOKEN_ADJUST_PRIVILEGES As Long = &H20

Private Const TOKEN_QUERY As Long = &H8

Private Type LUID_AND_ATTRIBUTES

LUID As LARGE_INTEGER

Attributes As Long

End Type

Private Type TOKEN_PRIVILEGES

PrivilegeCount As Long

Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES

End Type

Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LARGE_INTEGER) As Long

Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, ByRef NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, ByRef PreviousState As Long, ByRef ReturnLength As Long) As Long

Private Declare Function GetCurrentProcess Lib "KERNEL32.dll" () As Long

Private Declare Function GetCurrentProcessId Lib "KERNEL32.dll" () As Long

Private Declare Function CloseHandle Lib "KERNEL32.dll" (ByVal hObject As Long) As Long

Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, ByRef TokenHandle As Long) As Long

Private Declare Function GetLastError Lib "KERNEL32.dll" () As Long

Function EnableDebugPrivilege() As Boolean

Dim TP As TOKEN_PRIVILEGES

Dim hToken As Long, r As Long, e As Long

r = OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken)

e = GetLastError

' Err.Raise 6

If r And Not e Then

r = LookupPrivilegeValue(vbNullString, "SeDebugPrivilege", TP.Privileges(0).LUID)

e = GetLastError

If r And Not e Then

TP.PrivilegeCount = 1

TP.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED

r = AdjustTokenPrivileges(hToken, False, TP, LenB(TP), 0, 0)

EnableDebugPrivilege = GetLastError = 0

End If

End If

Call CloseHandle(hToken)

End Function

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有