firefox扩展,使用中,已禁用的

用了好几年的firefox,还在用的扩展,只包括使用中的,禁用的忽略了吧,删除的自然更不用管了。主要是现在的浏览器越来越膨胀,只打开几个页面,使用内存就飙到两三G,扩展的内存占用也是惊人,所以尽量删除了。

其中,

Redirector 是对URL做自动转向的,使用正则表达式,目前只使用了个规则,即把维基百科的移动版子域 m. 转到桌面版本上,规则

^https?:\/\/(.*?)\.m\.(wikipedia|wikisource)\.org\/(.*)
https://$1.$2.org/$3

 


下面是 2019/06/17的版本

用了好几年的firefox,上面安装的扩展,包括使用中的,还有已经禁用的,删除的当然不在其中。

激活状态的扩展们

激活状态的扩展们

已经停用的part-1

已经停用的part-1

已经停用的part-2

已经停用的part-2

filezilla server手工修改配置文件及重加载生效/命令行参考等

使用filezilla server自带的配置工具,修改用户(或用户组)目录权限时,浏览文件是很麻烦的事情,要一级一级展开,尤其是目录比较深的时候。这时,推荐手工修改配置文件 FileZilla Server.xml 。

以下示例假定filezilla server安装在 D:\Program Files\FileZilla Server

安装目录下文件 FileZilla Server.xml 即配置文件。该文件结构很清晰,而且有良好排版。每个用户(或组),下面都有 <Permissions> ... </Permissions> 节点,其中每个目录是一个 Permission节点,其中多个option,定义几种操作的权限。

下面是几种常用的权限示例,需要增减目录配置时,直接复制相应的 <Permission ...>.....</Permission> 节点 ,修改其中目录 Dir 即可

<label>readonly 只读权限</label>

                <Permission Dir="E:\web\tools">
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">0</Option>
                    <Option Name="FileDelete">0</Option>
                    <Option Name="FileAppend">0</Option>
                    <Option Name="DirCreate">0</Option>
                    <Option Name="DirDelete">0</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>


<label>allaccess 所有权限,包括读写删除管理目录等</label>

                <Permission Dir="E:\web\tools">
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">1</Option>
                    <Option Name="FileDelete">1</Option>
                    <Option Name="FileAppend">1</Option>
                    <Option Name="DirCreate">1</Option>
                    <Option Name="DirDelete">1</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>


<label>basic_write 常规的文件读写权限,不允许增删目录操作</label>

                <Permission Dir="E:\web\tools">
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">1</Option>
                    <Option Name="FileDelete">1</Option>
                    <Option Name="FileAppend">1</Option>
                    <Option Name="DirCreate">1</Option>
                    <Option Name="DirDelete">0</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>


<label>no_access 无任何权限,包括读写文件,列出目录等</label>

                <Permission Dir="E:\web\tools">
                    <Option Name="FileRead">0</Option>
                    <Option Name="FileWrite">0</Option>
                    <Option Name="FileDelete">0</Option>
                    <Option Name="FileAppend">0</Option>
                    <Option Name="DirCreate">0</Option>
                    <Option Name="DirDelete">0</Option>
                    <Option Name="DirList">0</Option>
                    <Option Name="DirSubdirs">0</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>

即如上

,修改后,不需要重启,只需在命令行下重新加载权限即可,示例

D:\Program Files\FileZilla Server>"FileZilla Server.exe" /reload-config

"FileZilla Server.exe"  不像unix程序一样自带help,经查官方手册,转载如下

-------------- "FileZilla Server.exe" Command-line arguments  ------------------
Starting and stopping the service:

/start
/stop

Installing the service for manual startup:

/install

Installing the service for start at boot:

/install auto

Uninstalling service:

/uninstall

Reloading configuration at runtime:

/reload-config

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

 

windows下filezilla server安装配置及安全加固

以  FileZilla_Server-0_9_41.exe 为例

1  安装
FileZilla_Server-0_9_41.exe

2  从开始菜单里停止Filezilla_server服务

3  到安装目录里改名备份(或直接删掉)文件 FileZilla server.exe
典型位置: "C:\Program Files (x86)\FileZilla Server" (64位机器上) 或 "C:\Program Files\FileZilla Server" (32位机器上)

4  从默认ansi编码的filezilla server补丁包里压缩出 FileZilla server.exe ,拷到如上安装目录里。

5  创建一个独立的windows用户、一个windows用户组,用于运行ftp服务,用户名为webftp
(默认情况下,windows服务以SYSTEM用户运行,几乎等同于管理员;这是重大安全隐藏,如果该服务有漏洞并被恶意利用,后果...)

