C#调用API隐藏Windws窗体界面

刚好碰到一个朋友要求,要隐藏窗体界面,网上下载了几个,都不太合意,很多都被杀毒软件认为是有害软件,没办法,只能自已写个隐藏窗体界面的小工具。

.NET 2.0, C#


/***************************************************
 *  开发者:0x001                                   *
 *  开发时间:2012-05-17                           *
 *  功能:List 获取所有显示的窗口列表名称          *
 *        Keyword 是要隐藏的窗口名称包含的关键字   *
 *        Start时正式关闭,Stop时关闭按钮将隐藏程序 *
 *        本程序隐藏时 Ctrl+Alt+9 激活主界面       *
 *        Start之后生隔5秒扫描一次窗口,继续隐藏   *
 **************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;

namespace SovHid
{
    public partial class Form1 : Form
    {
        #region Windows API
        [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
        static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        [DllImport("coredll.dll", EntryPoint = "FindWindow")]
        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
        static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);

        [DllImport("user32.dll")]
        public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);

        [DllImport("User32.dll", CharSet = CharSet.Auto)]
        public static extern int GetWindowText(IntPtr hWnd, out STRINGBUFFER text, int nMaxCount);

        [DllImport("user32.dll")]
        public static extern bool IsWindowVisible(IntPtr hWnd);

        [DllImport("user32.dll")]
        public static extern IntPtr GetWindowThreadProcessId(IntPtr hwnd, ref int lpdwProcessId);

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct STRINGBUFFER
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
            public string szText;
        }
        #endregion

        #region 系统热键

        [DllImport("user32")]
        public static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers control, Keys vk);
        //注册热键的api
        [DllImport("user32")]
        public static extern bool UnregisterHotKey(IntPtr hWnd, int id);

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x0312: //这个是window消息定义的 注册的热键消息
                    if (m.WParam.ToString().Equals("888")) //如果是我们注册的那个热键
                    {
                        this.ShowInTaskbar = true;
                        this.Show();
                        this.Focus();
                    }
                    break;
            }
            base.WndProc(ref m);
        }

        public enum KeyModifiers
        {
            None = 0,
            Alt = 1,
            Ctrl = 2,
            Shift = 4,
            WindowsKey = 8
        }

        #endregion

        private string Gname = string.Empty;
        private bool isRunning = false;
        public delegate bool EnumWindowsProc(IntPtr p_Handle, int p_Param);
        public delegate void MainFromSetRtbHandler(string str, bool isAdd);

        #region 窗体事件

        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            MessageWindwos(false);
            this.TopMost = true;              //窗体总在最前
            this.StartPosition = FormStartPosition.CenterScreen;    //设置窗体的位置
        }
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            //注消热键(句柄,热键ID)
            UnregisterHotKey(this.Handle, 888);
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isRunning)
            {
                HideMyFrom();
                e.Cancel = true;
            }
        }

        #endregion

        #region Change RichTextBox
        /// <summary>
        /// RichTextBox添加
        /// </summary>
        private void SetRtbMessage(string str, bool isAdd)
        {
            if (rtb_List.InvokeRequired)
            {

                MainFromSetRtbHandler CallBack = new MainFromSetRtbHandler(SetRtbMessage);
                this.Invoke(CallBack, new object[] { str, isAdd });
            }
            else
            {
                if (isAdd)
                {
                    rtb_List.Text += str + "\r\n";
                }
                else
                {
                    rtb_List.Text = str;
                }
            }
        }
        public void MessageWindwos(bool isHidden)
        {
            EnumWindowsProc _EunmWindows = null;
            if (!isHidden)
            {
                _EunmWindows = new EnumWindowsProc(NetEnumWindows);
            }
            else
            {
                _EunmWindows = new EnumWindowsProc(NetEnumWindowsHidden);
            }
            EnumWindows(_EunmWindows, 0);
        }
        #endregion

        /// <summary>
        /// 隐藏WinFrom窗体界面
        /// </summary>
        private void HideMyFrom()
        {
            this.Hide();
            this.ShowInTaskbar = false;
            //注册热键(窗体句柄,热键ID,辅助键,实键)
            RegisterHotKey(this.Handle, 888, KeyModifiers.Ctrl | KeyModifiers.Alt, Keys.D9);
        }
        /// <summary>
        /// 读取不隐藏
        /// </summary>
        private bool NetEnumWindows(IntPtr p_Handle, int p_Param)
        {
            if (!IsWindowVisible(p_Handle)) return true;

            STRINGBUFFER _TitleString = new STRINGBUFFER();
            GetWindowText(p_Handle, out _TitleString, 256);
            if (_TitleString.szText != "")
            {
                SetRtbMessage(_TitleString.szText, true);
            }
            return true;
        }
        /// <summary>
        /// 隐藏事件
        /// </summary>
        private bool NetEnumWindowsHidden(IntPtr p_Handle, int p_Param)
        {
            STRINGBUFFER _TitleString = new STRINGBUFFER();
            GetWindowText(p_Handle, out _TitleString, 256);

            if (_TitleString.szText != "")
            {
                if (!IsWindowVisible(p_Handle) && !isRunning)
                {
                    if (_TitleString.szText.IndexOf(Gname) > -1)
                    {
                        ShowWindow(p_Handle, 1);
                    }
                }
                else
                {
                    if (_TitleString.szText.IndexOf(Gname) > -1)
                    {
                        ShowWindow(p_Handle, 0);
                    }
                }
            }
            return true;
        }
        /// <summary>
        /// 线程-处理事件
        /// </summary>
        private void ThreadHandler()
        {
            while (isRunning)
            {
                MessageWindwos(true);
                System.Threading.Thread.Sleep(5000);
            }
        }
        /// <summary>
        /// 按钮事件-开始或结束
        /// </summary>
        private void btn_Start_Click(object sender, EventArgs e)
        {
            if (!isRunning)
            {
                Gname = txt_Keyword.Text.Trim();
                if (string.IsNullOrEmpty(Gname))
                {
                    MessageBox.Show("Please enter a Keyword!");
                    txt_Keyword.Focus();
                    return;
                }
                isRunning = true;
                txt_Keyword.Enabled = false;
                btn_Start.Text = "Stop";

                Thread th = new Thread(new ThreadStart(ThreadHandler));
                th.IsBackground = true;
                th.Start();
            }
            else
            {
                isRunning = false;
                txt_Keyword.Enabled = true;
                btn_Start.Text = "Start";
                MessageWindwos(true);
                SetRtbMessage("", false);
                MessageWindwos(false);
            }
        }
        /// <summary>
        /// 按钮事件-窗体列表
        /// </summary>
        private void btn_List_Click(object sender, EventArgs e)
        {
            SetRtbMessage("", false);
            MessageWindwos(false);
        }
    }
}

VPS又到期没续费,还好之前有备份

又是这样,还好之前有导出信息,不然所有信息又泡汤了……又要重新弄,幸好有备了一手……

简单rsync同步数据

1, Rsync 服务端配置:

#/etc/rsync.conf

use chroot = false
strict modes = false
hosts allow = 192.168.168.1/24
hosts deny = *
log file = /var/log/rsyncd.log

# Module definitions
# Remember cygwin naming conventions : c:work becomes /cygwin/c/work
#
[WebUpload]
path = /web/0x001/upload
read only = false
comment = PHP 0x001.com
transfer logging = yes
#write only = true

#启动rsync

# /usr/bin/rsync --daemon

2,客户端开始与服务器同步

# rsync -azv rsync://root@192.168.168.7/WebUpload /var/www/upload

bash shell 只允许运行一个进程

#!/usr/bin/env bash

# 文件运行的单锁文件
LOCKFILE=/tmp/watch.lock

if [ -f ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
	# 如果单锁文件存在并且程序正在运行,则退出。
	echo "filecollector is already running"
	exit
fi

# 注入系统调用中断号,接收到中断后先删除单锁文件。
trap "rm -f ${LOCKFILE};exit" INT TERM EXIT

# 把自身的pid写入单锁文件
echo $$ > ${LOCKFILE}

while [[ true ]]; do
    sleep 5
done

# 正常结束时,删除单锁文件
rm -f ${LOCKFILE}

智能终端Chrome监控插件

公司的智能终端使用浏览器客户端来与服务器网站交互。用户看到的智能终端界面,其实是公司的终端服务网站平台。
而浏览器与网站的互通互信会因网络的变化而产生很多错误,比如智能终端连不到网络、DNS解析有问题、或是因网速太慢打不开网站等等……。
这个时候浏览器表现出来的结果是非常不友好的;而且用户可以通过浏览器的错误信息页面跳转到其它地方,或是通过浏览源代码的方式打开系统文件夹等等…………
很明显,这样的结果是不可控的,公司的智能终端只能访问到公司的网站平台,才是公司想要的效果。
所以,经过Firefox,Opera,Chrome的一段时间测试与实践之后,因Chrome在linux下的稳定和速度都很有优势,所以公司决定使用Chrome代替原来的Firefox,Opear。
以是就需要对终端与网站平台的通讯做监控。原来在处理opera的时候,全是使用bash来实现,实时监控并替换相关的opera出错界面;等待网络正常,又跳转回原来的页面。
当然,使用原来的模式,我们也可以做到监控。但是使用Chrome插件的方式,更符合我们的实际要求。所以这个插件就产生了。

功能:
1.只允许Chrome打开一个window [窗口]
2.只允许Chrome打开一个tab [标签]
3.新开一个tab标签后,会把原来所有的标签关闭 [这是为了方便从终端执行google-chrome来调用新的页面]
4.只能浏览规定的网站,如果不是规定的网站,则跳到初始页面。
5.浏览器出错后,显示指定的友好界面。
6.当网络出现问题后,替换出错页面。并开始实时探测与服务器的通讯。一直探测到正常后才停止,并恢复界面成网站首页。

manifest.json

{
  "name": "OpenkkMonitor",
  "version": "1.0",
  "description": "Openkk智能终端网购机监控插件",
  "background_page": "background.html",
  "homepage_url":"http://www.0x001.com",
  "incognito": "split",
  "chrome_url_overrides": {
    "newtab": "html/index.html"
  },
  "content_scripts": [
    {
      "matches": ["http://*/*"],
      "js": ["openkkMonitor.js"]
    }
  ],
  "permissions": ["tabs", "webRequest", "webRequestBlocking", "webNavigation", "management", "http://*/*", "https://*/*"],
  "manifest_version": 1
}

