Linux怎么进行网络安装?,第1张

Linux网络安装全过程(安装fedora)

先来大概说一下网络安装linux的基本原理。我们是通过PXE(Pre-boot Execution Environment)(其实是intel设计的一个协议)来进行安装的,它可以使计算机通过网络启动。PXE协议分为server和client端,client就是我们即将要装linux的裸机。 linux下网络安装需具备3个条件:

1dhcp服务器:用于客户端引导时分配IP地址

2ftp、nfs、httpd服务器:用于保存操作系统的rpm包 3tftp服务器:用于客户端的tftp引导。 我的方案是DHCP+NFS+TFTP 方案介绍:

这种方案需要首先设置一个启动服务器和一个安装服务器,可以配置在同一台机器上,然后通过网络启动存放在启动服务器上的安装程序。安装程序会自动访问存放在安装服务器上的安装配置文件和安装介质来完成安装。 软硬件需求: · 一台机器作为启动和安装服务器(虚拟机A) · 待安装的机器,它的网卡必须带有PXE支持(虚拟机B) · 一个完好的局域网,机器已经连入同一网。 · 系统镜像文件

配置步骤:

一、DHCP服务器

1、 安装DHCP

[root@localhost ~]# rpm -qa|grep dhcp ;查看是否安装了 dhcp libdhcp6client-1022-1fc10i386 libdhcp-1998-1fc10i386

dhcp-400-37fc10i386 ;若没有此包,则需用yum install dhcp来安装 libdhcp4client-400-30fc10i386 dhcpv6-client-1022-1fc10i386 2、 配置DHCP

DHCP服务的配置文件是/etc/dhcpdconf,通过修改配置文件进行配置,分两步:一是加入黑体部分,二是修改配置地址。

注:初始安装时/etc/dhcpdconf配置文件为空,此时可以新建一个直接进行编辑。有个DHCP的配置例子为/usr/share/doc/dhcp-400/dhcpdconfsample。

[root@localhost /]# cd /etc

[root@localhost etc]# vim dhcpdconf # DHCP Server Configuration file

# see /usr/share/doc/dhcp/dhcpdconfsample ddns-update-style interim; ignore client-updates; allow booting; allow bootp;

必须与本机是同一网段

subnet 1921681860 netmask 2552552550 {

option routers

192168186135; 本机地址

#路由器地址

option subnet-mask

2552552550;

#子网掩码

option domain-name-servers

192168186135;

#DNS地址

option time-offset

-18000; # Eastern Standard Time

range dynamic-bootp 1921681862 192168186100;

filename "/linux-install/pxelinux0"; #

filename 后面是tftp目录下的文件,用来指定tftp根目录的启动文件。也可以直接写成

/pxelinux0,具体由自己设定

default-lease-time 21600;

#缺省租约时间

max-lease-time 43200;

#最大租约时间

}

[root@localhost ~]# ifconfig eth0 192 168 186135/24

配置地址

[root@localhost etc]# ifconfig ;查本机IP地址。

eth0

Link encap:Ethernet

HWaddr 00:0C:29:26:AC:57

inet addr:192168186135

Bcast:192168186255

Mask:2552552550

注意若要指定给某一特定主机分配地址,需再加入些东西,以下是一个例子

host MyP5 {

filename "pxelinux0";

server-name "bootserver";

hardware ethernet ae:32:20:00:b0:02;

fixed-address 19216818790;

为客户机(需要安装系统的机器)的 MAC 地址和所分配的IP地址。}

3、开启服务(开启成功则表示配置成功了)

[root@localhost etc]# service dhcpd start

(或者重启restart)

启动dhcpd:[确定]

使用

/etc/initd/dhcpd start

也可以(在/etc/initd下即可找到相应的服务service)

二、

NFS服务器

1、安装

NFS

[root@localhost /]# rpm -qa |grep nfs

nfs-utils-lib-114-1fc10i386

nfs-utils-114-1fc10i386

system-config-nfs-1341-1fc10noarch

查询是否已安装,否则使用

yum install nfs

进行安装。

2

、配置NFS

[root@localhost /]# mkdir /linuxos

(建立各个版本ISO文件的存放目录,并且将ISO文件拷贝到此目录下,NFS支持iso格式安装。)