6  到windows服务列表中,双击 "FileZilla Server FTP server",打开服务属性窗口 - 登录
“登录身份” - 选择 “此账户” - 浏览 - 选择到刚建立的独立用户webftp
回到“服务恢属性”窗口,输入账号密码,“应用”或“确定”

6  启动服务(从开始菜单或服务列表皆可),观察windows任务管理器中,进程"FileZilla server.exe" 的用户名是否是 webftp

7  修改将filezilla server安装目录权限:webftp用户有读取权限
只保留 SYSTEM, webftp, Administrators 三个用户的权限,其它删掉

修改安装目录中的 文件  "FileZilla Server.xml", "FileZilla Server Interface.xml" 权限,为webftp用户赋写入权限

8  windows默认对每个硬盘分区设置了较多权限,只保留administrator,system,users,其它删除(通常Users也可以删除)
(否则,权限极低的webftp用户将可以在相应目录的读取甚至写入的权限;或许是因为everyone用户的存在)

8  windows了防火墙,添加一条规则,按程序的规则添加规则(非按端口):allow_filezilla-server_in
新建入站规则- 规则类型:程序(P) - 此程序路径 - 浏览到 FileZilla server.exe - 允许连接

------------------------------------
* 关于ftp目录的权限设置
对于需要通过ftp管理(包括读取或删除写入等)的所有目录(文件)
检查是否有不该买有的权限,最好是严格按照“最低权限”原则进行设置。
对这些目录(文件),根据需要,赋给ftp用户权限,至少需要一个读取权限。
如果不需要通过ftp删除的文件(夹),可以不赋修改写入权限

删除windows上lpt1.asp伪装木马文件(SHR属性),及一次查杀web木马简记

维护的一台windows 2003服务器,跑iis6,其中一个站点需要同时支持asp与php,还得跟站点web用户赋写入权限(因为该站主要是一asp的CMS,文章内容页是生成静态html的)。正因如此,该站比较容易出问题,数次被挂马。

在与该CMS还有入侵者长期的拉锯战里,该站点做了很多针对性的措施,比如,

  • 删除iis里动态脚本映射,只保留.asp, .php, .shtml,其它的像.net的一大堆(,.cs什么什么的),全部删除
  • 改进cms程序的写入文件功能:禁止写asp, php文件,增强上传功能安全性,等
  • 非动态脚本目录(如文件上传目录等),通过iis设置无执行权限
  • 后来更严苛的设置,除了少数几个有必要的目录,其它目录下的.asp, .php全部重写到一个空文件上。通过rewrite实现

不过后来,还是出过问题。

如这一次,根据被挂马文件的写入时间,找之前一天内被修改过(包括写入)的.asp, .php文件,在查iis日志,里查找马儿文件被请求的记录项,找到马夫的ip,当然ip很可能是动态变化的,不过这次好像是全部从一个ip上还的,这就省功夫了。分析该ip的请求记录,专找对.asp, .php url的请求,尤其是 POST请求(因为webshell大马的处理很复杂,一般都是post传参数),仔细检查这些.asp, .php文件的修改时间,最近被修改过的,一定可疑。修改时间是很久以前,也不能吊心轻心,有可能是长期隐蔽马。

按上面的步骤,清理木马不是太难的事情。但就怕遗漏,一个小小马(通常是一句话或其变种),足以让这些工作白费。

不过这次发现了一个名为 lpt1.asp 的文件,而且是“系统 隐藏 只读”的属性SHR,删除时提示找不到文件,有点奇怪了,看文件名,有点奇怪;使用编辑器打开,也提示文件不存在。担心操作系统被植入了什么进程,这就麻烦了。google得知,lpt1这是dos保留字的文件名,要使用一个咒语般的路径地址,很蛋疼。。。

根据搜索结果,该文件位于 E:\www\site_root\images\lpt1.asp 相应的地址是 \\.\E:\www\site_root\images\lpt1.asp ,即

del \\.\E:\www\site_root\images\lpt1.asp

结果是不行,怀疑是SHR的关系,尝试一阵子,通过这样的形式:

attrib -S -R -H path_to_file.ext

清理掉这几个属性;似乎这几个属性要一次性去除,还不能一个一个的去除;好像不是dos的风格,竟然支持一次多个item的操作。。。。

然后可以删除了,当然,我在删除前做了个备份,毕竟又截获了一只马。

下面是一部分操作的记录,帖出来了

E:\www\site_root\images>del E:\www\site_root\images\lpt1.asp
文件名、目录名或卷标语法不正确。