background.html

/*//////////////////////////////////////////////////////////
//                                                        //
//   OpenkkMonitor! OpenKK网购机监控插件                  //
//   Copyright (c) 2012 0x001 ( http://www.0x001.com )    //
//                                                        //
//////////////////////////////////////////////////////////*/

<script type="text/javascript">// <![CDATA[
            var timer;
            var isFailing = false;
            var FailNum =0;
            var appID='';
            var appBackgroundUrl = '';
            var appCheckErrorURL= "http://www.openkk.cn/1.txt?";
            var xhr = new XMLHttpRequest();
            var currentTabID = 0;

            // 获取本扩展插件的ID
            chrome.management.getAll(function(info) {
                for (var i = 0; i < info.length; i++) {
                    if (info[i].name == "OpenkkMonitor"){
                    appID = info[i].id;
                    appBackgroundUrl = 'chrome-extension://'+ appID + '/background.html';
                    break;
                    }
                }
            });             

            // 判断网址是不是 [无效] 的
            function checkForInvalidUrl (url) {
                var str = '.mapabc.com|';
                    str += '.0x001.|';
                    str += '.openkk.|';
                    str += '.665.|';
                    str += '.google.|';
                    str += 'maps.gstatic.cn|';
                    str += '.china-gift.|';
                    str += 'chrome:|chrome-|';
                    str += 'localhost|127.0.0.1|';
                    str += 'file:///|about:blank';
                var reg = new RegExp(str);
                if (reg.test(url))
                {
                     return false;
                }else{
                     return true;
                }
            }           

            //判断提交到服务器是否成功
            function checkRequestVaild(){
                try{
                    xhr.open("GET", appCheckErrorURL + new Date().getTime(), false);
                    xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4 && xhr.status == 200) {
                            if (xhr.responseText == '1'){
                                isFailing = false;
                                FailNum=0;
                            }
                        }
                    }
                    xhr.send();
                }
                catch(e){}

                if (!isFailing){
                    clearTimeout(timer);
                    chrome.tabs.update(currentTabID,{url:'http://www.openkk.cn/m'});
                }else{
                    timer = setTimeout("checkRequestVaild()",1000);
                }
            }

            // [Http请求] 出错处理
            function requestErrorHandler(error,id,Durl){
                switch(error){
                      case 'net::ERR_NAME_NOT_RESOLVED':
                            // 不能解决域名解析,一般是网络还在,但是解析不到域名
                            SetErrorHandler(id,'dns_error.html?'+ Durl);
                            break;
                      case 'net::ERR_NAME_RESOLUTION_FAILED':
                            // 域名解析失败,一般是网络断了
                            SetErrorHandler(id,'network_error.html?'+ Durl);
                            break;
                       case 'net::ERR_INTERNET_DISCONNECTED':
                            // 互联网连接已中断,无法连接到互联网
                            SetErrorHandler(id,'network_error.html?'+ Durl);
                            break;
            //           case 'net::ERR_EMPTY_RESPONSE':
            //                //服务器已断开连接,且未发送任何数据
            //                SetErrorHandler(id,'network_error.html?'+ Durl);
            //                break;
                       case 'net::ERR_CONNECTION_TIMED_OUT':
                            // 操作超时
                            SetErrorHandler(id,'timeout_error.html?'+ Durl);
                            break;
                       default:
                            break;
                }
            }

            // 设置错误
            function SetErrorHandler(id,Durl){
                chrome.tabs.update(id,{url:'html/'+ Durl});
                isFailing = true;  //标志出错了
                FailNum= FailNum+1;
                timer = setTimeout("checkRequestVaild()",1000);
            }

            // 监听[创建新的tab]
            chrome.tabs.onCreated.addListener(function(tab) {
                //alert('tabs.onCreated --'  + ' window: ' + tab.windowId + ' tab: ' + tab.id + ' index: '  + tab.index + ' url: ' + tab.url + ' AppID: ' + appID);
                //如果不是调试扩展的窗口
                if ( tab.url.indexOf('chrome-devtools://') <= -1 ){                     // 判断是否为第一个窗口,不是则关闭 (保持只有一个窗口)                     if (tab.windowId != 1) {                         chrome.windows.remove(tab.windowId);                     };                          // 如果打开的标签索引大于0 (只允许开一个标签)                     if (tab.index >0){
                       // 关闭前面所有标签,而不是当前标签 (为了配合命令行打开新标签指定特定的错误页面)
                        for (var i = 0; i < tab.id; i++) {
                           chrome.tabs.remove(i);
                        };
                        currentTabID = tab.id;
                    }
                }

            });  

            // 监听[任何标签的URL的更改]。
            chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab) {
              if (changeInfo.status == 'complete'){
                // 判断是否最后有没有错误产生
                if (typeof(chrome.extension.lastError) == 'undefined'){
                  currentTabID = tabId;
                }
              }
            });            

            // 监听所有 [Http请求] 的错误
            chrome.webRequest.onErrorOccurred.addListener(
                  function(details){
                        //如果标志是正常状态下出错了
                        if (isFailing == false){
                            requestErrorHandler(details.error,details.id,details.url);
                        }else{
                            //如果是出错状态,判断是否不属于Timer检测的状态
                            if (details.url.indexOf(appCheckErrorURL) == -1){
                                requestErrorHandler(details.error,details.id,details.url);
                            }
                        }
                  },
                  {urls:["<all_urls>"]}
            );

            // 监听任何 [Http请求事件之前]
            chrome.webRequest.onBeforeRequest.addListener(
                function(details) {
                    // 如果是无效的URL,拒绝访问
                    //return {cancel: checkForInvalidUrl(details.url)};

                    // 如果是无效的URL, 转向到插件的默认页
                    if (checkForInvalidUrl(details.url)){
                        return { redirectUrl: 'chrome-extension://'+ appID +'/html/index.html'};
                    }
                },
                {urls: ["<all_urls>"]},
                ["blocking"]
            );

