摘自百度百科:
LanSet是LanStar的设置程序
界面:
逆它的原因是这个程序可以结束LanStar程序,我要获得这个方法。
什么是LanStar
LanStar 多媒体教学网络系统,是一套多媒体教学平台,包含影音广播,教学辅助,教学监控,系统管理四大工具群。用户可以透过LanStar 教学平台同时对数百位同学进行多媒体互动教学,从而大幅提高教学成效。
也就是我们学校至善楼xp机用的教学系统啦
找关键代码:
点登陆提示失败
一个信息框,多年来混迹黑暗领域的Cracker,嘴角露出了微笑......
很容易的找到了关键代码:
我把这个函数命名为g_test_password
.text:004054F0 ; int __thiscall g_test_password(CWnd *this) .text:004054F0 g_test_password proc near ; DATA XREF: .rdata:00407E04
.text:004054F0 ; int __thiscall g_test_password(CWnd *this) .text:004054F0 g_test_password proc near ; DATA XREF: .rdata:00407E04 .text:004054F0 push esi .text:004054F1 mov esi, ecx .text:004054F3 push 1 ; int .text:004054F5 call ?UpdateData@CWnd@@QAEHH@Z ; 控件内容装入控件变量 .text:004054FA mov eax, [esi+68h] ; 比较字符串,一个是我们输入的,那么这个是什么?你猜 .text:004054FD mov ecx, [esi+60h] ; 我们输入的内容 .text:00405500 push eax ; unsigned __int8 *push 正确密码lanstar .text:00405501 push ecx ; unsigned __int8 *push 我们输入的密码 .text:00405502 call ds:_mbscmp ;call strcmp .text:00405508 add esp, 8 ;esp + 8 .text:0040550B test eax, eax ; strcmp返回结果 相同=0 否则!=0 .text:0040550D jz short loc_40555A ; 根据结果决定是否跳 相同就跳走 跳走正确 否则出错 .text:0040550F push 0FFFFFFFFh ; unsigned int .text:00405511 push 10h ; unsigned int .text:00405513 push 801Fh ; unsigned int .text:00405518 call ?AfxMessageBox@@YGHIII@Z ; 弹错误框啦 .text:0040551D mov cl, [esi+64h] .text:00405520 inc cl .text:00405522 mov al, cl .text:00405524 mov [esi+64h], cl .text:00405527 cmp al, 2 .text:00405529 jbe short loc_405545 .text:0040552B push 0FFFFFFFFh ; unsigned int .text:0040552D push 10h ; unsigned int .text:0040552F push 8020h ; unsigned int .text:00405534 call ?AfxMessageBox@@YGHIII@Z ; 也弹错误框 这个带路径的 .text:00405539 mov eax, [esi] .text:0040553B mov ecx, esi .text:0040553D call dword ptr [eax+0D0h] .text:00405543 pop esi .text:00405544 retn .text:00405545 ; --------------------------------------------------------------------------- .text:00405545 .text:00405545 loc_405545: ; CODE XREF: g_test_password+39j .text:00405545 push 408h ; int .text:0040554A mov ecx, esi ; this .text:0040554C call ?GetDlgItem@CWnd@@QBEPAV1@H@Z ; CWnd::GetDlgItem(int) .text:00405551 mov ecx, eax ; this .text:00405553 call ?SetFocus@CWnd@@QAEPAV1@XZ ; CWnd::SetFocus(void) .text:00405558 pop esi .text:00405559 retn .text:0040555A ; --------------------------------------------------------------------------- .text:0040555A//跳到这就成功啦 .text:0040555A loc_40555A: ; CODE XREF: g_test_password+1Dj .text:0040555A mov ecx, esi ; this .text:0040555C call ?OnOK@CDialog@@MAEXXZ ; 返回ok .text:00405561 pop esi .text:00405562 retn .text:00405562 g_test_password endp
这个函数的做的事情就是把用户输入的密码跟“lanstar”比较 相同就通过 否则~
伪代码:
void __thiscall g_test_password(CWnd *this) { CWnd *m_Cw_edit; //用于记录输入框控件对象 //int m_error_count = 0;//这个是成员变量 记录出错次数 CWnd::UpdateData(this, 1); if(mbscmp("lanstar",m_input_user)) { AfxMessageBox("密码错误!"); m_error_count ++; if(m_error_count <= 2) { m_Cw_edit = CWnd::GetDlgItem(this, 1032);//1032应该是输入框的控件ID CWnd::SetFocus(m_Cw_edit);//设置焦点 }else { AfxMessageBox("连续3次输入错误 ! 程序即将退出!"); ExitProcess(0); } }else { CDialog::OnOK(this); } }
下面是找第二个界面中的确定键干了什么
这个键下面有我想要的信息,它怎么结束lanstar的
找关键代码:
看到界面上这么多输入控件,多年来混迹黑暗领域的Cracker,嘴角露出了微笑......
我把这个函数命名为g_set_config
.text:00403C20 ; int __thiscall g_set_config(CWnd *this) .text:00403C20 g_set_config proc near ; DATA XREF: .rdata:00407B64o .text:00403C20
中间有一部分都在写注册表 就省略了
.text:00403C20 ; int __thiscall g_set_config(CWnd *this) .text:00403C20 g_set_config proc near ; DATA XREF: .rdata:00407B64o .text:00403C20 .text:00403C20 phkResult = dword ptr -430h .text:00403C20 var_42C = dword ptr -42Ch .text:00403C20 var_428 = dword ptr -428h .text:00403C20 lpWindowName = dword ptr -424h .text:00403C20 Data = byte ptr -420h .text:00403C20 in = in_addr ptr -41Ch .text:00403C20 Drive = byte ptr -418h .text:00403C20 var_414 = byte ptr -414h .text:00403C20 Filename = byte ptr -410h .text:00403C20 Dir = byte ptr -30Ch .text:00403C20 Ext = byte ptr -20Ch .text:00403C20 var_10C = byte ptr -10Ch .text:00403C20 var_C = dword ptr -0Ch .text:00403C20 var_4 = dword ptr -4 .text:00403C20 .text:00403C20 push 0FFFFFFFFh .text:00403C22 push offset SEH_403C20 .text:00403C27 mov eax, large fs:0 .text:00403C2D push eax .text:00403C2E mov large fs:0, esp .text:00403C35 sub esp, 424h .text:00403C3B push ebx .text:00403C3C push ebp .text:00403C3D mov ebp, 1 .text:00403C42 push esi .text:00403C43 mov esi, ecx .text:00403C45 push ebp ; int .text:00403C46 call ?UpdateData@CWnd@@QAEHH@Z ; 更新内容到变量 .text:00403C4B lea ecx, [esp+43Ch+var_428] .text:00403C4F call ??0CString@@QAE@XZ ; 初始化一个空的cstring .text:00403C54 lea ecx, [esp+43Ch+var_42C] .text:00403C58 mov [esp+43Ch+var_4], 0 .text:00403C63 call ??0CString@@QAE@XZ ; CString::CString(void) .text:00403C68 push 66h ; unsigned int .text:00403C6A lea ecx, [esp+440h+var_42C] ; this .text:00403C6E mov byte ptr [esp+440h+var_4], 1 .text:00403C76 call ?LoadStringA@CString@@QAEHI@Z ; CString::LoadStringA(uint) .text:00403C7B mov eax, [esi+12Ch] .text:00403C81 mov ebx, ds:_mbscmp ; 获得mbscmp地址? .text:00403C87 cmp eax, ebp .text:00403C89 jnz short loc_403CD0 ; 地址不对就跳走 .text:00403C8B mov eax, [esi+128h] ; 指定ip字符串 另外一个字符串为空 .text:00403C91 push offset byte_40A898 ; unsigned __int8 * .text:00403C96 push eax ; unsigned __int8 * .text:00403C97 call ebx ; _mbscmp ; 判断指定ip是否为空 .text:00403C99 add esp, 8 .text:00403C9C test eax, eax ; 相同为0 否则 !=0 .text:00403C9E jnz short loc_403CD0 ; 指定ip字符串不为空 跳走 .text:00403CA0 push 67h ; unsigned int .text:00403CA2 lea ecx, [esp+440h+var_428] ; this .text:00403CA6 call ?LoadStringA@CString@@QAEHI@Z ; CString::LoadStringA(uint) .text:00403CAB mov eax, [esp+43Ch+var_428] ; ip地址不能为空 .text:00403CAF push 30h ; unsigned int .text:00403CB1 push 0 ; char * .text:00403CB3 push eax ; char * .text:00403CB4 mov ecx, esi ; this .text:00403CB6 call ?MessageBoxA@CWnd@@QAEHPBD0I@Z ; 弹框 ip地址不能为空 .text:00403CBB push 3FDh ; int .text:00403CC0 mov ecx, esi ; this .text:00403CC2 call ?GetDlgItem@CWnd@@QBEPAV1@H@Z ; 获取指定ip输入框对象 .text:00403CC7 mov ecx, eax ; this .text:00403CC9 call ?SetFocus@CWnd@@QAEPAV1@XZ ; 设置焦点 .text:00403CCE jmp short loc_403CF0 ; jmp end~ .text:00403CD0 ; --------------------------------------------------------------------------- .text:00403CD0 .text:00403CD0 loc_403CD0: ; CODE XREF: g_set_config+69j .text:00403CD0 ; g_set_config+7Ej .text:00403CD0 lea ecx, [esp+43Ch+phkResult] .text:00403CD4 push ecx ; pHandle .text:00403CD5 push 2001Fh ; Access = KEY_QUERY_VALUE|KEY_SET_VALUE|KEY_CREATE_SUB_KEY|KEY_ENUMERATE_SUB_KEYS|KEY_NOTIFT|20000 .text:00403CDA push 0 ; 0 .text:00403CDC push offset SubKey ; "SOFTWARE\\GoldenSoft\\LanStar 2000 VC\\Client" .text:00403CE1 push 80000002h ; HKEY_LOCAL_MACHINE .text:00403CE6 call ds:RegOpenKeyExA .text:00403CEC test eax, eax ; 返回0成功 否则失败 .text:00403CEE jz short loc_403D1A ; 0则跳 否则结束 .text:00403CF0 .text:00403CF0 loc_403CF0: ; CODE XREF: g_set_config+AEj .text:00403CF0 lea ecx, [esp+43Ch+var_42C] ; this .text:00403CF4 mov byte ptr [esp+43Ch+var_4], 0 .text:00403CFC call ??1CString@@QAE@XZ ; CString::~CString(void) .text:00403D01 lea ecx, [esp+43Ch+var_428] ; this .text:00403D05 mov [esp+43Ch+var_4], 0FFFFFFFFh .text:00403D10 call ??1CString@@QAE@XZ ; CString::~CString(void) .text:00403D15 jmp loc_404224 .text:00403D1A ; --------------------------------------------------------------------------- .text:00403D1A .text:00403D1A loc_403D1A: ; CODE XREF: g_set_config+CEj .text:00403D1A mov eax, [esi+12Ch] ; 无用数据 .text:00403D20 mov ecx, [esp+43Ch+phkResult] ; 获取hkey .text:00403D24 xor edx, edx .text:00403D26 push edi .text:00403D27 mov edi, ds:RegSetValueExA ; 获取设置注册函数地址 .text:00403D2D push 4 ; 数据大小4 .text:00403D2F test eax, eax .text:00403D31 lea eax, [esp+444h+Data] .text:00403D35 push eax ; 数据 .text:00403D36 push 4 ; 数据类型4 REG_DWORD .text:00403D38 push 0 ; 常年为0 .text:00403D3A push offset ValueName ; "AutoLogin" .text:00403D3F setz dl .text:00403D42 push ecx ; hKey .text:00403D43 mov dword ptr [esp+458h+Data], edx .text:00403D47 call edi ; RegSetValueExA ; 设置注册表 在上面得到的那边路径中应该有一项Autologin 类型为整型 将它设为0 .text:00403D49 cmp [esi+12Ch], ebp ; 如果ip格式不对? .text:00403D4F jnz short loc_403D7B ; 跳走 将ip地址对应的十六进制赋0 .text:00403D51 lea ebp, [esi+128h] .text:00403D57 push 100h ; int .text:00403D5C mov ecx, ebp ; this .text:00403D5E call ?GetBuffer@CString@@QAEPADH@Z ; CString::GetBuffer(int) .text:00403D63 push eax ; 指定ip地址字符串192.168.1.1 .text:00403D64 call ds:inet_addr ; 转到到十六进制 .text:00403D6A push 0FFFFFFFFh ; int .text:00403D6C mov ecx, ebp ; this .text:00403D6E mov [esi+168h], eax ; 0x0101a8c0 .text:00403D74 call ?ReleaseBuffer@CString@@QAEXH@Z ; CString::ReleaseBuffer(int) .text:00403D79 jmp short loc_403D85 .text:00403D7B ; --------------------------------------------------------------------------- .text:00403D7B .text:00403D7B loc_403D7B: ; CODE XREF: g_set_config+12Fj .text:00403D7B mov dword ptr [esi+168h], 0 ; 将ip地址对应的十六进制赋0 .text:00403D85 .text:00403D85 loc_403D85: ; CODE XREF: g_set_config+159j .text:00403D85 mov eax, [esi+130h] .text:00403D8B lea ebp, [esi+130h] .text:00403D91 mov edx, [esp+440h+phkResult] .text:00403D95 dec eax .text:00403D96 mov [ebp+0], eax .text:00403D99 lea eax, [esi+168h] .text:00403D9F push 4 ; cbData .text:00403DA1 push eax ; lpData .text:00403DA2 push 4 ; dwType .text:00403DA4 push 0 ; Reserved .text:00403DA6 push offset aTeacherip ; "TeacherIP" .text:00403DAB push edx ; hKey .text:00403DAC call edi ; RegSetValueExA .text:00403DAE mov eax, [esp+440h+phkResult] .text:00403DB2 push 4 ; cbData .text:00403DB4 push ebp ; lpData .text:00403DB5 push 4 ; dwType .text:00403DB7 push 0 ; Reserved .text:00403DB9 push offset aCommindex ; "CommIndex" .text:00403DBE push eax ; hKey .text:00403DBF call edi ; RegSetValueExA .text:00403DC1 mov eax, [esi+154h] .text:00403DC7 lea edx, [esp+440h+var_414] .text:00403DCB push 4 ; cbData .text:00403DCD push edx ; lpData .text:00403DCE lea eax, [eax+eax*4] .text:00403DD1 push 4 ; dwType .text:00403DD3 push 0 ; Reserved .text:00403DD5 push offset aBeginsleep ; "BeginSleep" .text:00403DDA lea eax, [eax+eax*4] .text:00403DDD lea ecx, [eax+eax*4] .text:00403DE0 mov eax, [esp+454h+phkResult] .text:00403DE4 shl ecx, 3 .text:00403DE7 push eax ; hKey .text:00403DE8 mov dword ptr [esp+458h+var_414], ecx .text:00403DEC call edi ; RegSetValueExA /////////////////////////////////////////////////////////////////////////////////////////////////// 大量相同代码 /////////////////////////////////////////////////////////////////////////////////////////////////// .text:0040401E mov eax, [esp+440h+phkResult] .text:00404022 mov ecx, [esi+60h] .text:00404025 lea edx, [esp+440h+Data] .text:00404029 push 4 ; cbData .text:0040402B push edx ; lpData .text:0040402C push 4 ; dwType .text:0040402E push 0 ; Reserved .text:00404030 push offset aCaudiorender ; "CaudioRender" .text:00404035 push eax ; hKey .text:00404036 mov dword ptr [esp+458h+Data], ecx .text:0040403A call edi ; RegSetValueExA .text:0040403C mov ecx, [esp+440h+phkResult] .text:00404040 mov ebx, ds:RegCloseKey .text:00404046 push ecx ; hKey .text:00404047 call ebx ; RegCloseKey .text:00404049 lea edx, [esp+440h+phkResult] .text:0040404D push edx ; phkResult .text:0040404E push 20019h ; samDesired .text:00404053 push 0 ; ulOptions .text:00404055 push offset aSoftwareGold_0 ; "SOFTWARE\\GoldenSoft\\LanStar Settings" .text:0040405A push 80000002h ; hKey .text:0040405F call ds:RegOpenKeyExA .text:00404065 mov ecx, [esp+440h+phkResult] .text:00404069 lea eax, [esi+150h] .text:0040406F push 4 ; cbData .text:00404071 push eax ; lpData .text:00404072 push 4 ; dwType .text:00404074 push 0 ; Reserved .text:00404076 push offset aSoundrender ; "SoundRender" .text:0040407B push ecx ; hKey .text:0040407C call edi ; RegSetValueExA .text:0040407E mov edx, [esp+440h+phkResult] .text:00404082 push edx ; hKey .text:00404083 call ebx ; RegCloseKey .text:00404085 mov eax, [esi+0C8h] .text:0040408B mov edi, ds:SendMessageA .text:00404091 push 0 ; lParam .text:00404093 push 0 ; wParam .text:00404095 push 147h ; Msg .text:0040409A push eax ; hWnd .text:0040409B call edi ; SendMessageA .text:0040409D mov ecx, [esi+0C8h] .text:004040A3 push 0 ; lParam .text:004040A5 push eax ; wParam .text:004040A6 push 150h ; Msg .text:004040AB push ecx ; hWnd .text:004040AC call edi ; SendMessageA .text:004040AE cmp eax, 0FFFFFFFFh .text:004040B1 mov dword ptr [esp+440h+in.S_un], eax .text:004040B5 jnz short loc_4040C5 .text:004040B7 lea edx, [esp+440h+in] .text:004040BB push 0 .text:004040BD push edx .text:004040BE mov ecx, esi .text:004040C0 call sub_405230 .text:004040C5 .text:004040C5 loc_4040C5: ; CODE XREF: g_set_config+495j .text:004040C5 mov eax, dword ptr [esp+440h+in.S_un] .text:004040C9 push eax ; in .text:004040CA call ds:inet_ntoa .text:004040D0 mov edx, eax .text:004040D2 or ecx, 0FFFFFFFFh .text:004040D5 mov edi, edx .text:004040D7 xor eax, eax .text:004040D9 repne scasb .text:004040DB not ecx .text:004040DD dec ecx .text:004040DE push ecx .text:004040DF push edx ; 本机IP .text:004040E0 push offset aHostip ; "HostIP" .text:004040E5 push offset aSoftwareGold_0 ; "SOFTWARE\\GoldenSoft\\LanStar Settings" .text:004040EA push 80000002h .text:004040EF call ds:RegWriteString ; 也是写键的一种方法 .text:004040F5 mov eax, [esi+160h] .text:004040FB add esp, 14h .text:004040FE test eax, eax .text:00404100 jz loc_4041F7 ; 没写入成功就跳走 .text:00404106 lea ecx, [esp+440h+lpWindowName] .text:0040410A call ??0CString@@QAE@XZ ; CString::CString(void) .text:0040410F push 73h ; unsigned int .text:00404111 lea ecx, [esp+444h+lpWindowName] ; this .text:00404115 mov byte ptr [esp+444h+var_4], 2 .text:0040411D call ?LoadStringA@CString@@QAEHI@Z ; CString::LoadStringA(uint) .text:00404122 mov ecx, [esp+440h+lpWindowName] .text:00404126 push ecx ; LanStar 21st Version 5.0 .text:00404127 push 0 ; lpClassName .text:00404129 call ds:FindWindowA ; 找有没有这个窗口 找学生端程序 .text:0040412F test eax, eax .text:00404131 jz loc_4041E6 ; 没找到 跳走结束 .text:00404137 push 0 ; lParam .text:00404139 push 0 ; wParam .text:0040413B push 4E6h ; 关键所在向lanstar发送0x4e6消息 0x4e6消息在windows里面是没有定义的 最大0x400,那这个就是自定义消息 干什么的 很明确了 .text:00404140 push eax ; hWnd .text:00404141 call ds:PostMessageA .text:00404147 push 0 ; int .text:00404149 mov ecx, esi ; this .text:0040414B call ?ShowWindow@CWnd@@QAEHH@Z ; CWnd::ShowWindow(int) .text:00404150 push 0BB8h ; dwMilliseconds .text:00404155 call ds:Sleep ; 等待0xbb8毫秒 .text:0040415B call ?AfxGetModuleState@@YGPAVAFX_MODULE_STATE@@XZ ; AfxGetModuleState(void) .text:00404160 mov eax, [eax+8] .text:00404163 lea edx, [esp+440h+Filename] .text:00404167 push 104h ; nSize .text:0040416C push edx ; lpFilename .text:0040416D push eax ; hModule .text:0040416E call ds:GetModuleFileNameA ; 获得当前进程路径 .text:00404174 lea eax, [esp+440h+Ext] .text:0040417B lea ecx, [esp+440h+var_10C] .text:00404182 push eax ; Ext .text:00404183 lea edx, [esp+444h+Dir] .text:0040418A push ecx ; Filename .text:0040418B lea eax, [esp+448h+Drive] .text:0040418F push edx ; Dir .text:00404190 lea ecx, [esp+44Ch+Filename] .text:00404194 push eax ; Drive .text:00404195 push ecx ; FullPath .text:00404196 call ds:_splitpath ; 分解一个路径 可以的到后缀名 文件名,目录,分区,完整路径 .text:0040419C mov ecx, 41h .text:004041A1 xor eax, eax .text:004041A3 lea edi, [esp+454h+Filename] .text:004041A7 push offset Ext ; "exe" .text:004041AC rep stosd .text:004041AE lea edx, [esp+458h+Dir] .text:004041B5 push offset Filename ; "lanclt" .text:004041BA lea eax, [esp+45Ch+Drive] .text:004041BE push edx ; Dir .text:004041BF lea ecx, [esp+460h+Filename] .text:004041C3 push eax ; Drive .text:004041C4 push ecx ; Path .text:004041C5 call ds:_makepath ; 组成一个完整路径 上面的代码将路径的文件名改为了lanstar .text:004041CB add esp, 28h .text:004041CE lea edx, [esp+440h+Filename] .text:004041D2 push 5 ; nShowCmd .text:004041D4 push 0 ; lpDirectory .text:004041D6 push 0 ; lpParameters .text:004041D8 push edx ; 也就是C:\Program Files\GoldenSoft\LanStar 8.0\lanclt.exe .text:004041D9 push offset Operation ; "open" .text:004041DE push 0 ; hwnd .text:004041E0 call ds:ShellExecuteA ; 执行这个程序 下面就是释放一些资源 .text:004041E6 .text:004041E6 loc_4041E6: ; CODE XREF: g_set_config+511j .text:004041E6 lea ecx, [esp+440h+lpWindowName] ; this .text:004041EA mov byte ptr [esp+440h+var_4], 1 .text:004041F2 call ??1CString@@QAE@XZ ; CString::~CString(void) .text:004041F7 .text:004041F7 loc_4041F7: ; CODE XREF: g_set_config+4E0j .text:004041F7 mov ecx, esi ; this .text:004041F9 call ?OnOK@CDialog@@MAEXXZ ; CDialog::OnOK(void) .text:004041FE lea ecx, [esp+440h+var_42C] ; this .text:00404202 mov byte ptr [esp+440h+var_4], 0 .text:0040420A call ??1CString@@QAE@XZ ; CString::~CString(void) .text:0040420F lea ecx, [esp+440h+var_428] ; this .text:00404213 mov [esp+440h+var_4], 0FFFFFFFFh .text:0040421E call ??1CString@@QAE@XZ ; CString::~CString(void) .text:00404223 pop edi .text:00404224 .text:00404224 loc_404224: ; CODE XREF: g_set_config+F5j .text:00404224 mov ecx, [esp+43Ch+var_C] .text:0040422B pop esi .text:0040422C pop ebp .text:0040422D pop ebx .text:0040422E mov large fs:0, ecx .text:00404235 add esp, 430h .text:0040423B retn .text:0040423B g_set_config endp
1.做的事情是将用户输入的信息写入注册表
2.向学生端发送一个0x4e6自定义消息关闭它
3.执行学生端(使配置生效)
伪代码:
int __thiscall g_set_config(CWnd *this) { CWnd::UpdateData(this, 1); //说下m_auto_login 这个用于保存是否自动登录 //不知道写这个代码的人怎么想的,为1是 指定ip地址登录 不太好理解 if ( m_auto_login == 1 && !mbscmp(m_student_ip, "") )//如果 是指定ip登陆 但 ip地址为空 出错 { AfxMessageBox("ip地址不能为空!") CWnd* m_edit_sdt_ip = CWnd::GetDlgItem(this, 1021);//1021应该是指定ip地址框的控件ID CWnd::SetFocus(m_edit_sdt_ip);//设置焦点 return 0; } if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\GoldenSoft\\LanStar 2000 VC\\Client" , 0, KEY_QUERY_VALUE|KEY_SET_VALUE|KEY_CREATE_SUB_KEY|KEY_ENUMERATE_SUB_KEYS|KEY_NOTIFT|20000, &phkResult) ) { //如果打开失败 直接返回 return 0; } //注册表中的AutoLogin项记录了是自动登录还是指定ip登录 //这里是写入这个值 Data = m_auto_login ; RegSetValueExA(phkResult, "AutoLogin" 0, 4, Data, 4); //如果是指定IP地址登陆 将内容转换为十六进制 否则为0 if ( m_auto_login == 1 ) { CWnd *tmp_ed_sdt_ip = CString::GetBuffer((CWnd *)(m_edit_sdt_ip), 256); //m_dw_student_ip是用于保存指定ip地址转换后的十六进制 m_dw_student_ip = inet_addr(tmp_ed_sdt_ip); } else { m_dw_student_ip = 0; } RegSetValueExA(phkResult, "TeacherIp", 0, 4,m_dw_student_ip, 4); RegSetValueExA(phkResult, "CommIndex", 0, 4, 0, 4); RegSetValueExA(phkResult, "BeginSleep", 0, 4, 0, 4); //........................................................... //...........省略大量相同代码................ //........................................................... //获取Combo Box 当前选中列 CB_GETCURSEL 147 DWORD cm_cur_sel = SendMessageA(m_CommboBox_host, 0x147, 0, 0); //CB_GETITEMDATA 150 //获取列表项的附加数据 DWORD host_ip = (struct in_addr)SendMessageA(m_CommboBox_host, 0x150, cm_cur_sel , 0); if ( host_ip == -1 )//Combo Box没有选中 就由程序自己获取本机IP { GetHostIp(&host_ip, 0);//这个未实现,功能是获取本机IP地址 } CString str_host_ip = inet_ntoa(host_ip); RegWriteString(0x80000002, "SOFTWARE\\GoldenSoft\\LanStar Settings", "HostIp", str_host_ip, strlen(str_host_ip)); if ( UnKnow )//这个判断暂时不清楚,不过常年为1 { DWORD hwnd_lanstar = FindWindowA(0, "LanStar 21st Version 5.0"); if ( hwnd_lanstar ) { //先关闭学生端 //关键所在:向lanstar.exe发送0x4e6消息 0x4e6消息在windows里面是没有定义的 最大0x400,那这个就是自定义消息 干什么的 很明确了 PostMessageA(hwnd_lanstar , 0x4E6, 0, 0); CWnd::ShowWindow(this, 0); Sleep(3000); //获取当前路径 C:\Program Files\GoldenSoft\LanStar 8.0\LanSet.exe CWnd* m_pModuleState = AfxGetModuleState(); GetModuleFileNameA(*((HMODULE *)m_pModuleState + 2), &Filename, 0x104); //拼接C:\Program Files\GoldenSoft\LanStar 8.0\lanclt.exe splitpath(&Filename, &Drive, &Dir, &v42, &Ext); memset(&Filename, 0, 0x104); //得到C:\Program Files\GoldenSoft\LanStar 8.0\lanclt.exe makepath(&Filename, &Drive, &Dir, ::Filename, ::Ext); //执行C:\Program Files\GoldenSoft\LanStar 8.0\lanclt.exe ShellExecuteA(0, Operation, &Filename, 0, 0, 5); } } return CDialog::OnOK(this); }
我本计划使用一些进程保护的方法来保护它,现在看来,得增加一些措施了.
菊花太大啊~~~
#include <stdio.h> #include <Windows.h> void main() { //LanStar 21st Version 5.0 HWND hwnd = FindWindowA(NULL,"LanStar 21st Version 5.0"); if(hwnd) { printf("input any key kill LanStar!\n"); getchar(); PostMessageA(hwnd,0x4e6,0,0); printf("Kill LanStar Success!\n"); Sleep(1000); }else { printf("No_Found_LanStar!\n"); getchar(); } }