windows与linux双系统卸载linux

使用MbrFix.exe修复mbr

在卸载linux Ubuntu之前,先修复MBR,然后再删除Linux分区就可以了。而MbrFix.exe 就是这样一个Windows 修复MBR的应用程序软件,MbrFix.exe 不仅支持Windows XP,还支持32位或64位的Windows NT, Windows 2000,Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7 和 Windows PE系统。使用MbrFix.exe卸载Linux Ubuntu的步骤如下:

1. 下载MbrFix.exe

首先进入Windows 操作系统,进入www.sysint.no 网站下载MbrFix.exe,从上往下数第四个软件即是;

下载完成后解压zip压缩包,将MbrFix.exe 剪切到C盘(系统盘);

Windows7要使用以管理员身份运行CMD 然后在使用如下命令:MbrFix /drive 0 fixmbr /yes–>Enter回车;

这样MBR修复就完成了。接下来直接删除linux分区就可以了。

2. 格式化删除 Linux分区

以Windows XP系统为例:我的电脑点击右键–>管理–>磁盘管理–>看到几个没有盘符名称的分区(看准哦,不要将Windows 分区给误删了。)–>右键–>删除逻辑分区。

重启电脑,Grub 已经不复存在,双系统Linux Ubuntu 卸载完成,电脑启动自动进入Windows XP 系统….

3、误删windows的磁盘分区可以用 磁盘分区及数据恢复工具DiskGenius 恢复。

Share
发表在 linux学习笔记 | 评论关闭

apt-get学习笔记

你输入apt-get --help
会有详细资料的
apt命令详解
apt-cache search # (package 搜索包)
apt-cache show #(package 获取包的相关信息,如说明、大小、版本等)
sudo apt-get install # (package 安装包)
sudo apt-get install # (package - - reinstall 重新安装包)
sudo apt-get -f install # (强制安装?#"-f = --fix-missing"当是修复安装 吧...)
sudo apt-get remove #(package 删除包)
sudo apt-get remove - - purge # (package 删除包,包括删除配置文件等)
sudo apt-get autoremove --purge # (package 删除包及其依赖的软件包+配置 文件等(只对6.10有效,强烈推荐))
sudo apt-get update #更新源
sudo apt-get upgrade #更新已安装的包
sudo apt-get dist-upgrade # 升级系统
sudo apt-get dselect-upgrade #使用 dselect 升级
apt-cache depends #(package 了解使用依赖)
apt-cache rdepends #(package 了解某个具体的依赖?#当是查看该包被哪些包依赖吧...)
sudo apt-get build-dep #(package 安装相关的编译环境)
apt-get source #(package 下载该包的源代码)
sudo apt-get clean && sudo apt-get autoclean # 清理下载文件的存档 && 只清理过时的包
sudo apt-get check #检查是否有损坏的依赖
Share
发表在 linux学习笔记 | 评论关闭

安全配置PHP服务器

PHP被广泛用于各种Web开发。而当服务器端脚本配置错误时会出现各种问题。现今,大部分Web服务器是基于Linux环境下运行(比如:Ubuntu,Debian等)。本文例举了十大PHP最佳安全实践方式,能够让您轻松、安全配置PHP.

PHP安全性设置提示:

DocumentRoot: /var/www/ Default Web server: Apache

Default PHP configuration file: /etc/php.ini

Default PHP extensions config directory: /etc/php.d/

Our sample php security config file: /etc/php.d/security.ini (you need to create this file using a text editor)

Operating systems: Ubuntu (the instructions should work with any other Linux distributions such as RHEL / CentOS / Fedora or other Unix like operating systems such as OpenBSD/FreeBSD/HP-UX)。

1. 减少PHP内置模块

为了增强性能和安全性,强烈建议,减少PHP中的模块。来看看下面这个被执行命令安装的模块。

# php –m你将会得到类似的结果:

