Linux/Unix相关
分页: 1/5 第一页 1 2 3 4 5 下页 最后页 [ 显示模式: 摘要 | 列表 ]
本文内容详细,建立家用nas服务器,值得一读,核对了一下原文件,补充了几个遗漏的内容。
仅做了翻译,没有做安装的验证,尽量做到没有技术错误,希望有感兴趣的fans能做个测试,分享一下经验。

HOWTO : Home made NAS server with Ubuntu 8.04.1
[HOWTO] 用Ubuntu 8.04.1搭建NAS服务器

There are many NAS for home users in the market, such as Synology, Qnap, LinkStation and etc. They are not in good performance and not cheap in price. However, they are good in less power consumption. It is because I owned not only one brand of such products at home now.
现在市场上有很多家用NAS产品,例如:Synology, Qnap, LinkStation等。它们性能并不好,而且价格不便宜。不过,在低能耗方面做得较好,因此,我家里有不止1个品牌的这类产品。

Recently, I bought a VIA PC-1 PC2500E motherboard, which has VIA C7-D 1.5GHz CPU on board. It is cheap in price and use less power too. The maximum amount of RAM is 2 GB.
最近,我买了1块VIA PC-1 PC2500E主板,板上带有VIA C7-D 1.5GHz CPU。价格便宜,也节能。最大可装2G内存。

Testing it with Ubuntu 8.04.1 Desktop version for a while, I am very satisfied with the performance of the CPU, although it is not quite fast indeed. I decided to build a home made NAS server with remote BitTorrent function.
用Ubuntu 8.04.1 Desktop测试一段时间,虽然不是足够快,我还是对CPU的性能相当满意。我决定在家组装NAS服务器,并带有远程BT功能。

Hardware
Motherboard – VIA PC-1 PC2500E with VIA C7-D 1.5GHz CPU
RAM – 2 X 1GB DDR2 667MHz (maximum)
Hard drive – 300GB Seagate SATA (The motherboard treats it as ATA drive)
Router – Planet WRT-401E (wired) (optional)

Software
Operating system – Ubuntu 8.04.1 Server Edition
File server – Samba
FTP server – vsFTPd
Remote access – OpenSSH
Web Server – Apache, PHP and MySQL
Remote BitTorrent – TorrentFlux (front-end) and BitTornado (back-end)
Security software – Fail2Ban
作者: 秋风的家

一、前言

所谓的软件安装,不管是那个系统,都是通过一定的方法把文件从源复制到目的,然后做一些配置工作,使其能正常的运行,卸载。

对于Linux来说,其目录的高度组织化,以及各软件依赖关系的复杂性,使得软件包数据库显得非常重要。

简单来说,软件包数据库最主要记录两点:

   1. 软件包包含的文件列表
   2. 软件的依赖关系

对与debian的软件包数据库来说,要做的事情更多:

   1. 软件的安装状态
   2. 软件的配置状态
   3. 软件的post-uninstall

有很多原因会导致软件安装失败,但大多数都集中在:

   1. 安装时的post-install
   2. 卸载时的post-uninstall

虽然不会对系统造成问题,但是每次安装软件,或者升级软件的时候,都会提示有软件包需要配置,其实的确很烦人。
系统安全高手Dan Rosenberg 发布了一段 C 程序, 这段200多行的程序利用了 Linux Econet 协议的3个安全漏洞,可以导致本地帐号对系统进行拒绝服务或特权提升,也就是说一个普通用户可以通过运行这段程序后轻松获得 root shell,以下在 update 过的 Ubuntu 10.04 Server LTS 上测试通过:

$ sudo apt-get update
$ sudo apt-get upgrade

$ uname -r
2.6.32-21-server

$ gcc full-nelson.c -o full-nelson
$ ./full-nelson[*] Resolving kernel addresses...
[+] Resolved econet_ioctl to 0xffffffffa0131510
[+] Resolved econet_ops to 0xffffffffa0131600
[+] Resolved commit_creds to 0xffffffff8108b820
[+] Resolved prepare_kernel_cred to 0xffffffff8108bc00
[*] Calculating target...
[*] Failed to set Econet address.
[*] Triggering payload...
[*] Got root!#