[root@localhost /]# mkdir tftpboot

[root@localhost /]# cd tftpboot/

[root@localhost tftpboot]# mkdir linux-install

[root@localhost /]# vim /etc/exports ;配置文件

/mnt (ro,sync) ;(mnt为NFS的目录,用来存放操作系统。此处选/mnt是因为

其是挂载光盘的挂载点)

/tftpboot/linux-install (ro,sync) 3、启动NFS

[root@localhost tftpboot]# exportfs –a ;使用此命令使配置生效 [root@localhost /]# service nfs start(或restart)

启动 NFS 服务: [确定] 关掉 NFS 配额: [确定] 启动 NFS 守护进程: [确定] 启动 NFS mountd: [确定]

三、TFTP服务器

1、安装TFTP

[root@localhost /]# rpm -qa |grep tftp

tftp-049-1fc10i386 ;这个只是tftp客户端软件

tftp-server-049-1fc10i386 ;这个才是tftp服务器软件(必不可少) 若没有则需使用yum下载。 [root@localhost /]# yum install tftp

[root@localhost /]# yum install tftp-server 2、配置TFTP

[root@localhost initd]# vim /etc/xinetdd/tftp ;配置文件 service tftp {

disable = no

socket_type = dgram protocol = udp wait = yes user = root

server = /usr/sbin/intftpd

server_args = -s /tftpboot ;将 /tftpboot 定义为 tftp 服务的默认目录,您可以自行修改。 per_source = 11 cps = 100 2 flags = IPv4 }

3、保存之后重启 /etc/initd/xinetd 服务,即可开启 tftp 服务。(注意此服务service不识别)

[root@localhost /]# /etc/initd/xinetd restart

停止 xinetd: [确定] 启动 xinetd:

[确定] 4、 测试tftp (1)下载文件

FTP和TFTP是我们经常使用的文件传输协议。在Linux中,sftp协议由于其安全性的优点,被作为默认的链接协议。但是,一些场合下,我们依然需要使用ftp和tftp协议进行文件传输。本篇主要介绍配置方法,供有需要的朋友待查。

1、 环境准备

我们选择Linux 26内核进行测试。

[root@SimpleLinuxUp ~]# uname -r

2618-128el5

当前OS运行在level 3模式下。

[root@SimpleLinuxUp ~]# grep init /etc/inittab

# inittab This file describes how the INIT process should set up

# 0 - halt (Do NOT set initdefault to this)

# 6 - reboot (Do NOT set initdefault to this)

id:3:initdefault:

# System initialization

si::sysinit:/etc/rcd/rcsysinit

默认情况下,tftp服务器包是安装上的,而FTP服务器没有安装。

[root@SimpleLinuxUp Server]# rpm -qa | grep ftp

tftp-server-042-31

ftp-017-35el5

lftp-351-2fc6

2、TFTP服务器安装配置

TFTP是一种比较特殊的文件传输协议。相对于FTP和目前经常使用的SFTP,TFTP是基于TCP/IP协议簇,用于进行简单文件传输,提供简单、低开销的传输服务。TFTP的端口设置为69。

相对于常见的FTP,TFTP有两个比较好的优势:

ü TFTP基于UDP协议,如果环境中没有TCP协议,是比较合适的;

ü TFTP执行和代码占用内存量比较小;

默认情况下,Linux内部是安装了tftp服务器包的。但是默认是不启动的。

[root@SimpleLinuxUp ~]# chkconfig --list tftp

tftp off

启用和禁用tftp服务是通过配置文件/etc/xinetdd/tftp,将其中参数设置。

[root@SimpleLinuxUp ~]# vi /etc/xinetdd/tftp

# default: off

# description: The tftp server serves files using the trivial file transfer \

# protocol The tftp protocol is often used to boot diskless \

# workstations, download configuration files to network-aware printers, \

# and to start the installation process for some operating systems

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/intftpd

server_args = -s /tftpboot -c

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

配置文件中,将disable默认值从yes改为no。适当修改server_args参数,主要是其中的tftp根目录地址。

Tftp服务是不需要单独启动的,是作为xinetd服务的一个附属对象连带启动。

[root@SimpleLinuxUp ~]# service xinetd status