// ]]></script>

利用虚拟键盘驱动uinput向系统发送按键指令

因为公司智能终端放置在外面,有一个像ATM机器一样的密码键盘.原本是作为银行卡密码输入确认的。

现在为了方便维护,一些简单的系统操作,就利用这个密码键盘来调用编写好的sh脚本。
但是因为终端机并没有插键盘,所以没有输入设备,这个时候只能利用与密码键盘通讯的支付程序,向系统发送按键指令。
所以,用到了uinput虚拟输入驱动,简单的说:用它可以在用户空间实现输入设备,向系统中注入输入事件。
下面,是我写好的输入按键的程序。

1.将下面的代码保存成 keyinput.c
2.编译:

$ gcc keyinput.c -o keyinput

3.加载 uinput驱动

$ sudo modprobe uinput
$ lsmod |grep uinput

4.将编译好的文件放到/usr/sbin/中

$ sudo cp keyinput /usr/sbin/
$ sudo chmod 755 /usr/sbin/keyinput

5.示例:向Linux桌面系统发送CTRL+ALT+D 清屏蔽指令

$ keyinput  29 56 32

6.keyinput 参数说明:后面跟着的参数全是ASCII码,对应的键盘ASCII码在 /usr/include/linux/input.h 中可以查询。

/*//////////////////////////////////////////
//    Simulated keyboard input program    //
//                by:0x001                //
//////////////////////////////////////////*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <linux/uinput.h>

#define die(str, args...) do {
        perror(str);
        exit(EXIT_FAILURE);
    } while(0)

int fd;
struct uinput_user_dev uidev; // uInput device structure
struct input_event     ev;  // Input device structure

/* Setup the uinput device */
void setup_uinput_device()
{
    int i=0;
    // Open the input device
    fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
    if(fd < 0)
        die("error: open /dev/uinput");

    memset(&uidev, 0, sizeof(uidev)); // Intialize the uInput device to NULL
    snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "uinput-Openkk");
    uidev.id.bustype = BUS_USB;
    uidev.id.vendor  = 0x1;
    uidev.id.product = 0x1;
    uidev.id.version = 1;
    // Setup the driver I/O channels
    ioctl(fd, UI_SET_EVBIT, EV_KEY);
    ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
    for (i=0; i < 256; i++) {
        ioctl(fd, UI_SET_KEYBIT, i);
    }
    ioctl(fd, UI_SET_EVBIT, EV_REL);
    ioctl(fd, UI_SET_RELBIT, REL_X);
    ioctl(fd, UI_SET_RELBIT, REL_Y);

    /* Create input device into input sub-system */
    write(fd, &uidev, sizeof(uidev));
    if(ioctl(fd, UI_DEV_CREATE) < 0)
        die("error: create uinput device");
}

