Wednesday, April 22, 2009
Thiên thần ngủ yên!
...
Mẹ ơi đừng khóc
Ba ơi đừng buồn
Con muốn thấy Ba Mẹ cười
Như lúc con đang ở bên
...
Thursday, April 02, 2009
The old tool that helps: access server console with conserver
Conserver gồm 2 thành phần (xem tài liệu hướng dẫn chi tiết: http://www.conserver.com/consoles/Training/published.html):
- Server (conserver): chạy trên máy kết nối với thiết bị console (vd cổng serial) hoặc nối tới Terminal server (thiết bị mắc tiền - vd như Digiport, Cylades). Server mặc định listen trên port 782/tcp để client kết nối tới
- Client (console): chạy trên máy client bất kỳ, kết nối tới server qua mạng IP, sau đó gắn vào một trong các console để điều khiển
--- /etc/conserver.cf ---
default tty {
type device;
baud 9600;
parity none;
protocol raw;
}
default * {
logfile /var/log/consoles/&; # '&' is replaced with console name
timestamp 1ha; # write timestamps
rw *; # allow all users
master localhost; # this server
}
console sun1 {
device /dev/ttyS0; motd "SUN server 01 console";
include tty;
}
access * {
trusted 127.0.0.1;
trusted 192.168.1.0/24;
}
--- end of /etc/conserver.cf ---
- Phía server: start conserver
# /etc/init.d/conserver start - Phía client: chạy console để kết nối tới server
liệt kê các console trên server và xem trạng thái của chúng:$ console -M <server_name/ip> -u
kết nối tới console của Sun server 01:
$ console -M 192.168.0.1 -u
sun1 up <none>$ console -M 192.168.0.1 sun1
kết thúc phiên làm việc và ngắt kết nối:
[Enter `^Ec?' for help]
[-- MOTD -- SUN server 01 console]
server01 console login:Nhấn phím chuỗi phím: Ctrl+E, c, . (^Ec.)
Lưu ý: nếu muốn "phức tạp" hơn thì xem thêm phần thiết lập quyền access cho user/goup, đặt mật khẩu, cấu hình cho nhiều server dạng phân bố, ...
Monday, September 08, 2008
CTF trick: fool replay attack with one time (based) shellcode
Giang hồ hiểm ác, biết đâu bọn chúng dùng chiêu của mình mà lại đánh thắng mình, tốt nhất là diệt trừ mọi hậu họa. Tuy nhiên, việc chống replay attack là khá khó khăn do: a) kêt nối mạng client - server không có mã hóa; b) không thể chủ động ở phía server do đối phương nắm giữ. Nếu chiếm được chủ động phía server, có khả năng chống được replay attack. Trong trường hợp đó, một chiến thuật để chống lại chiêu "tá lực đả lực" là: mã khai thác (exploit code) chỉ sử dụng được một lần, không thể replay dựa theo thời gian trên server. Theo cách này mã khai thác lỗi chỉ chạy đúng (valid) trong một khoảng thời gian xác định (ví dụ trong vòng 30 giây kể từ lúc được chạy lần đầu), thời gian này được xác định theo server bị khai thác do đó nếu được capture rồi replay lại sẽ không ra được kết quả. Việc tại tạo lại mã khai thác từ luồng dữ liệu (data stream) bắt được để dò ra lỗi sẽ mất thời gian hơn nhiều.
Mã khai thác lỗi ban đầu:
exploit = [padding] + [shellcode]
Mã khai thác lỗi dùng một lần:
exploit = [new padding] + [time check code] + [shellcode]
Mã giả (pseudo code) phần kiểm tra theo thời gian đơn giản như sau:
t = time(NULL); // predefined time value = when the exploit code is built and run
// shellcode
current_time = time(NULL);
if (current_time > t)
if(current_time < t + 30)
shellcode();
Mã khai thác lỗi ở mỗi lần chạy khác nhau sẽ có giá trị "t" khác nhau theo thời gian. Tuy nhiên phần mã này là tĩnh và có thể bị phát hiện khi so sánh hai lần chạy khác nhau. Một cách để tránh bị phát hiện là mã hóa mã khai thác lỗi theo cách khác nhau qua mỗi lần chạy. Với chiêu này, ta có thể chiếm phần tiện nghi hơn các đối thủ một chút, đôi khiến chúng phải bứt đầu bứt tóc để dò tìm tại sao chiêu "tá lực đả lực" lại vô hiệu :D.
Lưu ý/Hạn chế:
- Phải có khả năng khai thác lỗi để thực thi được trên server đối phương (khi đó mới gọi time() được)
- Buffer đủ lớn để thêm phần mã kiểm tra (16+ bytes)
- Đồng hồ trên server đối phương không chạy sai (kiểm tra được)
Sunday, August 17, 2008
Defcon 16 CTF
- Sk3wl0fr00t
- Routards
- 1@stPlace
- Taekwon-V
- Guard@MyLan0
- Shellphish
- Pandas with Gambas
- WOWHACKER
Saturday, February 23, 2008
Analyzing Nessus HTML report with Excel
- Xử lý HTML report để lọc ra phần chi tiết các kết quả scan
- Import dữ liệu vào Excel
- Tạo Pivot Table Report, kết quả sẽ như hình dưới
Kết quả của Pivot Table report cũng giúp ích nhiều cho việc vá các lỗ hổng, chỉ cần double-click vào một ô kết quả một sheet mới sẽ tự động được tạo với tất cả thông tin chi tiết. DataPilot của OpenOffice Calc có thể làm được Pivot table report nhưng không có "chiêu" double-click lợi hại này của Excel.
Friday, February 15, 2008
The power of fusesmb
Cấu hình file ~/.smb/fusesmb.conf:
; Global settings
[global]
; Default username and password
username=user
password=totallysecret
; Connection timeout in seconds
timeout = 10
Cấu hình file ~/.smb/fusesmb.conf
Chạy fusesmb để tự động mount các shares khi được truy xuất đến:
$ fusesmb ~/shares
Truy cập các shares theo dạng
Lưu ý:
- Password được lưu ở dạng cleartext
- Chương trình fusesmb-cache sẽ tự động quét toàn bộ Windows domain để lấy về tất cả các shares trên tất cả các servers trong mạng. Việc này rất mất thời gian lúc ban đầu, tốn resource về sau và khiến truy xuất các shares chậm. Có thể bỏ qua quá trình này bằng "mánh" sau:
- Dùng smbclient lấy tên các shares trên server cần truy xuất
- Thêm vào file ~/.smb/fusesmb.cache, theo dạng DOMAIN/SERVER/SHARE, ví dụ:
MYCONPANY/192.168.1.10/Upload - Xóa quyền ghi trên file ~/.smb/fusesmb.cache để chương trình tự động cập nhật không ghi đè được
- Tiện lợi nhưng bù lại performance không được cao bằng cách mount cifs trực tiếp (test bằng lệnh find hoặc dd)
Monday, September 17, 2007
HITB 2007 CTF report
[Original link from vnSecurity]
We decided to join HITB 2007 CTF in Kualar Lumpur just after the VNSECON '07 in August. Our team, Sao Vang from vnSecurity, is the last (10th) team registered, and we had only 1 month to prepare for the competition. It's unbelievable that we win the game!
Day 1 - 05/09
The game, which had been planned to start at 10:30 AM, was delayed because the organizer had not completed setting it up. Teams had to find something fun to do while waiting. We sat on the ground playing bzflag. Other guys checked email, or set up the hardware. We felt a bit nervous because there was only one network cable on each team's table and other teams brought their own switch.
Finally, CTF crew announced the game would start at 2:00 PM. At 2:45pm, it really started. While the crew setting up vmware images (Gentoo 2007 hardened) for teams' servers, some guys looked over their shoulders and captured (guessed) the root's password. It's a bad password (qwe123). We got it too ;).
The organizer sent out crackme1 for Windows and the main switch would only be plumbed after it had been cracked. I changed our root's password, copied the vmware image for backup, tried to upload the tools to server with USB HDD, and ran the defense script while lamer and sieukhung were cracking the binary on their laptop. They took it down only within 20 minutes!
Then the game really started. The organizer announced the root password to all teams. Before that, one team (perhaps Qb1t?) had used it to accessed other servers, installed backdoor user (lalala?) and unwisely changed their root passwords. The organizer identified and removed it easily. We had also prepared a script just for this situation. Had we run install_backdoor script (silently, without changing root password), we could have owned most of the boxes. But then, where is the fun?
All teams started looking at the vulnerability daemons (01 to 08) and defending their servers. Some teams chown'd all the flags so that no other team could get it, even the score server ;-). There was glitches in the score server. Only Sao Vang got positive defensive score while the rest got negative. After crackme1 was done, the organizer sent out crackme2 binary. By the end of day 1, no daemon was exploited and we earned 350 bonus points for crackme1.
There was not much to say about day 1 because it just happened in less than 3 hours. We managed to crack crackme1 and identified the vulnerabilities in some daemons. Our dreaded vmware host running on WinXP hang 2 times and continued to hang 3 or 4 times on day 2.
Day 1.5
We got back to our place and continued the job overnight. crackme2 (md5 crack) was solved first by sieukhung. Then, we found the vuln in daemon05 (trivial buffer overflow; shamelessly, we weren't successful in exploiting it remotely) and daemon07 (trivial format string) but there were "bugs" that made them un-exploitable. After few hours, we could exploit daemon02 (vtable overwrite) and daemon04 (buffer overflow with multithreaded complication). We went to bed (and sofa ;)) at 4:30 AM and woke up at 7:30 AM. Crazyyy!
The next morning, while waiting for taxi, lamer managed to exploit daemon01 (reverse crc32 and buffer overflow). All of our exploits were coded by lamer with his excellent Python framework.
Day 2 - 06/09
The game started at 11:00 AM and ran smoothly.
It was more exciting on day 2. We continued to lead from the beginning by submitting crackme2 and getting flags from other servers. The organizer also sent out fixed binaries for daemon05 and daemon07.
After 2 hours, we raked in lots of points for captured flags from daemon 1, 2, 4, and 7. According to the detail score log, we should have gained breakthrough points for 5 daemons (daemon08 later) instead of 4 as displayed on the official score board and Padocon (from Korea) would have had no breakthrough. We guessed they just replayed our exploits. And maybe other teams did the same too. We raked in more than 3000 points while the next closest team 700.
After that, we settled down to work on daemon 3, 6 and 8. At 2:00 PM, the organizer sent out crackme3 and source code of daemon08. sieukhung cracked crackme3 in half an hour and we earned many bonus points (800). Right after that, lamer finished his work on daemon08 and we got breakthrough for it. We decided to take a break and have lunch with McDonald hamburgers (thanks BlueMood, and Valmont for your support). We intended to give up daemon 3 and 6 to play bzflag (hey, they had a crowded bzflag server there) till the game ended.
But WsLabi (from Switzerland) managed to decode daemon03 and got breakthrough for it. They also ran exploits for other daemons and earned many offensive points. We felt their hot breath when their offensive score was just one flag behind us. I thought there was something wrong with our exploits and reviewed them. We found out that exploit for daemon04 was stuck by blocking socket behavior. We changed it and got more points.
Team Army Strong had best defensive score at that time and it seemed like we could not get valid flags from them. When trying to run exploit for daemon08 against Army Strong, I found that the first byte of the flag changed from time to time. It inspired us to write a brute force script to submit score to the server and with just a few Python loops we successfully captured their flag (thank you Army Strong for this inspration ;)).
Some of our exploits were not really stable (e.g. daemon07), flag data sometimes were 40 bytes or more instead of 20 bytes (fixed flag's length). We modified the above brute force script to submit flag in any size and raked in more points. By 4:30 PM the organizer set new flags for some daemons (they set new flags only 1 time on day 2) and we easily gained more offensive points with our scripts.
When there was only 30 minutes left, the organizer announced bonus points for crackmes' and daemons' exploits write-ups (brief). It was quite rush. We decided to shutdown the server because score server did not check for defensive things anymore and focus on write-ups. We submitted write-ups for all challenges we solved and got more than 1000 bonus points.
Finally, we won the 1st place with a total of 8900 points, with best offensive (5280), second-best defensive (510) and highest bonus (3110). WsLabi won the 2nd place with a total of 5540 points and Padocon came next with 3165.
Conclusion
- The CTF this year was very interesting and attracted a lot of people (though it started late as normal)
- Some teams had more than 3 players (4 to 6) and played in turn. It is more fun this way.
- Best defensive strategy is to keep the daemons running and modify nothing.
- Because defensive score is far lower than offensive score, "good" defensive strategy is to remove read permission from flags so that no other team can get it. "Best" defensive strategy is to follow Army Strong.
- Capturing then replaying is a good offensive strategy and can help team win if they do it effectively.
- python rox!
- Team must plan and prepare well to have good result.
References
- spoonfork's write up
- xwings' report
- WsLabi's write up for daemon03
- lamer's write up for daemon01, daemon05, and daemon07
- http://ctf2007.security.org.my/
Credits
To all vnSecurity members
More detailed write ups will be posted at http://www.vnsecurity.net.