[PHP Modules] apc bcmath bz2 calendar Core ctype curl date dom ereg exif fileinfo filter ftp gd gettext gmp hash iconv imap json libxml mbstring memcache mysql mysqli openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session shmop SimpleXML sockets SPL sqlite3 standard suhosin tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib [Zend Modules] Suhosin删除一个模块,并执行此命令。例如:删除模块sqlite3

# rm /etc/php.d/sqlite3.ini

或者

# mv /etc/php.d/sqlite3.ini /etc/php.d/sqlite3.disableRestrict 2. 使PHP信息泄露最小化

在默认PHP时在HTTP抬头处会生成一条线介于每个响应中,(比如X-Powered-By: PHP/5.2.10)。而这个在系统信息中为攻击者创建了一个非常有价值的信息。

HTTP示例:

HTTP/1.1 200 OK X-Powered-By: PHP/5.2.10 Content-type: text/html; charset=UTF-8 Vary: Accept-Encoding, Cookie X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikiToken;string-contains=wikiLoggedOut;string-contains=wiki_session Last-Modified: Thu, 03 Nov 2011 22:32:55 GMT……

因此,我们强烈建议,禁止PHP信息泄露,想要要禁止它,我们要编辑/etc/php.d/secutity.ini,并设置以下指令:

expose_php=Off

3. 使PHP加载模块最小化

在默认情况下,RHEL加载的所有模块可以在/etc/php.d/目录中找到。要禁用或启用一个特定的模块,只需要在配置文件/etc/php.d/目录中中注释下模块名称。而为了优化PHP性能和安全性,当你的应用程序需要时,我们强烈建议建议启用扩展功能。举个例子:当禁用GD扩展时,键入以下命令:

# cd /etc/php.d/

# mv gd.{ini,disable}

# /etc/init.d/apache2 restart为了扩展PGP GD模块,然后键入以下命令:

# mv gd.{disable,ini}

# /sbin/service httpd restart 4. 记录PHP错误信息

为了提高系统和Web应用程序的安全,PHP错误信息不能被暴露出。要做到这一点,需要编辑/etc/php.d/security.ini 文件,并设置以下指令:

display_errors=Off为了便于开发者Bug修复,所有PHP的错误信息都应该记录在日志中。

log_errors=On

error_log=/var/log/httpd/php_scripts_error.log

5. 禁用远程执行代码

如果远程执行代码,允许PHP代码从远程检索数据功能,如FTP或Web通过PHP来执行构建功能。比如:file_get_contents()。

很多程序员使用这些功能,从远程通过FTP或是HTTP协议而获得数据。然而,此法在基于PHP应用程序中会造成一个很大的漏洞。由于大部分程序员在传递用户提供的数据时没有做到适当的过滤功能,打开安全漏洞并且创建了代码时注入了漏洞。要解决此问题,需要禁用_url_fopen in /etc/php.d/security.ini,并设置以下命令:

allow_url_fopen=Off除了这个,我还建议禁用_url_include以提高系统的安全性。

allow_url_include=Off 6. 禁用PHP中的危险函数

PHP中有很多危险的内置功能,如果使用不当,它可能使你的系统崩溃。你可以创建一个PHP内置功能列表通过编辑/etc/php.d/security.ini来禁用它。

disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source 7. 资源控制

为了提高系统的稳定性,强烈建议设置每个脚本解析请求数据所花费的时间和脚本可能消耗的最大内存量。正确的配置这些参数可以防止PHP任何脚本消耗太多的资源或是内存,从而避免系统不安全或降低安全系数。

# set in seconds

max_execution_time = 30

max_input_time = 30

memory_limit = 40M

8. 限制PHP访问文件系统

该open_basedir指令指定的目录是允许PHP访问使用fopen()等功能。如果任何脚本试图访问超出open_basdir定义的路径文件,PHP将拒绝打开。值得注意的是,你不能使用一个符号链接作为一种变通方法。

; Limits the PHP process from accessing files outside; of specifically designated directories such as /var/www/html/ open_basedir=”/var/www/html/”; ——; Multiple dirs example; open_basedir=”/home/httpd/vhost/cyberciti.biz/html/:/home/httpd/vhost/nixcraft.com/html/:/home/httpd/vhost/theos.in/html/”; ——9.限制文件/目录访问