E:\www\site_root\images>attrib \\.\E:\www\site_root\images\lpt1.asp
A  SHR     \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>del E:\www\site_root\images\lpt1*
找不到 E:\www\site_root\images\lpt1*

E:\www\site_root\images>del E:\www\site_root\images\lp*

E:\www\site_root\images>attrib \\.\E:\www\site_root\images\lpt1.asp
A  SHR     \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>attrib \\.\E:\www\site_root\images\lpt1.asp
A  SHR     \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>attrib -H \\.\E:\www\site_root\images\lpt1.asp
未重设系统文件 - \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>attrib -S -R -H \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>attrib -H \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>attrib \\.\E:\www\site_root\images\lpt1.asp
A          \\.\E:\www\site_root\images\lpt1.asp


E:\www\site_root\images>attrib \\.\E:\www\site_root\images\lpt1.asp
A          \\.\E:\www\site_root\images\lpt1.asp

E:\www\site_root\images>copy \\.\E:\www\site_root\images\lpt1.asp f:\aa.txt
已复制         1 个文件。

E:\www\site_root\images>del \\.\E:\www\site_root\images\lpt1.asp

本文是以前写的一篇手记,处理后以为问题得解,但稍后两天发现仍被入侵,于是次本文状态改成草稿;被入侵的原因是其他地方仍然有木马,处理后本文丢在这里没有动。这么久都没有继续写,大概以后也不会续写,最近整理博客时就直接发出来算了(2016-10-10 16:20)

磁盘空间爆掉时nginx报错 An error occurred

nginx报错了,消息如下错误如下nginx_Error_disk_empty

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

1分钟前还是好的,至少wordpress后台可以正常打开,突然就成这样子了。静态页面还正常,就ssh上,检查php-fpm进程是正常的,没有僵局。算了,杀死,连nginx一起杀死,虽然这是很不优雅的行为,所不齿的行为。然而结果是没用。随手查了下df -h ,分区满了,怪不得,查了下,删除几个备份文件,然后一切恢复正常了。空间不够,还是个问题,要进一步清理了。

centos 7 下rpm/yum安装inconsolata字体

inconsolata字体是一款不错的等宽字体,码代码用字体...

然而在centos 7下没有,在rhel/epel 6下的rpmforge里有这个字体,7系列竟然没了。根据“相近原则”,找6下面的字体,竟然发现它是noarch的,那就直接rpm安装了,使用华中科技大学开源镜像站的镜像

rpm -ivh http://mirrors.hustunique.com/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/inconsolata-fonts-0.1-1.el6.rf.noarch.rpm

完成。

macport pip install Cryptography/pyOpenSSL报错 Expected in: flat namespace

如题,macport pip安装pyOpenSSL过程中,要安装依赖包Cryptography,在该依赖包中,报错,经过不懈的查询,找到这篇文章 http://chriskief.com/2014/03/25/installing-cryptography-via-pip-with-macports-or-homebrew/comment-page-1/#comment-2809
按照作者的方案,要增加几个环境变量再pip,如下
sudo env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
记录并分享一下,再次感谢原作者Chris Kief

pip install m2crypto安装报错:opensslconf.h Error: CPP #error This openssl-devel package does not work your architecture

centos 7下,安装shadowsocks,提示需要m2crypto依赖包,M2Crypto is required to use aes-256-cfb, please run `apt-get install python-m2crypto`

通过pip安装之,但提示错误消息如下

[root@fsc tmp]# pip install m2crypto
Downloading/unpacking m2crypto
  Running setup.py egg_info for package m2crypto
    
Installing collected packages: m2crypto
  Running setup.py install for m2crypto
    building 'M2Crypto.__m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    swig -python -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    /usr/include/openssl/opensslconf.h:31: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.
    error: command 'swig' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-feng/m2crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vpkm7l-record/install-record.txt --single-version-externally-managed:
    running install

running build

running build_py

running build_ext

building 'M2Crypto.__m2crypto' extension

swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c

swig -python -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i

/usr/include/openssl/opensslconf.h:31: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.

error: command 'swig' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-feng/m2crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vpkm7l-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-feng/m2crypto
Storing complete log in /root/.pip/pip.log

安装m2crypto后,再pip安装即可。

 

linux下日期时间自动同步设置(rdate,ntpdate两种方法)

linux下同步时间,至少有两种方法:

rdate,ntpdate两种。centos最小化安装默认不安装,先确认已经安装过,否则先安装。