由于 RHEL/CentOS 默认不支持 Econet 协议,所以测试没有通过:
# yum update

$ uname -r
2.6.18-194.26.1.el5

$ gcc full-nelson.c -o full-nelson
$ ./full-nelson
[*] Failed to open file descriptors.

如果在企业环境用 Ubuntu 的话可能会比较杯具了

Linux kernel exploit

[| 不指定 2010/12/10 20:38]
From: Dan Rosenberg
Date: Tue, 07 Dec 2010 15:25:36 -0500

Hi all,

I've included here a proof-of-concept local privilege escalation exploit
for Linux.  Please read the header for an explanation of what's going
on.  Without further ado, I present full-nelson.c:

Happy hacking,
Dan


--snip--
Tags: , , , ,
时钟的跃变,有时候会导致很严重的问题。许多应用程序依赖连续的时钟——毕竟,这是一项常见的假定,即,取得的时间是线性的,一些操作,例如数据库事务, 通常会地依赖这样的事实:时间不会往回跳跃。

不幸的是,ntpdate调整时间的方式就是我们所说的”跃变“:在获得一个时间之 后,ntpdate使用settimeofday(2)设置系统时间,这有几个非常明显的问题:

第一,这样做不安全。ntpdate的设 置依赖于ntp服务器的安全性,攻击者可以利用一些软件设计上的缺陷,拿下ntp服务器并令与其同步的服务器执行某些消耗性的任务。由于ntpdate采 用的方式是跳变,跟随它的服务器无法知道是否发生了异常(时间不一样的时候,唯一的办法是以服务器为准)。

第二,这样做不精确。一旦 ntp服务器宕机,跟随它的服务器也就会无法同步时间。与此不同,ntpd不仅能够校准计算机的时间,而且能够校准计算机的时钟。

第三, 这样做不够优雅。由于是跳变,而不是使时间变快或变慢,依赖时序的程序会出错(例如,如果ntpdate发现你的时间快了,则可能会经历两个相同的时刻, 对某些应用而言,这是致命的)。

因而,唯一一个可以令时间发生跳变的点,是计算机刚刚启动,但还没有启动很多服务的那个时候。其余的时 候,理想的做法是使用ntpd来校准时钟,而不是调整计算机时钟上的时间。

=======
dovecot, 经常会在ntpdate修改时间后,进程会死掉,且不能自动重启.
解决dovecot的问题有2个方式,
1. 将校准时间的方式由 ntpdate 更改为ntpd(此方式会有一个daemon常驻后台)
2. 在每次执行utpdate后,延迟一段时间,自动重启dovecot服务.
(这种方式只适用于邮件服务不是关键服务的情况,如果要保证dovecot稳定运行,还是建议采用第1种方式)


在ubuntu server的脚本如下
sudo nano /etc/cron.weekly/timeupdate

然后写入
#!bin/sh
ntpdate cn.pool.ntp.org

#脚本休息120秒,然后再继续.一般来说一个星期偏差120秒已经是足够足够足够大的了.#
sleep 120
service dovecot restart
Tags: , , , ,
Version 1.0
Author: Falko Timme
Last edited: 02/07/2006

In this HowTo I will show how to install and configure DenyHosts. DenyHosts is a tool that observes login attempts to SSH, and if it finds failed login attempts again and again from the same IP address, DenyHosts blocks further login attempts from that IP address by putting it into /etc/hosts.deny. DenyHosts can be run by cron or as a daemon. In this tutorial I will run DenyHosts as a daemon.

From the DenyHosts web site:

"DenyHosts is a script intended to be run by Linux system administrators to help thwart ssh server attacks.

If you've ever looked at your ssh log (/var/log/secure on Redhat, /var/log/auth.log on Mandrake, etc...) you may be alarmed to see how many hackers attempted to gain access to your server. Hopefully, none of them were successful (but then again, how would you know?). Wouldn't it be better to automatically prevent that attacker from continuing to gain entry into your system?