进行适当的安全设置:确保Apache作为非root用户运行,比如www-data或www.对于文件和目录在基于/var/www/下同样属于非root用户。想要更改所有者,执行以下命令:

# chown -R apache:apache /var/www/ 10.编译保护Apache,PHP和MySQL的配置文件

使用charrt命令编译保护配置文件

# chattr +i /etc/php.ini

# chattr +i /etc/php.d/*

# chattr +i /etc/my.ini

# chattr +i /etc/httpd/conf/httpd.conf

# chattr +i /etc/使用charrt命令可以编译保护PHP文件或者是文件中的/var/www/html的目录:

# chattr +i /var/www/html/file1.php

# chattr +i /var/www/html/

Share
发表在 网络安全 | 评论关闭

记录一下最近的我

最近的2件喜事1:找到工作了做企业网数据维护2:考上本科了是:泉州师范 专业是:计算机科学与技术。工作挺累的,整天在外面跑,这几天也没休息好,早上还给迟到了,唉!!这是什么生活,有点不想干了!在过几天又要去靠网工了,没时间复习啊!连书都没看,唉,都不想去考了。最近太忙了,又很累。更本没有时间看书啥的。前几天出去干活看到几个大牛,玩数据库的,晚上12点以后才干活的,挺好的不是很累。还是有把技术练好了,这样干活轻松些啊!

算了,又要干活去了,累啊!继续努力,加油!

Share
发表在 生活小记 | 评论关闭

Linux的系统安全设置Shell脚本

本脚本是第二次更新,已经大量应用在某大型媒体网站体系中,加入了之前没有想到的一些安全设置。使用方法将其复制,保存为一个Shell文件,比如security.sh.将其上传到Linux服务器上,执行sh security.sh,就可以使用该脚本了!

#!/bin/sh
# desc: setup linux system security
# author:coralzd
#account setup

passwd -l xfs
passwd -l news
passwd -l nscd
passwd -l dbus
passwd -l vcsa
passwd -l games
passwd -l nobody
passwd -l avahi
passwd -l haldaemon
passwd -l gopher
passwd -l ftp
passwd -l mailnull
passwd -l pcap
passwd -l mail
passwd -l shutdown
passwd -l halt
passwd -l uucp
passwd -l operator
passwd -l sync
passwd -l adm
passwd -l lp

# chattr /etc/passwd /etc/shadow
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow

# add continue input failure 3 ,passwd unlock time 5 minite
sed -i 's#auth required pam_env.so#auth required pam_env.sonauth required pam_tally.so onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_tally.so onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
# system timeout 5 minite auto logout
echo "TMOUT=300" >>/etc/profile

# will system save history command list to 10
sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile

# enable /etc/profile go!
source /etc/profile

# add syncookie enable /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf

sysctl -p # exec sysctl.conf enable
# optimizer sshd_config

sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

# limit chmod important commands
chmod 700 /bin/ping
chmod 700 /usr/bin/finger
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 700 /usr/bin/locate
chmod 700 /usr/bin/whereis
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/pico
chmod 700 /bin/vi
chmod 700 /usr/bin/which
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/make
chmod 700 /bin/rpm

# history security

chattr +a /root/.bash_history
chattr +i /root/.bash_history

# write important command md5
cat > list << "EOF" &&
/bin/ping
/bin/finger
/usr/bin/who
/usr/bin/w
/usr/bin/locate
/usr/bin/whereis
/sbin/ifconfig
/bin/pico
/bin/vi
/usr/bin/vim
/usr/bin/which
/usr/bin/gcc
/usr/bin/make
/bin/rpm
EOF

for i in `cat list`
do
if [ ! -x $i ];then
echo "$i not found,no md5sum!"
else
md5sum $i >> /var/log/`hostname`.log
fi
done
rm -f list
Share
发表在 网络安全 | 评论关闭