// Simulated keyboard input
void simulate_key(int keycode, int keyvalue)
{
    memset(&ev, 0, sizeof(struct input_event));
    gettimeofday(&ev.time, NULL);
    ev.type = EV_KEY;
    ev.code = keycode;
    ev.value = keyvalue;
    if(write(fd, &ev, sizeof(struct input_event)) < 0)
    {
            printf("simulate key errorn");
            return;
    }else{
        printf("simulate key %d, %dn", keycode, keyvalue);
    }

}

void simulate_key_end()
{
    memset(&ev, 0, sizeof(struct input_event));
    ev.type = EV_SYN;
    ev.code = 0;
    ev.value = 0;
    write(fd, &ev, sizeof(struct input_event));
}

//  check the key is control key
int check_valid_control_key(int key)
 {
      int control_key[] = {29,42,54,56,97,100,125,126};
      int len = sizeof(control_key) / sizeof(control_key[0]);
      int i;
      int ret = 0;
      for ( i = 0; i < len; i++)
      {
          if (control_key[i] == key)
          {
              ret = 1;
              break;
          }
      }
      return ret;
 }

int main(int argc, char *argv[])
{
    if (argc <=1)
    {
        printf("n  /*//////////////////////////////////////////n");
        printf("  //    Simulated keyboard input program    //n");
        printf("  //                by:0x001                //n");
        printf("  //////////////////////////////////////////*/nn");
        printf("  Usage : keyinput <kye number> [key number...]n");
        printf("          keyinput 29 56 32  /* CTRL + ALT +D */n");
        printf("          keyinput 125 32  /* WIN +D */nn");
        printf("  /* Types of key number are defined in /usr/include/linux/input.h */nn");
        printf("  /* tools need to load the kernel module: uinput */nn");
        printf("  /* $ sudo modprobe uinput */nn");
        return 0;
    }

    setup_uinput_device();

    sleep(1);
    int key;
    int i;

    for (i=1; i < argc; i++)
    {
        key = atoi(argv[i]);
        simulate_key(key,1);
        if (check_valid_control_key(key) == 0)
        {
            simulate_key(key,0);
        }
    }

    for (i=1; i < argc; i++)
    {
        key = atoi(argv[i]);
        if (check_valid_control_key(key) == 1)
        {
            simulate_key(key,0);
        }
    }

    simulate_key_end();
    if(ioctl(fd, UI_DEV_DESTROY) < 0)
        die("error: ioctl");
    close(fd);

    return 0;
}