xinetd (pid 2194) is running

[root@SimpleLinuxUp ~]# cd /

[root@SimpleLinuxUp /]# mkdir /tftpboot

mkdir: cannot create directory `/tftpboot': File exists

[root@SimpleLinuxUp /]# cd /tftpboot/

[root@SimpleLinuxUp tftpboot]# cd

[root@SimpleLinuxUp /]# chmod -R 777 /tftpboot/

由于连接使用UDP端口,我们将防火墙和SELinux配置关闭。

[root@SimpleLinuxUp /]# service iptables stop

[root@SimpleLinuxUp /]# service iptables status

Firewall is stopped

对xinetd服务重启,连带将tftp服务启动。

[root@SimpleLinuxUp /]# service xinetd restart

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]

[root@SimpleLinuxUp /]# chkconfig --list tftp

tftp on

使用netstat判断UDP端口开启。

[root@SimpleLinuxUp /]# netstat -nlp | grep udp

udp 0 0 0000:772 0000: 1868/rpcstatd

udp 0 0 0000:775 0000: 1868/rpcstatd

udp 0 0 0000:69 0000: 3869/xinetd

(篇幅原因,有省略……)

从远程服务器启动连接,笔者从windows环境客户端启动。TFTP是可以不输入用户名和密码的,所以对于安全文件传输是不满足的。

C:\Documents and Settings\liuzy>tftp

Transfers files to and from a remote computer running the TFTP service

TFTP [-i] host [GET | PUT] source [destination]

-i Specifies binary image transfer mode (also called

octet) In binary image mode the file is moved

literally, byte by byte Use this mode when

transferring binary files

host Specifies the local or remote host

GET Transfers the file destination on the remote host to

the file source on the local host

PUT Transfers the file source on the local host to

the file destination on the remote host

source Specifies the file to transfer

destination Specifies where to transfer the file

测试客户端与服务器根目录之间的文件互相拷贝传输。

C:\Documents and Settings\liuzy>tftp 1921680100 put cogtrwinini

Transfer successful: 536 bytes in 1 second, 536 bytes/s

[root@SimpleLinuxUp tftpboot]# ls -l

total 12

-rw-rw-rw- 1 nobody nobody 507 Jan 28 10:39 cogtrwinini

drwxrwxrwx 4 root root 4096 Dec 26 09:46 linux-install

D:\>tftp 1921680100 get cogtrwinini

Transfer successful: 536 bytes in 1 second, 536 bytes/s

TFTP是一种简单的文件传输解决方案。

3、FTP配置

目前成熟系统设计中,都将FTP协议和传输定性为非安全传输协议。它和telnet登录方式,逐渐为SFTP和SSH协议所取代。在Linux流行版本中,SFTP已经成为默认配置项目。

在Linux发行版的光盘中,已经包括了vsftp服务器安装包,是需要手工安装。

Tftp安装使用全接触

发表日期:2004年10月8日

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

菜鸟A通过时下比较流行的webdav漏洞进行溢出攻击得到了一个shell,但是在加了管理员帐户后他却发现发现建立了管理员帐户之后却不能ipc$连接,在cmd下又不能开启ipc$,提示启动错误。那么怎么上传文件呢?菜鸟听人说过可以用ftp,但是由于cmd环境下ftp是不能实现交互的,所以这样反而会害了人,输入ftp后,cmd停在那里不动了?菜鸟傻眼了;也有人说是用echo命令写一个从指定ftp下载程序的文件,然后通过ftp –s:file命令来下载,这个通过实践是可行的,但是菜鸟又觉得有点麻烦。怎么办?

这时,一个声音在耳边响起:用tftp吧,给你快乐。Tftp?!@#$^&,菜鸟想了一会,不得其解。听说过ftp,那tftp又是什么呢?那么今天我就给菜鸟们讲解下它的安装使用过程以及在入侵中的作用和自己的心得体会。

一 TFTP简介:

Tftp是Trivial File Transfer Protocol的简称,翻译为简单文件传输协议,它是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,虽然功能有点少,但是在我们的入侵中帮助还是很大的。

Tftp与Win2K自带的Ftp服务器和目前流行的Serv-u所不同的是Tftp是承载在UDP端口;与Ftp相比,TFTP的大小要小的多;缺陷是它提供的数据流传输服务是不可靠的,它不提供存取授权与认证机制,使用超时重传方式来保证数据的到达,使用的是UDP 69端口。但是由于它采用的是UDP端口,很容易摆脱防火墙的限制和IP安全策略对端口的审核,可以在入侵的时候灵活的使用,这也就是我向大家介绍它的原因了。

二:TFTP服务的开启:

也许你还记得经典的unicode漏洞,利用这个漏洞可以在浏览器里执行命令,可以通过tftp上传idqdll,然后结合ispcexe来获取管理员权限。但是你知道tftp服务器不是很容易找的,但是话又说回来了,既然Tftpexe是微软自带的一个比较可爱的小工具,那么我们就可以利用它来做点事,为肉鸡开启Tftp服务,那就不用愁着找不到tftp服务器了。我们可以在Win2k的Winnt\system32下找到Tftpexe,还可以在WINNT\system32\dllcache下找到Tftpexe。当然你可以在命令行下输入:dir %windir%\tftp /s(表示在%windir%目录所有子目录搜索tftp前缀程序)。我的机子反馈的信息是这样的:

驱动器 C 中的卷没有标签。卷的序列号是 287C-D610

C:\WINNT\system32 的目录

2002-07-22 12:05 17,680 tftpexe

1 个文件 17,680 字节

C:\WINNT\system32\dllcache 的目录

2002-07-22 12:05 17,680 tftpexe

2001-08-22 08:00 19,728 tftpdexe

2 个文件 37,408 字节

大家也看到了,这里出现了一个Tftpdexe程序,没有错,它是tftp服务器的服务端程序。怎么开启肉鸡的tftp服务呢,双击运行?-install?这里我们需要ResourceKit里的一个工具instsrvexe把tftp安装为服务,instsrv是命令行下的工具,srvinstwexe是它的gui版本,看图

1:我们来看它的说明:

C:\Longker>instsrvexe

Installs and removes system services from NT

INSTSRV <service name> (<exe location> | REMOVE) [-a <Account Name>] [-p <Account Password>]

Install service example:

INSTSRV MyService C:\MyDir\DiskServiceExe

-OR-

INSTSRV MyService C:\mailsrv\mailsrvexe -a MYDOMAIN\joebob -p foo

Remove service example:

INSTSRV MyService REMOVE

那我们就把tftp安装为服务:

C:\Longker>instsrv "Tftp services" c:\winnt\system32\dllcache\tftpdexe

The service was successfuly added!

Make sure that you go into the Control Panel and use

the Services applet to change the Account Name and

Password that this newly installed service will use

for its Security Context

就这样,我们把tftp服务安装上了,服务名是Tftp services,下面来启动它:

C:\Longker>net start "tftp services"

Tftp services 服务正在启动。

Tftp services 服务已经启动成功。

OK,服务已经启动成功了,我们可以用fport来查看端口开启的情况:

1524 tftpd -> 69 UDP c:\winnt\system32\dllcache\tftpdexe

看到了,它是采用UDP协议来进行文件传输的,开启的端口是69。

或者我们可以用以下命令来查询:

C:\Longker >netstat -an |find "69"

netstat -an |find "69"

UDP 202xxxx165:69 :

服务启动成功后,会在系统跟目录下生成tftpdroot文件夹,我们上传和提供下载的文件就放在这里。

这里有一个很好的Tftp服务器推荐给大家,有日志记录和目录设定功能,还显示传输进度,最重要的是它是免费的,而且可以在多个平台使用

下载地址http://5ihackvicpnet:88/down/showaspid=219

三:如何使用Tftp:

TFTP 自带的帮助信息:

TFTP [-i] host [GET | PUT] source [destination]

-i Specifies binary image transfer mode (also called

octet) In binary image mode the file is moved

literally, byte by byte Use this mode when transferring binary files

host Specifies the local or remote host

GET Transfers the file destination on the remote host to

the file source on the local host

PUT Transfers the file source on the local host to

the file destination on the remote host

source Specifies the file to transfer

destination Specifies where to transfer the file

说明:

-i选项是以二进制模式传送文件,很多Exploit代码就需要用这种模式来传送。

Host是开启了tftp服务的主机,可以是本地主机也可以是远程主机。

get就是到当前运行的目录里面下载,而put就是把文件上传到了开了tftp服务的机子。Source是你要上传或者是下载的文件名称。

下面举几个列子:

C:\Longker>tftp -i 202xxxx165 get scexe

tftp -i 202xxxx165 get scexe

Transfer successful: 63248 bytes in 1 second, 63248 bytes/s

这个是从开了tftp服务的主机下载scexe程序,速度不错吧 :)

C:\Longker>tftp -i 202xxxx165 put scexe

tftp -i 202xxxx165 put scexe

Transfer successful: 63248 bytes in 1 second, 63248 bytes/s

上面是把scexe上传到tftp服务器。

四:相关问题解答:

由于tftp是微软自带的,所以我们入侵了一台机子后,可以使用它来上传我们所要用到的工具,而不用下载其他的工具了。那么刚才菜鸟的问题也就迎刃而解了,我们可以用tftp下载我们需要的工具,或者是只用tftp下载wgetexe(一个可以从web服务器下载程序的小型工具),然后用wget下载自己实现准备好的工具包。

前面的问题是解决了,但是或许菜鸟还会遇到些问题,比如要把上传的文件删除的时候却出现了错误提示:拒绝访问!怎么回事?我自己上传的文件却不能删除,太假了。那是因为用tftp上传下载的文件默认是具有只读属性的,所以我们在删除前需要用attrib –R 来去掉它的只读属性。

大家也知道,很多网络蠕虫或黑客攻击程序都尝试通过某种漏洞获得命令行的运行权限,而这些获得权限的过程中,蠕虫往往是通过Windows自带的tftp客户端程序去获取一些需要的攻击程序或后门程序,如nc之类的工具。较新的比如是现在热门的asp木马,也可以利用cmdasp调用tftp来下载工具,进而获取系统管理员权限。注重安全的读者也许会问,那万一我的机子也被入侵了,怎么了防止入侵者使用tftp呢?我这里介绍两种方法给大家。

1:可以用cacls来限制用户对程序的访问

C:\>cacls

显示或者修改文件的访问控制表(ACL)

CACLS filename [/T] [/E] [/C] [/G user:perm] [/R user []]

[/P user:perm []] [/D user []]

filename 显示 ACL。

/T 更改当前目录及其所有子目录中指定文件的 ACL。

/E 编辑 ACL 而不替换。

/C 在出现拒绝访问错误时继续。

/G user:perm 赋予指定用户访问权限。

Perm 可以是: R 读取W 写入C 更改(写入) F 完全控制

/R user 撤销指定用户的访问权限(仅在与 /E 一起使用时合法)。

/P user:perm 替换指定用户的访问权限。

Perm 可以是: N 无R 读取W 写入C 更改(写入) F 完全控制

/D user 拒绝指定用户的访问。

在命令中可以使用通配符指定多个文件。也可以在命令中指定多个用户。

相关帮助信息如上,那我们可以禁止iusr_computername用户对tftpexe的运行权限。

C:\>cacls c:\winnt\system32\tftpexe /D iusr_computername

C:\>cacls c:\winnt\system32\dllcache\tftpexe /D iusr_computername

是否确定(Y/N)y

处理的文件: c:\winnt\system32\tftpexe

处理的文件: c:\winnt\system32\dllcache\tftpexe

C:\>tftp

拒绝访问。

显然我们达到了我们的目的。类似的我们可以禁止iusr用户对cmdexe的调用。

2:我们能不能把tftp删除以绝后患呢?不行,因为在WIN2K下,tftpexe之类的系统关键程序受到Windows File Protection系统的保护,无法直接更改。这里我们介绍另外一种方法,

用文本编辑工具打开%systemroot%\system32\drivers\etc下的service文件找到对应的tftp那一行:

bootps 67/udp dhcps #Bootstrap Protocol Server

bootpc 68/udp dhcpc #Bootstrap Protocol Client

tftp 69/udp #Trivial File Transfer

将 69/udp 替换成 0/udp保存退出。我们再尝试看看能否使用tftp了?

怎么样,提示“timeout occurred了吧,也达到了我们的目的了

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » Linux怎么进行网络安装?

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情