其中rdate本身是用来获取远程时间服务器上时间用的,带上 -s 参数,就可以将获取到的时间应用到本地系统。

NAME
       rdate - get the time via the network

SYNOPSIS
       rdate [-p] [-s] [-u] [-l] [-t sec] [host...]

DESCRIPTION
       rdate  connects  to  an  RFC  868 time server over a TCP/IP network, printing the returned time
       and/or setting the system clock.

   OPTIONS
       -p     Print the time returned by the remote machine.

       -s     Set the system time to the returned time.

       -u     Use UDP instead of TCP as the transport.

       -l     Use syslog to output errors (cron.warning) and output (cron.info).

       -t     Set timeout in seconds for every attempt to retreive date.

rdate -s time.nist.gov

ntpdate 本身就是用来同步时间的工具。

示例 :ntpdate ntp.sjtu.edu.cn

NAME
       ntpdate - set the date and time via NTP

       Disclaimer:  The functionality of this program is now available in the ntpd program. See the -q com-
       mand line option in the ntpd - Network Time Protocol (NTP) daemon page. After a suitable  period  of
       mourning, the ntpdate program is to be retired from this distribution

SYNOPSIS
       ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t
       timeout ] [ -U user_name ] server [ ... ]

DESCRIPTION

[略,具体参看linux man手册]

日期时间服务器

同步时间,就必须有时间服务器。通常情况下,我们完全没必要自己搭建,使用公共的时间服务就可以。

参看 国内常用NTP服务器地址及IP  http://www.douban.com/note/171309770/

其中国家授时中心的似乎不能用,推荐使用上海交大ntp服务 ntp.sjtu.edu.cn 或美国授时中心 time.nist.gov

上代码,拷了就可以用

rdate -s time.nist.gov

ntpdate ntp.sjtu.edu.cn

可以加到crontab里定时执行。

mysqld 配置优化,请一定要加 skip-name-resolve,否则将被show processlist 里的 unauthenticated user 搞死

把mysql迁移到单独的服务器,与web服务器分离;但似乎不怎么稳定,经常无法连接,报错是连接数过多;登录到服务器上命令行连接也是无法连接。这情况很频繁,今天竟然出现了两次。之前一直是重启mysql解决问题,但如此频繁的故障,就有十分的必要去查找原因了。

在服务器上命令行登录,mysql -uroot -upassword,把密码写到命令行里,不用每次再输入,按ctrl+p 然后回车,尝试N次,终于登录进去了;连接数过多,终究还是可以找到空子进去的。赶快查看并保留运行状态的重要参数:

show variables;
show status;

show processlist;

好家伙,这么多连接:

| 10520 | unauthenticated user | 192.168.0.109:41063 | NULL  | Connect | NULL | login | NULL             |
| 10521 | unauthenticated user | 192.168.0.109:41065 | NULL  | Connect | NULL | login | NULL             |
| 10522 | unauthenticated user | 192.168.0.109:41067 | NULL  | Connect | NULL | login | NULL             |
| 10523 | unauthenticated user | 192.168.0.109:41068 | NULL  | Connect | NULL | login | NULL             |
| 10524 | unauthenticated user | 192.168.0.109:41069 | NULL  | Connect | NULL | login | NULL             |
| 10525 | unauthenticated user | 192.168.0.109:41070 | NULL  | Connect | NULL | login | NULL             |
| 10526 | unauthenticated user | 192.168.0.109:41071 | NULL  | Connect | NULL | login | NULL             |

如些上千行。先不管,这里肯定是问题突破口。

set global max_connections=4000;

增加允许的最大连接数,先让前台网站可以正常工作。

回过头google :mysql unauthenticated user

果然,遇到此类问题的人很多,问题在于mysql的反向ip地址解析,配置参数里加上skip-name-resolve就可以。

总结一下原因,大概如下:

因为mysql默认会根据客户端的ip地址反向解析,用于用户登录授权之用。不过正常情况下,很少会有人这样用。ip地址反向解析是很慢的,尤其是高负荷的mysql,每秒种几百次甚至更高的请求,这个请求压到本地的dns服务器上,dns服务器说不定会怀疑你在恶意请求,然后不理你了,然后这些登录请求就挂在那里,后面的连接还持续,然后越积越多,然后就达到mysql的最大连接数据限制了,然后新的连接就直接被拒,得到连接数过多的消息。

因为mysql配置文件使用的之前的配置文件,当时跟web同服务器,所以不存在这个问题。

这也正好解释了为什么phpMyAdmin里看mysqld状态时,有很多失败的连接,它们应该就是因反解析失败而被拒的。