GRUB rescue 模式下修复引导(ubuntu)

手贱呀,由于使用EasyBCD做双系统引导,看着等待时间3秒太长,设置成1秒,结果开机的时候不能选择了,直接跳过。接着在GRUB设置页面选择了/dev/sda1引到了机器的恢复分区。GRUB就搞坏了。。。
再重启的时候,进入了grub rescue> 状态下。于是,就只能修复了。

rescue模式下可使用的命令有:set,ls,insmod,root,prefix

grub rescue> ls         #查看所有分区,接着一个一个的ls目标,找到/boot/grub目录。如果知道原来Linux引导分区放哪里,直接ls查看。
grub rescue> ls (hd0,8)/boot/grub/      #确定了Linux引导分区在 (hd0,8)
grub rescue> set root=(hd0,8)          #设置启动分区
grub rescue> set prefix=(hd0,8)/boot/grub       #设置grub的启动目录
grub rescue> insmod /boot/grub/normal.mod       # 设置正常引导的内核模块
grub rescue> normal     #进入grub正常引导界面

第二步:进入Linux系统后,修复grub
sudo update-grub #会列出所有能引导的列表

第三步:
sudo grub-install /dev/sda
提示: Installation finished. No error reported.就代表成功,没有任何错误。

BT5 R2 下 Metasploit使用postgersql数据库