DenyHosts attempts to address the above... "

This tutorial is based on a Debian Sarge system, however, it should apply to other distributions with almost no modifications.

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

查看ubuntu的log

[| 不指定 2010/11/14 19:37]
Q. Can you explain me log files in Ubuntu Linux and how do I view logs?
A. All logs are stored in /var/log directory under Ubuntu (and other Linux distro).

Linux Log files and usage

=> /var/log/messages : General log messages
=> /var/log/boot : System boot log
=> /var/log/debug : Debugging log messages
=> /var/log/auth.log : User login and authentication logs
=> /var/log/daemon.log : Running services such as squid, ntpd and others log message to this file
=> /var/log/dmesg : Linux kernel ring buffer log
=> /var/log/dpkg.log : All binary package log includes package installation and other information
=> /var/log/faillog : User failed login log file
=> /var/log/kern.log : Kernel log file
=> /var/log/lpr.log : Printer log file
=> /var/log/mail.* : All mail server message log files
=> /var/log/mysql.* : MySQL server log file
=> /var/log/user.log : All userlevel logs
=> /var/log/xorg.0.log : X.org log file
=> /var/log/apache2/* : Apache web server log files directory
=> /var/log/lighttpd/* : Lighttpd web server log files directory
=> /var/log/fsck/* : fsck command log
=> /var/log/apport.log : Application crash report / log file
Tags: , ,

Linux中的18位特种兵

[| 不指定 2010/09/29 14:27]
  多数用户只熟悉那些声名遐迩的Linux发行版——如Ubuntu、Red Hat Enterprise Linux、Debian和Mandriva。这些知名发行版通常是设计作为通用桌面操作系统使用或安装到服务器。但除此之外,还有数百个发行版是设计满足特殊需求,或吸引特殊用户。

  今天Goodgearguide列举了12款有意思的、但可能默默无闻的发行版,同时笔者也整理了之前文章中的6个发行版/工具,凑够了18个,整理如下:

  1、安全是虚幻发行版Damn Vulnerable Linux
  官方主页:http://www.damnvulnerablelinux.org/
点击在新窗口中浏览此图片

  2、安全至上偏执狂发行版Tinfoil Hat Linux
  官方主页:http://tinfoilhat.shmoo.com/
点击在新窗口中浏览此图片

  3、CSI取证专用发行版CAINE
  官方主页:http://www.caine-live.net/
点击在新窗口中浏览此图片
vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux, BSD, Solaris, HP-UX 以及 IRIX 上面。
本文是vsftpd 2.0.3官方faq的非官方翻译版本。官方faq地址:ftp://vsftpd.beasts.org/users/cevans/untar/vsftpd-2.0.3/FAQ
现在最新的版本是vsftpd 2.3.2,对应的faq地址:ftp://vsftpd.beasts.org/users/cevans/untar/vsftpd-2.3.2/FAQ

Q1) 我能把用户限制在他的家(home)目录里吗?

A) 能,设置chroot_local_user=YES就行了。

Q2) 为什么设置了chroot_local_user=YES后,符号链接(symlink)就不起作用了呢?

A) 这是chroot()这种安全机制如何工作的结果。可选地,看一下硬连接(hard links),或者,你用的是“现代的”Linux,看一下强大的"mount --bind"命令。

Q3) vsftpd支持限制用户连接数吗?

A1) 是的,间接地。vsftpd是一个基于inetd的服务。如果你使用流行的xinetd,它会支持per-service per-IP的连接限制。"EXAMPLE"目录里有这样的一个例子。

A2) 如果你以"standalone"方式运行vsftpd(方法是设置listen=YES),你可以研究一下max_clients=10这样的设置。
Tags: , ,

Guide to OpenVas on Ubuntu 9.04

[| 不指定 2010/09/18 23:04]
26. JUN, 2009 CATEGORIES: TOOLS BY ADMIN VIEW COMMENTS

This guide is the second in a 3 part series. Part 1 covers the Installation of Nessus 4 on the Jaunty Jackalope – Ubuntu 9.04. Part 2 is the installation of OpenVas 2 on Ubuntu 9.04 and Part 3 will be a show down between the two vulnerability scanners. A full review with comparison scan results from a number of sample systems. Nessus is a commercial product from Tenable while OpenVas is an open source product that branched from the original Nessus open source project releasing version 1.0 in August 2008.

This guide will cover the installation of the following OpenVas components on Ubuntu 9.04 (Jaunty Jackalope). While specific to 64bit, other versions of Ubuntu should have no trouble with the following steps.
设定规则 iptables -p INPUT DROP
iptables -p OUTPUT ACCEPT
iptables -p FORWARD DROP

1、防止外网用内网IP欺骗
iptables -t nat -A PREROUTING -i eth0 -s 10.0.0.0/8 -j DROP
iptables -t nat -A PREROUTING -i eth0 -s 172.16.0.0/12 -j DROP
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/16 -j DROP
   查看nat规则
iptables -t nat -L

2、如果想取消上面所加的规则:
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat

3、阻止一个IP连接本机
iptables -t filter -A INPUT -s 192.168.1.5 -i eth0 -j DROP

简释iptables防火墙

[| 不指定 2010/09/17 10:23]
一般LINUX防火墙(iptalbes)的运用无非是用nat 表(PREROUTING、OUTPUT、POSTROUTING)和filter表(FORWARD、INPUT、OUTPUT)。我们只有知道了数据的流向才能正确的配置防火墙。现用一个相对比较直观的图形解释数据的走向。

(此处只作最基本的iptables数据流走向说明。)
点击在新窗口中浏览此图片

上图是你的家,蓝色的圈是你家院子,有两扇大门①⑥进出,你家有两个房间,分别为eth0和 eth1房间,每个房间有两个门可以进出②③④⑤。旁边是张三和李四的家,张三家和李四家之间的往返必须要过你家院子。

现假设,eth0网卡IP为:192.168.5.1链接内网,eth1网卡IP为:218.100.100.111链接互连网。

再假设,“张三家”为一个局域网,“李四家”为互连网。进我家院子用PREROUTING,出我家院子用FORWARD,进我家门用INPUT,出我家门用OUTPUT。(当我们的操作是征对服务器本身而言的话,如SSH操作,此时肯定会用到PREROUTING、INPUT和OUTPUT,当数据只是通过服务器去访问别的机器时会用到PREROUTING和FORWARD。)
感叹一句:配置网站服务器,还是要用Linux!! Windows是很难靠得住的.
1. 关闭无关端口,禁止ping (建议)

2. 更改SSH默认端口 (一般)

3. 限制可以SSH登录的IP地址/范围 (建议)

4. 使用密钥方式代替密码方式 (强烈建议)

ubuntu pdf转jpg或txt

[| 不指定 2010/08/09 01:03]
1.PDF转JPG

安装一个软件ImageMagick:
# sudo apt-get install imageMagick
然后就可以转换了,yes!!
# convert XXX.pdf XXX.jpg
这样XXX.pdf 就转换成了一大堆的XXX-*.jpg,一页一张JPG。
如果想清晰些(实验中):
# convert -verbose -colorspace RGB -resize 1800 -interlace none -density 300 -quality 100 XXX.pdf XXX.jpg

2. PDF转txt
我们要用poppler来做,它是系统自带的,
呵呵,先加一个中文支持:
# sudo apt-get install poppler-data

嘻嘻,转换啦!!
# pdftotext -layout -nopgbrk XXX.pdf
因为pdftotext不支持同时处理多个 pdf,所以用批处理要脚本搞定,打开终端,进入放置 pdf 的目录,运行下面命令
find ./ -name '*.pdf' | while read i; do pdftotext -layout -nopgbrk $i; done
很快就在当前目录下输出很多 txt 文件,“-layout”参数表示保留页面布局,“-nopgbrk”表示不输出换行符,自己对比一下就知道区别了。
Tags: , , , ,
分页: 1/5 第一页 1 2 3 4 5 下页 最后页 [ 显示模式: 摘要 | 列表 ]