1,先查看postgresql的端口,默认是自动开启的,端口7337 。

root@bt:~# netstat -tnpl |grep postgres
tcp        0      0 127.0.0.1:7337          0.0.0.0:*               LISTEN      1100/postgres
tcp6       0      0 ::1:7337                :::*                    LISTEN      1100/postgres

2,查看msf的配置,里面有数据库用户和密码

root@bt:~# cat /opt/metasploit/config/database.yml
development:
  adapter: "postgresql"
  database: "msf3dev"
  username: "msf3"
  password: "c80c3cea"
  port: 7337
  host: "localhost"
  pool: 256
  timeout: 5

3,开启msf专业版

# /opt/metasploit/msfpro

4,连接数据库

msf> db_connect msf3:c80c3cea@127.0.0.1:7337/msf3

Linux Web服务器TCP Socket的优化

修改文件 /etc/sysctl.conf:

net.ipv4.tcp_tw_recycle = 1
#表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭.

net.ipv4.tcp_tw_reuse = 1
#表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭;

net.ipv4.tcp_syncookies = 1
#表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭;

net.ipv4.tcp_fin_timeout = 30
#对于本端断开的socket连接,TCP保持在FIN_WAIT_2状态的时间。对方可能会断开连接或一直不结束连接或不可预料的进程死亡。默认值为 60 秒。
# /sbin/sysctl -p

Apache分割日志

首先下载cronolog分割工具,习惯用Apache自带的rotatelogs也行.
#wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
编译安装,然后配置

<VirtualHost *:80>
    DocumentRoot /web/www.0x001.com
    php_admin_value open_basedir /tmp:/web/www.0x001.com
    ServerName www.0x001.com
    ErrorLog "|/usr/local/sbin/cronolog /var/log/httpd/%Y%m%d/www.0x001.com-error_log"
    CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/%Y%m%d/www.0x001.com-access_log" common
 <Directory "/web/www.0x001.com">
    AllowOverride All
 </Directory>
</VirtualHost>

CustomLog “|/usr/local/sbin/cronolog /var/log/httpd/%Y%m%d/www.0×001.com-access_log” common
这样把日志存在每天的日期目录中.