Unicode/UTF-8

=============很久以前保存的,别人写的但是很明了=============

很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物。他们看到8个开关状态是好的,于是他们把这称为”字节“。再后来,他们又做了一些可以处理这些字节的机器,机器开动了,可以用字节来组合出很多状态,状态开始变来变去。他们看到这样是好的,于是它们就这机器称为”计算机“。

开始计算机只在美国用。八位的字节一共可以组合出256(2的8次方)种不同的状态。
他们把其中的编号从0开始的32种状态分别规定了特殊的用途,一但终端、打印机遇上约定好的这些字节被传过来时,就要做一些约定的动作。遇上0×10,
终端就换行,遇上0×07, 终端就向人们嘟嘟叫,例好遇上0x1b,
打印机就打印反白的字,或者终端就用彩色显示字母。他们看到这样很好,于是就把这些0×20以下的字节状态称为”控制码”。他们又把所有的空
格、标点符号、数字、大小写字母分别用连续的字节状态表示,一直编到了第127号,这样计算机就可以用不同字节来存储英语的文字了。大家看到这样,都感觉
很好,于是大家都把这个方案叫做 ANSI 的”Ascii”编码(American Standard Code for Information Interchange,美国信息互换标准代码)。当时世界上所有的计算机都用同样的ASCII方案来保存英文文字。

后来,就像建造巴比伦塔一样,世界各地的都开始使用计算机,但是很多国家用的不是英文,他们的字母里有许多是ASCII里没有的,为了可以在计算机
保存他们的文字,他们决定采用
127号之后的空位来表示这些新的字母、符号,还加入了很多画表格时需要用下到的横线、竖线、交叉等形状,一直把序号编到了最后一个状态255。从128
到255这一页的字符集被称”扩展字符集“。从此之后,贪婪的人类再没有新的状态可以用了,美帝国主义可能没有想到还有第三世界国家的人们也希望可以用到计算机吧!

等中国人们得到计算机时,已经没有可以利用的字节状态来表示汉字,况且有6000多个常用汉字需要保存呢。但是这难不倒智慧的中国人民,我们不客气
地把那些127号之后的奇异符号们直接取消掉,
规定:一个小于127的字符的意义与原来相同,但两个大于127的字符连在一起时,就表示一个汉字,前面的一个字节(他称之为高字节)从0xA1用到
0xF7,后面一个字节(低字节)从0xA1到0xFE,这样我们就可以组合出大约7000多个简体汉字了。在这些编码里,我们还把数学符号、罗马希腊的
字母、日文的假名们都编进去了,连在 ASCII
里本来就有的数字、标点、字母都统统重新编了两个字节长的编码,这就是常说的”全角”字符,而原来在127号以下的那些就叫”半角”字符了。
中国人民看到这样很不错,于是就把这种汉字方案叫做 “GB2312“。GB2312 是对 ASCII 的中文扩展。

但是中国的汉字太多了,我们很快就就发现有许多人的人名没有办法在这里打出来,特别是某些很会麻烦别人的国家领导人。于是我们不得不继续把
GB2312 没有用到的码位找出来老实不客气地用上。
后来还是不够用,于是干脆不再要求低字节一定是127号之后的内码,只要第一个字节是大于127就固定表示这是一个汉字的开始,不管后面跟的是不是扩展字
符集里的内容。结果扩展之后的编码方案被称为 GBK 标准,GBK包括了GB2312 的所有内容,同时又增加了近20000个新的汉字(包括繁体字)和符号。 后来少数民族也要用电脑了,于是我们再扩展,又加了几千个新的少数民族的字,GBK扩成了 GB18030。从此之后,中华民族的文化就可以在计算机时代中传承了。 中国的程序员们看到这一系列汉字编码的标准是好的,于是通称他们叫做 “DBCS“(Double
Byte Charecter Set
双字节字符集)。在DBCS系列标准里,最大的特点是两字节长的汉字字符和一字节长的英文字符并存于同一套编码方案里,因此他们写的程序为了支持中文处
理,必须要注意字串里的每一个字节的值,如果这个值是大于127的,那么就认为一个双字节字符集里的字符出现了。那时候凡是受过加持,会编程的计算机僧侣
们都要每天念下面这个咒语数百遍: “一个汉字算两个英文字符!一个汉字算两个英文字符……”

因为当时各个国家都像中国这样搞出一套自己的编码标准,结果互相之间谁也不懂谁的编码,谁也不支持别人的编码,连大陆和台湾这样只相隔了150海
里,使用着同一种语言的兄弟地区,也分别采用了不同的 DBCS
编码方案——当时的中国人想让电脑显示汉字,就必须装上一个”汉字系统”,专门用来处理汉字的显示、输入的问题,但是那个台湾的愚昧封建人士写的算命程序
就必须加装另一套支持 BIG5
编码的什么”倚天汉字系统”才可以用,装错了字符系统,显示就会乱了套!这怎么办?而且世界民族之林中还有那些一时用不上电脑的穷苦人民,他们的文字又怎
么办? 真是计算机的巴比伦塔命题啊!

正在这时,大天使加百列及时出现了——一个叫 ISO
(国际标谁化组织)的国际组织决定着手解决这个问题。他们采用的方法很简单:废了所有的地区性编码方案,重新搞一个包括了地球上所有文化、所有字母和符号
的编码!他们打算叫它”Universal Multiple-Octet Coded Character Set”,简称 UCS, 俗称 “unicode“。

unicode开始制订时,计算机的存储器容量极大地发展了,空间再也不成为问题了。于是 ISO
就直接规定必须用两个字节,也就是16位来统一表示所有的字符,对于ASCII里的那些“半角”字符,unicode包持其原编码不变,只是将其长度由原
来的8位扩展为16位,而其他文化和语言的字符则全部重新统一编码。由于”半角”英文符号只需要用到低8位,所以其高8位永远是0,因此这种大气的方案在
保存英文文本时会多浪费一倍的空间。

这时候,从旧社会里走过来的程序员开始发现一个奇怪的现象:他们的strlen函数靠不住了,一个汉字不再是相当于两个字符了,而是一个!是的,从unicode开始,无论是半角的英文字母,还是全角的汉字,它们都是统一的”一个字符“!同时,也都是统一的”两个字节“,请注意”字符”和”字节”两个术语的不同,“字节”是一个8位的物理存贮单元,而“字符”则是一个文化相关的符号。在unicode中,一个字符就是两个字节。一个汉字算两个英文字符的时代已经快过去了。

unicode同样也不完美,这里就有两个的问题,一个是,如何才能区别unicode和ascii?计算机怎么知道三个字节表示一个符号,而不是
分别表示三个符号呢?第二个问题是,我们已经知道,英文字母只用一个字节表示就够了,如果unicode统一规定,每个符号用三个或四个字节表示,那么每
个英文字母前都必然有二到三个字节是0,这对于存储空间来说是极大的浪费,文本文件的大小会因此大出二三倍,这是难以接受的。

unicode在很长一段时间内无法推广,直到互联网的出现,为解决unicode如何在网络上传输的问题,于是面向传输的众多 UTF(UCS Transfer Format)标准出现了,顾名思义,UTF-8就是每次8个位传输数据,而UTF-16就是每次16个位。UTF-8就是在互联网上使用最广的一种unicode的实现方式,这是为传输而设计的编码,并使编码无国界,这样就可以显示全世界上所有文化的字符了。

UTF-8最大的一个特点,就是它是一种变长的编码方式。它可以使用1~4个字节表示一个符号,根据不同的符号而变化字节长度,当字符在ASCII
码的范围时,就用一个字节表示,保留了ASCII字符一个字节的编码做为它的一部分,注意的是unicode一个中文字符占2个字节,而UTF-8一个中
文字符占3个字节)。从unicode到uft-8并不是直接的对应,而是要过一些算法和规则来转换。

Unicode符号范围 | UTF-8编码方式

(十六进制) | (二进制)
—————————————————————–
0000 0000-0000 007F | 0xxxxxxx
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

 

以上内容来源:http://www.zhihu.com/question/23374078/answer/69732605

发表在 technologys | 标签为 , | Unicode/UTF-8已关闭评论

Java/Android RSA使用时注意补位

java

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); 

android

Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding"); 

参考:
 
http://stackoverflow.com/questions/6069369/rsa-encryption-difference-between-java-and-android
http://stackoverflow.com/questions/2956647/rsa-encrypt-with-base64-encoded-public-key-in-android

发表在 java | 标签为 | Java/Android RSA使用时注意补位已关闭评论

java base64

代码来源于网络

import java.io.UnsupportedEncodingException;  

public class Base64Utils  
{  
    private static char[] base64EncodeChars = new char[]  
    { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',  
            'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',  
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',  
            '6', '7', '8', '9', '+', '/' };  
    private static byte[] base64DecodeChars = new byte[]  
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  
            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53,  
            54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,  
            12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29,  
            30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1,  
            -1, -1, -1 };  
 
    /**
     * 加密
     *  
     * @param data
     * @return
     */  
    public static String encode(byte[] data)  
    {  
        StringBuffer sb = new StringBuffer();  
        int len = data.length;  
        int i = 0;  
        int b1, b2, b3;  
        while (i < len)  
        {  
            b1 = data[i++] & 0xff;  
            if (i == len)  
            {  
                sb.append(base64EncodeChars[b1 >>> 2]);  
                sb.append(base64EncodeChars[(b1 & 0x3) << 4]);  
                sb.append("==");  
                break;  
            }  
            b2 = data[i++] & 0xff;  
            if (i == len)  
            {  
                sb.append(base64EncodeChars[b1 >>> 2]);  
                sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]);  
                sb.append(base64EncodeChars[(b2 & 0x0f) << 2]);  
                sb.append("=");  
                break;  
            }  
            b3 = data[i++] & 0xff;  
            sb.append(base64EncodeChars[b1 >>> 2]);  
            sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]);  
            sb.append(base64EncodeChars[((b2 & 0x0f) << 2) | ((b3 & 0xc0) >>> 6)]);  
            sb.append(base64EncodeChars[b3 & 0x3f]);  
        }  
        return sb.toString();  
    }  
 
    /**
     * 解密
     *  
     * @param str
     * @return
     */  
    public static byte[] decode(String str)  
    {  
        try  
        {  
            return decodePrivate(str);  
        } catch (UnsupportedEncodingException e)  
        {  
            e.printStackTrace();  
        }  
        return new byte[]  
        {};  
    }  
 
    private static byte[] decodePrivate(String str) throws UnsupportedEncodingException  
    {  
        StringBuffer sb = new StringBuffer();  
        byte[] data = null;  
        data = str.getBytes("US-ASCII");  
        int len = data.length;  
        int i = 0;  
        int b1, b2, b3, b4;  
        while (i < len)  
        {  
 
            do  
            {  
                b1 = base64DecodeChars[data[i++]];  
            } while (i < len && b1 == -1);  
            if (b1 == -1)  
                break;  
 
            do  
            {  
                b2 = base64DecodeChars[data[i++]];  
            } while (i < len && b2 == -1);  
            if (b2 == -1)  
                break;  
            sb.append((char) ((b1 << 2) | ((b2 & 0x30) >>> 4)));  
 
            do  
            {  
                b3 = data[i++];  
                if (b3 == 61)  
                    return sb.toString().getBytes("iso8859-1");  
                b3 = base64DecodeChars[b3];  
            } while (i < len && b3 == -1);  
            if (b3 == -1)  
                break;  
            sb.append((char) (((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));  
 
            do  
            {  
                b4 = data[i++];  
                if (b4 == 61)  
                    return sb.toString().getBytes("iso8859-1");  
                b4 = base64DecodeChars[b4];  
            } while (i < len && b4 == -1);  
            if (b4 == -1)  
                break;  
            sb.append((char) (((b3 & 0x03) << 6) | b4));  
        }  
        return sb.toString().getBytes("iso8859-1");  
    }  
 

...

发表在 java | 标签为 | java base64已关闭评论

Crontab / Cron Expressions

cron表达式和Linux下的很类似,比如 "/5 * * ? * * *"  这样的7位表达式,最后一位非必选。

表达式从左到右,依此是秒、分、时、月第几天、月、周几、年。下面表格是要遵守的规范:

段名 允许的值 允许的特殊字符
Seconds 0-59 , - * /
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day of month 1-31 , - * ? / L W
Month 1-12 or JAN-DEC , - * /
Day of week 1-7 or SUN-SAT , - * ? / L #
Year 空, 1970-2099 , - * /

 

特殊字符 解释
, 或的意思。例:分钟位 5,10  即第5分钟或10分都触发。
/ a/b。 a:代表起始时间,b频率时间。 例; 分钟位  3/5,  从第三分钟开始,每5分钟执行一次。
* 频率。 即每一次波动。    例;分钟位 *  即表示每分钟
- 区间。  例: 分钟位   5-10 即5到10分期间。
? 任意值 。   即每一次波动。只能用在DayofMonth和DayofWeek,二者冲突。指定一个另一个一个要用?
L 表示最后。 只能用在DayofMonth和DayofWeek,4L即最后一个星期三
W 工作日。  表示最后。 只能用在DayofWeek
# 4#2。 只能用DayofMonth。 某月的第二个星期三

 

实例介绍

”0 0 10,14,16 * * ?"    每天10点,14点,16点 触发。

"0 0/5 14,18 * * ?"    每天14点或18点中,每5分钟触发 。

"0 4/15 14-18 * * ?"       每天14点到18点期间,  从第四分钟触发,每15分钟一次。

"0 15 10 ? * 6L"        每月的最后一个星期五上午10:15触发。

 

一些完整的Cron- Expressions例子:

表达式

意思

0 0 12 * * ? 每天12:00执行触发
0 15 10 ? * * 每天10:15执行触发
0 15 10 * * ? 每天10:15执行触发
0 15 10 * * ? * 每天10:15执行触发
0 15 10 * * ? 2005 2005年的每天10:15执行触发
0 * 14 * * ? 每天从14:00到14:59每隔1分钟执行一次触发
0 0/5 14 * * ? 每天从14:00到14:59每个5分钟执行一次触发
0 0/5 14,18 * * ? 每天从14:00到14:59和18:00到18:59每隔5分钟执行一次触发
0 0-5 14 * * ? 每天从14:00到14:05每隔1分钟执行一次触发
0 10,44 14 ? 3 WED 3月的每个星期3的14:10和14:44分别执行一次触发
0 15 10 15 * ? 每月的第15日10:15执行一次触发
0 15 10 L * ? 每月最后一天的10:15执行一次触发
0 15 10 ? * 6L 每月的最后一个星期5的10:15执行一次触发
0 15 10 ? * 2002-2005 2002、2003、2004、2005年的每个月的最后一个星期5的10:15执行一次触发
0 15 10 ? * 6#3 每月的第3个星期5的10:15执行一次触发
 */5 * * * * 每五分钟
 0 * * * * 每小时
 0 0 * * * 每天
 0 0 * * 0  每周
 0 0 1 * *  每月
 0 0 1 1 *  每年

 

linux/unix:  crontab 格式:

crontab文件中,每一行都代表一项任务,每行的每个字段代表一项设置,它的格式共分为六个字段,前五段是时间设定段,第六段是要执行的命令段,格式如下:
minute   hour   day   month   week   command

其中:
minute: 表示分钟,可以是从0到59之间的任何整数。
hour:表示小时,可以是从0到23之间的任何整数。
day:表示日期,可以是从1到31之间的任何整数。
month:表示月份,可以是从1到12之间的任何整数。
week:表示星期几,可以是从0到7之间的任何整数,这里的0或7代表星期日。

command:要执行的命令,可以是系统命令,也可以是自己编写的脚本文件。

代表意义 分钟 小时 日期 月份 命令
数字范围 0~59 0~23 1~31 1~12 0~7 需要执行的命令

 

特殊字符:
星号(*):代表所有可能的值,例如month字段如果是星号,则表示在满足其它字段的制约条件后每月都执行该命令操作。
逗号(,):可以用逗号隔开的值指定一个列表范围,例如,“1,2,5,7,8,9”
中杠(-):可以用整数之间的中杠表示一个整数范围,例如“2-6”表示“2,3,4,5,6”
正斜线(/):可以用正斜线指定时间的间隔频率,例如“0-23/2”表示每两小时执行一次。同时正斜线可以和星号一起使用,例如*/10,如果用在minute字段,表示每十分钟执行一次。

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

除了数字还有几个个特殊的符号就是"*"、"/"和"-"、",",*代表所有的取值范围内的数字,"/"代表每的意思,"/5"表示每5个单位,"-"代表从某个数字到某个数字,","分开几个离散的数字。

-l 在标准输出上显示当前的crontab。
-r 删除当前的crontab文件。
-e 使用VISUAL或者EDITOR环境变量所指的编辑器编辑当前的crontab文件。当结束编辑离开时,编辑后的文件将自动安装。

例子: 
每天早上6点
0 6 * * * echo "Good morning." >> /tmp/test.txt

每两个小时
0 */2 * * * echo "Have a break now." >> /tmp/test.txt

晚上11点到早上8点之间每两个小时和早上八点
0 23-7/2,8 * * * echo "Have a good dream" >> /tmp/test.txt

每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4 * 1-3 command line

1月1日早上4点
0 4 1 1 * command line SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root
//如果出现错误,或者有数据输出,数据作为邮件发给这个帐号 HOME=/

每小时执行/etc/cron.hourly内的脚本
01 * * * * root run-parts /etc/cron.hourly

每天执行/etc/cron.daily内的脚本
02 4 * * * root run-parts /etc/cron.daily

每星期执行/etc/cron.weekly内的脚本
22 4 * * 0 root run-parts /etc/cron.weekly

每月去执行/etc/cron.monthly内的脚本
42 4 1 * * root run-parts /etc/cron.monthly

注意: "run-parts"这个参数了,如果去掉这个参数的话,后面就可以写要运行的某个脚本名,而不是文件夹名。

每天的下午4点、5点、6点的5 min、15 min、25 min、35 min、45 min、55 min时执行命令。
5,15,25,35,45,55 16,17,18 * * * command

每周一,三,五的下午3:00系统进入维护状态,重新启动系统。
00 15 * * 1,3,5 shutdown -r +5

每小时的10分,40分执行用户目录下的innd/bbslin这个指令:
10,40 * * * * innd/bbslink

每小时的1分执行用户目录下的bin/account这个指令:
1 * * * * bin/account

每天早晨三点二十分执行用户目录下如下所示的两个指令(每个指令以;分隔):
20 3 * * * (/bin/rm -f expire.ls logins.bad;bin/expire$#@62;expire.1st)

每年的一月和四月,4号到9号的3点12分和3点55分执行/bin/rm -f expire.1st这个指令,并把结果添加在mm.txt这个文件之后(mm.txt文件位于用户自己的目录位置)。
12,55 3 4-9 1,4 * /bin/rm -f expire.1st$#@62;$#@62;mm.txt

 

1.每分钟定时执行一次规则:
每1分钟执行: */1 * * * *或者* * * * *
每5分钟执行: */5 * * * *

2.每小时定时执行一次规则:
每小时执行: 0 * * * *或者0 */1 * * *
每天上午7点执行:0 7 * * *
每天上午7点10分执行:10 7 * * *

3.每天定时执行一次规则:
每天执行 0 0 * * *

4.每周定时执行一次规则:
每周执行 0 0 * * 0

5.每月定时执行一次规则:
每月执行 0 0 1 * *

6.每年定时执行一次规则:
每年执行 0 0 1 1 *

7.其他例子
5 * * * * 指定每小时的第5分钟执行一次ls命令
30 5 * * * ls 指定每天的 5:30 执行ls命令
30 7 8 * * ls 指定每月8号的7:30分执行ls命令
30 5 8 6 * ls 指定每年的6月8日5:30执行ls命令
30 6 * * 0 ls 指定每星期日的6:30执行ls命令[注:0表示星期天,1表示星期1,以此类推,也可以用英文来表示,sun表示星期天,mon表示星期一等。]
30 3 10,20 * * ls 每月10号及20号的3:30执行ls命令[注:“,”用来连接多个不连续的时段]
25 8-11 * * * ls 每天8-11点的第25分钟执行ls命令[注:“-”用来连接连续的时段]
*/15 * * * * ls 每15分钟执行一次ls命令 [即每个小时的第0 15 30 45 60分钟执行ls命令 ]
30 6 */10 * * ls 每个月中,每隔10天6:30执行一次ls命令[即每月的1、11、21、31日是的6:30执行一次ls命令。 ]

crontab中的输出配置

crontab中经常配置运行脚本输出为:>/dev/null 2>&1,来避免crontab运行中有内容输出。
shell命令的结果可以通过‘> ’的形式来定义输出
/dev/null 代表空设备文件
> 代表重定向到哪里,例如:echo "123" > /home/123.txt
1 表示stdout标准输出,系统默认值是1,所以">/dev/null"等同于"1>/dev/null"
2 表示stderr标准错误
& 表示等同于的意思,2>&1,表示2的输出重定向等同于1
那么重定向输出语句的含义:
1>/dev/null 首先表示标准输出重定向到空设备文件,也就是不输出任何信息到终端,不显示任何信息。
2>&1 表示标准错误输出重定向等同于标准输出,因为之前标准输出已经重定向到了空设备文件,所以标准错误输出也重定向到空设备文件。

 

 

发表在 technologys | 标签为 , | Crontab / Cron Expressions已关闭评论

common port

计算机之间依照互联网传输层TCP/IP协议不同的协议通信,都有不同的对应端口。所以,利用短信(datagram)的UDP,所采用的端口号码不一定和采用TCP的端口号码一样。以下为两种通信协议的端口列表链接:

端口状态颜色图例

以下方块,以如下颜色和标签,标明了端口的状态:

使用状态 叙述 颜色
官方 应用与端口组合记录在IANA的端口分配列表中[1]
非官方 应用与端口组合不在IANA的端口分配列表中;
多重使用 已知多个应用程序使用这个 port.

0到1023号端口

以下列表仅列出常用端口,详细的列表请参阅IANA网站。

端口 描述 状态
0/TCP,UDP 保留端口;不使用(若发送过程不准备接受回复消息,则可以作为源端口) 官方
1/TCP,UDP TCPMUX(传输控制协议端口服务多路开关选择器) 官方
5/TCP,UDP RJE(远程作业登录) 官方
7/TCP,UDP ECHO(回显)协议 官方
9/TCP,UDP DISCARD(丢弃)协议 官方
11/TCP,UDP SYSTAT协议 官方
13/TCP,UDP DAYTIME协议 官方
15/TCP,UDP NETSTAT协议 官方
17/TCP,UDP QOTD(Quote of the Day,每日引用)协议 官方
18/TCP,UDP 消息发送协议 官方
19/TCP,UDP CHARGEN(字符发生器)协议 官方
20/TCP,UDP 文件传输协议 - 默认数据端口 官方
21/TCP,UDP 文件传输协议 - 控制端口 官方
22/TCP,UDP SSH (Secure Shell) - 远程登录协议,用于安全登录文件传输SCPSFTP)及端口重新定向 官方
23/TCP,UDP Telnet 终端仿真协议 - 未加密文本通信 官方
25/TCP,UDP SMTP(简单邮件传输协议) - 用于邮件服务器间的电子邮件传递 官方
26/TCP,UDP RSFTP - 一个简单的类似FTP的协议 非官方
35/TCP,UDP QMS Magicolor 2 printer 非官方
37/TCP,UDP TIME时间协议 官方
39/TCP,UDP Resource Location Protocol(资源定位协议) 官方
41/TCP,UDP 图形 官方
42/TCP,UDP Host Name Server(主机名服务) 官方
42/TCP,UDP WINS(WINS主机名服务) 非官方
43/TCP WHOIS 协议 官方
49/TCP,UDP TACACS 登录主机协议 官方
53/TCP,UDP DNS(域名服务系统) 官方
56/TCP,UDP 远程访问协议 官方
57/TCP MTP,邮件传输协议
67/UDP BOOTP(BootStrap协议)服务;同时用于动态主机设置协议 官方
68/UDP BOOTP 客户端;同时用于动态主机设定协议 官方
69/UDP TFTP(小型文件传输协议) 官方
70/TCP Gopher信息检索协议 官方
79/TCP Finger协议 官方
80/TCP HTTP(超文本传输协议)- 用于传输网页 官方
81/TCP HTTP预备(超文本传输协议) 官方
81/TCP Torpark -Onion routing ORport 非官方
82/UDP Torpark - 控制端口 非官方
88/TCP Kerberos - 认证代理 官方
101/TCP 主机名
102/TCP ISO-TSAP 协议
107/TCP 远程Telnet协议
109/TCP POP(Post Office Protocol),“邮局协议”,第2版
110/TCP POP3(“邮局协议”,第3版)- 用于接收电子邮件 官方
111/TCP,UDP Sun协议 官方
113/TCP ident - 旧的服务器身份识别系统,仍然被IRC 服务器用来认证它的用户 官方
115/TCP SFTP, 简单文件传输协议
117/TCP UUCP-PATH
118/TCP,UDP SQL 服务 官方
119/TCP 网络新闻传输协议 - 用来收取新闻组的消息 官方
123/UDP NTP (Network Time Protocol) - 用于时间同步 官方
135/TCP,UDP EPMAP (End Point Mapper) / Microsoft RPC Locator Service 官方
137/TCP,UDP NetBIOS NetBIOS Name Service 官方
138/TCP,UDP NetBIOS NetBIOS Datagram Service 官方
139/TCP,UDP NetBIOS NetBIOS Session Service 官方
143/TCP,UDP IMAP4 (Internet Message Access Protocol 4) - used for retrievingE-mails 官方
152/TCP,UDP BFTP, Background File Transfer Program
153/TCP,UDP SGMP, Simple Gateway Monitoring Protocol
156/TCP,UDP SQL服务 官方
158/TCP,UDP DMSP, Distributed Mail Service Protocol
161/TCP,UDP SNMP (Simple Network Management Protocol) 官方
162/TCP,UDP SNMPTRAP 官方
170/TCP Print-srv
179/TCP BGP (Border Gateway Protocol) 官方
194/TCP IRC (互联网中继聊天) 官方
201/TCP,UDP AppleTalk Routing Maintenance
209/TCP,UDP Quick Mail传输协议
213/TCP,UDP IPX 官方
218/TCP,UDP MPP,信息发布协议
220/TCP,UDP IMAP,交互邮件访问协议第3版
259/TCP,UDP ESRO, Efficient Short Remote Operations
264/TCP,UDP BGMP,Border Gateway Multicast Protocol
308/TCP Novastor Online Backup 官方
311/TCP Apple Server-Admin-Tool, Workgroup-Manager-Tool
318/TCP,UDP TSP,时间戳协议英语Time Stamp Protocol
323/TCP,UDP IMMP, Internet Message Mapping Protocol
383/TCP,UDP HP OpenView HTTPs Operations Agent
366/TCP,UDP SMTP, Simple Mail Transfer Protocol. ODMR, On-Demand Mail Relay
369/TCP,UDP Rpc2portmap 官方
371/TCP,UDP ClearCase albd 官方
384/TCP,UDP 一个远程网络服务器系统
387/TCP,UDP AURP, AppleTalk Update-based Routing Protocol
389/TCP,UDP 轻型目录访问协议 官方
401/TCP,UDP UPS Uninterruptible Power Supply 官方
411/TCP Direct Connect Hub port 非官方
412/TCP Direct Connect Client-To-Client port 非官方
427/TCP,UDP SLP (Service Location Protocol) 官方
443/TCP HTTPS -HTTP over TLS/SSL (加密传输) 官方
444/TCP,UDP SNPP,Simple Network Paging Protocol
445/TCP Microsoft-DS (Active Directory,Windows shares,Sasser worm,Agobot, Zobotworm) 官方
445/UDP Microsoft-DS SMB file sharing 官方
464/TCP,UDP Kerberos Change/Set password 官方
465/TCP Cisco protocol 官方
465/TCP SMTP overSSL 非官方
475/TCP tcpnethaspsrv (Hasp services, TCP/IP version) 官方
497/TCP dantz backup service 官方
500/TCP,UDP ISAKMP,IKE-Internet Key Exchange 官方
502/TCP,UDP Modbus,Protocol
512/TCP exec, Remote Process Execution
512/UDP comsat, together with biff:notifies users of new c.q. yet unread e-mail
513/TCP 登陆
513/UDP Who
514/TCP rsh protocol - used to execute non-interactive commandline commands on a remote system and see the screen return
514/UDP syslog protocol - used for system logging 官方
515/TCP Line Printer Daemon protocol - used in LPD printer servers
517/UDP Talk
518/UDP NTalk
520/TCP efs
520/UDP Routing - RIP 官方
513/UDP Router
524/TCP,UDP NCP (NetWare Core Protocol) is used for a variety things such as access to primary NetWare server resources, Time Synchronization, etc. 官方
525/UDP Timed,Timeserver
530/TCP,UDP 远程过程调用 官方
531/TCP,UDP AOL Instant Messenger, IRC 非官方
532/TCP netnews
533/UDP netwall, For Emergency Broadcasts
540/TCP UUCP (Unix-to-Unix Copy Protocol) 官方
542/TCP,UDP commerce (Commerce Applications) 官方
543/TCP klogin, Kerberos login
544/TCP kshell, Kerberos Remote shell
546/TCP,UDP DHCPv6 客户端
547/TCP,UDP DHCPv6 服务器
548/TCP AFP (Apple Filing Protocol)
550/UDP new-rwho, new-who
554/TCP,UDP RTSP (Real Time Streaming Protocol) 官方
556/TCP Remotefs, rfs, rfs_server
560/UDP rmonitor, Remote Monitor
561/UDP monitor
563/TCP,UDP NNTP protocol over TLS/SSL (NNTPS) 官方
587/TCP email message submission(SMTP) (RFC 2476) 官方
591/TCP FileMaker 6.0 (及之后版本)网络共享(HTTP的替代,见80端口) 官方
593/TCP,UDP HTTP RPC Ep Map(RPC over HTTP, often used by DCOM services and Microsoft Exchange Server 官方
604/TCP TUNNEL
631/TCP,UDP 互联网打印协议
636/TCP,UDP LDAP overSSL (加密传输,也被称为LDAPS) 官方
639/TCP,UDP MSDP, Multicast Source Discovery Protocol
646/TCP LDP, Label Distribution Protocol
647/TCP DHCP Failover Protocol
648/TCP RRP, Registry Registrar Protocol
652/TCP DTCP, Dynamic Tunnel Configuration Protocol
654/UDP AODV, Ad hoc On-Demand Distance Vector
665/TCP sun-dr, Remote Dynamic Reconfiguration 非官方
666/UDP 毁灭战士,电脑平台上的一系列第一人称射击游戏
674/TCP ACAP, Application Configuration Access Protocol
691/TCP MS Exchange Routing 官方
692/TCP Hyperwave-ISP
694/UDP Linux-HA High availability Heartbeat port 非官方
695/TCP IEEE-MMS-SSL
698/UDP OLSR, Optimized Link State Routing
699/TCP Access Network
700/TCP EPP, Extensible Provisioning Protocol
701/TCP LMP, Link Management Protocol.
702/TCP IRIS over BEEP
706/TCP SILC, Secure Internet Live Conferencing
711/TCP TDP, Tag Distribution Protocol
712/TCP TBRPF, Topology Broadcast based on Reverse-Path Forwarding
720/TCP SMQP, Simple Message Queue Protocol
749/TCP, UDP kerberos-adm, Kerberos administration
750/UDP Kerberos version IV
782/TCP Conserver serial-console management server
829/TCP CMP (Certificate Management Protocol)
860/TCP iSCSI
873/TCP rsync File synchronisation protocol 官方
901/TCP Samba Web Administration Tool (SWAT) 非官方
902 VMware服务器控制台[2] 非官方
904 VMware服务器替代(如果902端口已被占用) 非官方
911/TCP Network Console on Acid (NCA) - localtty redirection overOpenSSH
981/TCP SofaWare Technologies Remote HTTPS management for firewall devices running embeddedCheckpoint Firewall-1 software 非官方
989/TCP,UDP FTP Protocol (data) over TLS/SSL 官方
990/TCP,UDP FTP Protocol (control) over TLS/SSL 官方
991/TCP,UDP NAS (Netnews Admin System)
992/TCP,UDP Telnet protocol over TLS/SSL 官方
993/TCP IMAP4 overSSL (encrypted transmission) 官方
995/TCP POP3 overSSL (encrypted transmission) 官方


1024到49151号端口

以下列表仅列出常用端口,详细的列表请参阅IANA网站。

When investigating TCP traffic, be careful not to confuse the client and server ports. The client port is incremental, typically beginning at 1024 at boot time and wrapping at 4096.[来源请求] If the port you are investigating is in the lower part of this range, it may be a client port. Stateful firewalls identify the server port, but packet sniffers and stateless firewalls do not. For example, a packet sniffer showing a TCP packet with source port 1080 and destination port 1494 might be SOCKS or Citrix-ICA. The only way to know for sure is to examine the initial TCP handshake.

With UDP, client port selection depends on the application and may be incremental, fixed to a nonsensical value, or fixed equal to the server port.

端口 描述 状态
1025/tcp NFS-or-IIS 非官方
1026/tcp Often utilized by Microsoft DCOM services 非官方
1029/tcp Often utilized by Microsoft DCOM services 非官方
1058/tcp nim AIX Network Installation Manager 官方
1059/tcp nimreg 官方
1080/tcp SOCKS proxy 官方
1099/tcp RMI Registry 官方
1099/udp RMI Registry 官方
1109/tcp Kerberos POP
1140/tcp AutoNOC 官方
1167/udp phone, conference calling
1176/tcp Perceptive Automation Indigo home control server 官方
1182/tcp,udp AcceleNet 官方
1194/udp OpenVPN 官方
1198/tcp,udp The cajo project Free dynamic transparent distributed computing in Java 官方
1200/udp Steam Friends Applet 官方
1214/tcp Kazaa 官方
1223/tcp,udp TGP: "TrulyGlobal Protocol" aka "The Gur Protocol" 官方
1241/tcp,udp Nessus Security Scanner 官方
1248/tcp NSClient/NSClient++/NC_Net (Nagios) 非官方
1270/tcp,udp Microsoft Operations Manager 2005 agent (MOM 2005) 官方
1311/tcp Dell Open Manage Https Port 非官方
1313/tcp Xbiim (Canvii server) Port 非官方
1337/tcp WASTE Encrypted File Sharing Program 非官方
1352/tcp IBM Lotus Notes/Domino RPC 官方
1387/tcp Computer Aided Design Software Inc LM (cadsi-lm ) 官方
1387/udp Computer Aided Design Software Inc LM (cadsi-lm ) 官方
1414/tcp IBM MQSeries 官方
1431/tcp RGTP 官方
1433/tcp,udp Microsoft SQL database system 官方
1434/tcp,udp Microsoft SQL Monitor 官方
1494/tcp Citrix Presentation Server ICA Client 官方
1512/tcp,udp WINS
1521/tcp nCube License Manager 官方
1521/tcp Oracle database default listener, in future releases official port 2483 非官方
1524/tcp,udp ingreslock, ingres 官方
1526/tcp Oracle database common alternative for listener 非官方
1533/tcp IBM Sametime IM - Virtual Places Chat 官方
1547/tcp Laplink 官方
1547/udp Laplink 官方
1550 Gadu-Gadu (Direct Client-to-Client) 非官方
1581/udp MIL STD 2045-47001 VMF 官方
1589/udp Cisco VQP (VLAN Query Protocol) / VMPS 非官方
1627 iSketch 非官方
1677/tcp Novell GroupWise clients in client/server access mode
1701/udp l2tp, Layer 2 Tunnelling protocol
1716/tcp America's Army MMORPG Default Game Port 官方
1723/tcp Microsoft PPTP VPN 官方
1723/udp Microsoft PPTP VPN 官方
1725/udp Valve Steam Client 非官方
1755/tcp Microsoft Media Services (MMS, ms-streaming) 官方
1755/udp Microsoft Media Services (MMS, ms-streaming) 官方
1761/tcp,udp cft-0 官方
1761/tcp Novell Zenworks Remote Control utility 非官方
1762-1768/tcp,udp cft-1 to cft-7 官方
1812/udp radius, RADIUS authentication protocol
1813/udp radacct, RADIUS accounting protocol
1863/tcp Windows Live Messenger, MSN 官方
1900/udp Microsoft SSDP Enables discovery of UPnP devices 官方
1935/tcp Real Time Messaging Protocol (RTMP) raw protocol 官方
1970/tcp,udp Danware Data NetOp Remote Control 官方
1971/tcp,udp Danware Data NetOp School 官方
1972/tcp,udp InterSystems Caché 官方
1975-77/udp Cisco TCO (Documentation) 官方
1984/tcp Big Brother - network monitoring tool 官方
1985/udp Cisco HSRP 官方
1994/TCP STUN-SDLC protocol for tunneling
1998/tcp Cisco X.25 service (XOT)
2000/udp Cisco SCCP (Skinny) 官方
2000/tcp Cisco SCCP (Skinny) 官方
2002/tcp Cisco Secure Access Control Server (ACS) for Windows 非官方
2030 Oracle Services forMicrosoft Transaction Server 非官方
2031/tcp mobrien-chat - Mike O'Brien <mike@mobrien.com> November 2004 官方
2031/udp mobrien-chat - Mike O'Brien <mike@mobrien.com> November 2004 官方
2049/udp nfs, NFS Server 官方
2049/udp shilp 官方
2053/tcp knetd, Kerberos de-multiplexor
2056/udp Civilization 4 multiplayer 非官方
2073/tcp DataReel Database 官方
2073/udp DataReel Database 官方
2074/tcp Vertel VMF SA (i.e. App.. SpeakFreely) 官方
2074/udp Vertel VMF SA (i.e. App.. SpeakFreely) 官方
2082/tcp Infowave Mobility Server 官方
2082/tcp CPanel, default port 非官方
2083/tcp Secure Radius Service (radsec) 官方
2083/tcp CPanel default SSL port 非官方
2086/tcp GNUnet 官方
2086/tcp WebHost Manager default port 非官方
2087/tcp WebHost Manager default SSL port 非官方
2095/tcp CPanel default webmail port 非官方
2096/tcp CPanel default SSL webmail port 非官方
2161/tcp ?-APC Agent 官方
2181/tcp EForward-document transport system 官方
2181/udp EForward-document transport system 官方
2200/tcp Tuxanci game server 非官方
2219/tcp NetIQ NCAP Protocol 官方
2219/udp NetIQ NCAP Protocol 官方
2220/tcp NetIQ End2End 官方
2220/udp NetIQ End2End 官方
2222/tcp DirectAdmin's default port 非官方
2222/udp Microsoft Office OS X antipiracy network monitor [1] 非官方
2301/tcp HP System Management Redirect to port 2381 非官方
2302/udp ArmA multiplayer (default for game) 非官方
2302/udp Halo: Combat Evolved multiplayer 非官方
2303/udp ArmA multiplayer (default for server reporting)(default port for game +1) 非官方
2305/udp ArmA multiplayer (default for VoN)(default port for game +3) 非官方
2369/tcp Default port for BMC Software CONTROL-M/Server - Configuration Agent port number - though often changed during installation 非官方
2370/tcp Default port for BMC Software CONTROL-M/Server - Port utilized to allow the CONTROL-M/Enterprise Manager to connect to the CONTROL-M/Server - though often changed during installation 非官方
2381/tcp HP Insight Manager default port for webserver 非官方
2404/tcp IEC 60870-5-104 官方
2427/udp Cisco MGCP 官方
2447/tcp ovwdb - OpenView Network Node Manager (NNM) daemon 官方
2447/udp ovwdb - OpenView Network Node Manager (NNM) daemon 官方
2483/tcp,udp Oracle database listening port for unsecure client connections to the listener, replaces port 1521 官方
2484/tcp,udp Oracle database listening port for SSL client connections to the listener 官方
2546/tcp,udp Vytal Vault - Data Protection Services 非官方
2593/tcp,udp RunUO - Ultima Online server 非官方
2598/tcp new ICA - when Session Reliability is enabled, TCP port 2598 replaces port 1494 非官方
2612/tcp,udp QPasa from MQSoftware 官方
2710/tcp XBT Bittorrent Tracker 非官方
2710/udp XBT Bittorrent Tracker experimental UDP tracker extension 非官方
2710/tcp Knuddels.de 非官方
2735/tcp NetIQ Monitor Console 官方
2735/udp NetIQ Monitor Console 官方
2809/tcp corbaloc:iiop URL, per the CORBA 3.0.3 specification.Also used by IBM WebSphere Application Server Node Agent 官方
2809/udp corbaloc:iiop URL, per the CORBA 3.0.3 specification. 官方
2944/udp Megaco Text H.248 非官方
2945/udp Megaco Binary (ASN.1) H.248 非官方
2948/tcp WAP-pushMultimedia Messaging Service (MMS) 官方
2948/udp WAP-pushMultimedia Messaging Service (MMS) 官方
2949/tcp WAP-pushsecureMultimedia Messaging Service (MMS) 官方
2949/udp WAP-pushsecureMultimedia Messaging Service (MMS) 官方
2967/tcp Symantec AntiVirus Corporate Edition 非官方
3000/tcp Miralix License server 非官方
3000/udp Distributed Interactive Simulation (DIS), modifiable default port 非官方
3001/tcp Miralix Phone Monitor 非官方
3002/tcp Miralix CSTA 非官方
3003/tcp Miralix GreenBox API 非官方
3004/tcp Miralix InfoLink 非官方
3006/tcp Miralix SMS Client Connector 非官方
3007/tcp Miralix OM Server 非官方
3025/tcp netpd.org 非官方
3050/tcp,udp gds_db (Interbase/Firebird) 官方
3074/tcp,udp Xbox Live 官方
3128/tcp HTTP used byweb caches and the default port for the Squid cache 官方
3260/tcp iSCSI target 官方
3268/tcp msft-gc, Microsoft Global Catalog (LDAP service which contains data fromActive Directory forests) 官方
3269/tcp msft-gc-ssl, Microsoft Global Catalog over SSL (similar to port 3268, LDAP over SSL version) 官方
3300/tcp TripleA game server 非官方
3305/tcp,udp ODETTE-FTP 官方
3306/tcp,udp MySQL Database system 官方
3333/tcp Network Caller ID server 非官方
3386/tcp,udp GTP'3GPPGSM/UMTSCDR logging protocol 官方
3389/tcp 远程桌面协议(RDP) 官方
3396/tcp Novell NDPS Printer Agent 官方
3689/tcp DAAP Digital Audio Access Protocol used byApple’siTunes 官方
3690/tcp Subversion version control system 官方
3702/tcp,udp Web Services Dynamic Discovery (WS-Discovery), used by various components of Windows Vista 官方
3724/tcp World of Warcraft Online gaming MMORPG 官方
3784/tcp,udp Ventrilo VoIP program used byVentrilo 官方
3785/udp Ventrilo VoIP program used byVentrilo 官方
3868 tcp,udp Diameter base protocol 官方
3872/tcp Oracle Management Remote Agent 非官方
3899/tcp Remote Administrator 非官方
3900/tcp Unidata UDT OS udt_os 官方
3945/tcp Emcads server service port, a Giritech product used by G/On 官方
4000/tcp Diablo II game 非官方
4007/tcp PrintBuzzer printer monitoring socket server 非官方
4089/udp OpenCORE Remote Control Service 官方
4089/tcp OpenCORE Remote Control Service 官方
4093/udp PxPlus Client server interface ProvideX 官方
4093/tcp PxPlus Client server interface ProvideX 官方
4096/udp Bridge-Relay Element ASCOM 官方
4100 WatchGuard Authentication Applet - default port 非官方
4111/tcp,udp Xgrid 官方
4111/tcp Microsoft Office SharePoint Portal Server - 默认管理端口 非官方
4226/tcp,udp Aleph One (computer game) 非官方
4224/tcp Cisco CDP Cisco discovery Protocol 非官方
4569/udp Inter-Asterisk eXchange 非官方
4662/tcp OrbitNet Message Service 官方
4662/tcp 通常用于eMule 非官方
4664/tcp Google桌面搜索 非官方
4672/udp eMule - 常用端口 非官方
4894/tcp LysKOM Protocol A 官方
4899/tcp Radmin 远程控制工具 官方
5000/tcp commplex-main 官方
5000/tcp UPnP - Windows network device interoperability 非官方
5000/tcp,udp VTun -VPN 软件 非官方
5001/tcp,udp Iperf (Tool for measuring TCP and UDP bandwidth performance) 非官方
5001/tcp Slingbox及Slingplayer 非官方
5003/tcp FileMaker Filemaker Pro 官方
5004/udp RTP Real-time Transport Protocol 官方
5005/udp RTP Real-time Transport Protocol 官方
5031/tcp,udp AVM CAPI-over-TCP (ISDN overEthernet tunneling) 非官方
5050/tcp Yahoo! Messenger 官方
5051/tcp ita-agent Symantec Intruder Alert 官方
5060/tcp Session Initiation Protocol (SIP) 官方
5060/udp Session Initiation Protocol (SIP) 官方
5061/tcp Session Initiation Protocol (SIP) overTransport Layer Security (TLS) 官方
5093/udp SPSS License Administrator (SPSS) 官方
5104/tcp IBM NetCOOL / IMPACT HTTP Service 非官方
5106/tcp A-Talk Common connection 非官方
5107/tcp A-Talk 远程服务器连接 非官方
5110/tcp ProRat Server 非官方
5121/tcp Neverwinter Nights 官方
5176/tcp ConsoleWorks default UI interface 非官方
5190/tcp ICQ andAOL Instant Messenger 官方
5222/tcp XMPP/Jabber - client connection 官方
5223/tcp XMPP/Jabber - default port for SSL Client Connection 非官方
5269/tcp XMPP/Jabber - server connection 官方
5351/tcp,udp NAT Port Mapping Protocol - client-requested configuration for inbound connections through network address translators 官方
5353/udp mDNS - multicastDNS
5402/tcp,udp StarBurst AutoCast MFTP 官方
5405/tcp,udp NetSupport 官方
5421/tcp,udp Net Support 2 官方
5432/tcp PostgreSQL database system 官方
5445/udp Cisco Vidéo VT Advantage 非官方
5495/tcp Applix TM1 Admin server 非官方
5498/tcp Hotline tracker server connection 非官方
5499/udp Hotline tracker server discovery 非官方
5500/tcp VNC remote desktop protocol - for incoming listening viewer,Hotline control connection 非官方
5501/tcp Hotline file transfer connection 非官方
5517/tcp Setiqueue Proxy server client forSETI@Home project 非官方
5555/tcp Freeciv multiplay port for versions up to 2.0,Hewlett Packard Data Protector, SAP 非官方
5556/tcp Freeciv multiplay port 官方
5631/tcp 赛门铁克 pcAnywhere 官方
5632/udp 赛门铁克 pcAnywhere 官方
5666/tcp NRPE (Nagios) 非官方
5667/tcp NSCA (Nagios) 非官方
5800/tcp VNC remote desktop protocol - for use overHTTP 非官方
5814/tcp,udp Hewlett-Packard Support Automation (HP OpenView Self-Healing Services) 官方
5900/tcp VNC remote desktop protocol (used byARD) 官方
6000/tcp X11 - used between an X client and server over the network 官方
6001/udp X11 - used between an X client and server over the network 官方
6005/tcp Default port for BMC Software CONTROL-M/Server - Socket Port number used for communication between CONTROL-M processes - though often changed during installation 非官方
6050/tcp Brightstor Arcserve Backup 非官方
6051/tcp Brightstor Arcserve Backup 非官方
6100/tcp Vizrt System 非官方
6110/tcp softcm HP SoftBench CM 官方
6110/udp softcm HP SoftBench CM 官方
6111/tcp spc HP SoftBench Sub-Process Control 官方
6111/udp spc HP SoftBench Sub-Process Control 官方
6112/tcp "dtspcd" - a network daemon that accepts requests from clients to execute commands and launch applications remotely 官方
6112/tcp Blizzard'sBattle.net gaming service, ArenaNet gaming service 官方
6129/tcp Dameware Remote Control 非官方
6257/udp WinMX (参见6699端口) 非官方
6346/tcp,udp gnutella-svc (FrostWire,Limewire,Bearshare, etc.) 官方
6347/tcp,udp gnutella-rtr 官方
6444/tcp,udp Sun Grid Engine - Qmaster Service 官方
6445/tcp,udp Sun Grid Engine - Execution Service 官方
6502/tcp,udp Danware Data NetOp Remote Control 非官方
6522/tcp Gobby (and other libobby-based software) 非官方
6543/udp Jetnet - default port that theParadigm Research & Development Jetnet protocol communicates on 非官方
6566/tcp SANE (Scanner Access Now Easy) - SANE network scanner daemon 非官方
6600/tcp Music Playing Daemon (MPD) 非官方
6619/tcp,udp ODETTE-FTP over TLS/SSL 官方
6665-6669/tcp Internet Relay Chat 官方
6679/tcp IRC SSL (安全互联网中继聊天) - 通常使用的端口 非官方
6697/tcp IRC SSL (安全互联网中继聊天) - 通常使用的端口 非官方
6699/tcp WinMX (参见6257端口) 非官方
6881-6999/tcp,udp BitTorrent 通常使用的端口 非官方
6891-6900/tcp,udp Windows Live Messenger (文件传输) 官方
6901/tcp,udp Windows Live Messenger (语音) 官方
6969/tcp acmsoda 官方
6969/tcp BitTorrent tracker port 非官方
7000/tcp Default port for Azureus's built in HTTPS Bittorrent Tracker 非官方
7001/tcp Default port for BEA WebLogic Server's HTTP server - though often changed during installation 非官方
7002/tcp Default port for BEA WebLogic Server's HTTPS server - though often changed during installation 非官方
7005/tcp,udp Default port for BMC Software CONTROL-M/Server and CONTROL-M/Agent's - Agent to Server port though often changed during installation 非官方
7006/tcp,udp Default port for BMC Software CONTROL-M/Server and CONTROL-M/Agent's - Server to Agent port though often changed during installation 非官方
7010/tcp Default port for Cisco AON AMC (AON Management Console) [2] 非官方
7025/tcp Zimbra - lmtp [mailbox] - local mail delivery 非官方
7047/tcp Zimbra - conversion server 非官方
7171/tcp Tibia
7306/tcp Zimbra - mysql [mailbox] 非官方
7307/tcp Zimbra - mysql [logger] - logger 非官方
7312/udp Sibelius License Server port 非官方
7670/tcp BrettspielWelt BSW Boardgame Portal 非官方
7777/tcp Default port used by Windows backdoor program tini.exe 非官方
8000/tcp iRDMI - often mistakenly used instead of port 8080 (The Internet Assigned Numbers Authority (iana.org) officially lists this port for iRDMI protocol) 官方
8000/tcp Common port used for internet radio streams such as those using SHOUTcast 非官方
8002/tcp Cisco Systems Unified Call Manager Intercluster Port
8008/tcp HTTP 替代端口 官方
8008/tcp IBM HTTP Server 默认管理端口 非官方
8009/tcp ApacheJServ 协议 v13 (ajp13) 例如:Apache mod_jk Tomcat会使用。 非官方
8010/tcp XMPP/Jabber 文件传输 非官方
8074/tcp Gadu-Gadu 非官方
8080/tcp HTTP 替代端口 (http_alt) - commonly used forweb proxy and caching server, or for running a web server as a non-root user 官方
8080/tcp Apache Tomcat 非官方
8086/tcp HELM Web Host Automation Windows Control Panel 非官方
8086/tcp Kaspersky AV Control Center TCP Port 非官方
8087/tcp Hosting Accelerator Control Panel 非官方
8087/udp Kaspersky AV Control Center UDP Port 非官方
8090/tcp Another HTTP Alternate (http_alt_alt) - used as an alternative to port 8080 非官方
8118/tcp Privoxy web proxy - advertisements-filtering web proxy 官方
8087/tcp SW Soft Plesk 控制面板 非官方
8200/tcp GoToMyPC 非官方
8220/tcp Bloomberg 非官方
8222 VMware Server Management User Interface (insecure web interface)[3]. See also, port 8333 非官方
8291/tcp Winbox - Default port on a MikroTik RouterOS for a Windows application used to administer MikroTik RouterOS 非官方
8294/tcp Bloomberg 非官方
8333 VMware 服务器管理用户界面(安全网络界面)[4]. See also, port 8222 非官方
8400 Commvault Unified Data Management 官方
8443/tcp SW Soft Plesk Control Panel 非官方
8500/tcp ColdFusion Macromedia/Adobe ColdFusion default Webserver port 非官方
8501/udp Duke Nukem 3D - Default Online Port 官方
8767/udp TeamSpeak - Default UDP Port 非官方
8880 WebSphere Application ServerSOAP Connector port
8881/tcp Atlasz Informatics Research Ltd Secure Application Server 非官方
8882/tcp Atlasz Informatics Research Ltd Secure Application Server 非官方
8888/tcp,udp NewsEDGE server 官方
8888/tcp Sun Answerbookdwhttpd server (deprecated by docs.sun.com) 非官方
8888/tcp GNUmp3d HTTP music streaming and web interface port 非官方
8888/tcp Hero Fighter Network Game Server 非官方
9000/tcp Buffalo LinkSystem web access 非官方
9000/tcp DBGp 非官方
9000/udp UDPCast 非官方
9001 cisco-xremote router configuration 非官方
9001 Tor network default port 非官方
9001/tcp DBGp Proxy 非官方
9009/tcp,udp Pichat Server - Peer to peer chat software 官方
9043/tcp WebSphere Application Server Administration Console secure port
9060/tcp WebSphere Application Server Administration Console
9100/tcp Jetdirect HP Print Services 官方
9110/udp SSMP Message protocol 非官方
9101 Bacula Director 官方
9102 Bacula File Daemon 官方
9103 Bacula Storage Daemon 官方
9119/TCP,UDP MXit Instant Messenger 官方
9535/tcp man, Remote Man Server
9535 mngsuite - Management Suite Remote Control 官方
9800/tcp,udp WebDAV Source Port 官方
9800 WebCT e-learning portal 非官方
9999 Hydranode - edonkey2000 telnet control port 非官方
9999 Urchin Web Analytics 非官方
10000 Webmin - web based Linux admin tool 非官方
10000 BackupExec 非官方
10008 Octopus Multiplexer - CROMP protocol primary port, hoople.org 官方
10017 AIX,NeXT, HPUX - rexd daemon control port 非官方
10024/tcp Zimbra - smtp [mta] - to amavis from postfix 非官方
10025/tcp Ximbra - smtp [mta] - back to postfix from amavis 非官方
10050/tcp Zabbix-Agent
10051/tcp Zabbix-Server
10113/tcp NetIQ Endpoint 官方
10113/udp NetIQ Endpoint 官方
10114/tcp NetIQ Qcheck 官方
10114/udp NetIQ Qcheck 官方
10115/tcp NetIQ Endpoint 官方
10115/udp NetIQ Endpoint 官方
10116/tcp NetIQ VoIP Assessor 官方
10116/udp NetIQ VoIP Assessor 官方
10480 SWAT 4 Dedicated Server 非官方
11211 memcached 非官方
11235 Savage:Battle for Newerth Server Hosting 非官方
11294 Blood Quest Online Server 非官方
11371 OpenPGP HTTP Keyserver 官方
11576 IPStor Server management communication 非官方
12035/udp Linden Lab viewer to sim 非官方
12345 NetBus - remote administration tool (oftenTrojan horse). Also used by NetBuster. Little Fighter 2 (TCP). 非官方
12975/tcp LogMeIn Hamachi (VPN tunnel software;also port 32976)
13000-13050/udp Linden Lab viewer to sim 非官方
13720/tcp SymantecNetBackup - bprd (formerly VERITAS)
13721/tcp SymantecNetBackup - bpdbm (formerly VERITAS)
13724/tcp Symantec Network Utility - vnet (formerlyVERITAS)
13782/tcp SymantecNetBackup - bpcd (formerly VERITAS)
13783/tcp Symantec VOPIED protocol (formerlyVERITAS)
14567/udp Battlefield 1942 and mods 非官方
15000/tcp psyBNC 非官方
15000/tcp Wesnoth
15567/udp Battlefield Vietnam and mods 非官方
15345/udp XPilot 官方
16000/tcp shroudBNC 非官方
16080/tcp Mac OS X Server performance cache forHTTP[5] 非官方
16384/udp Iron Mountain Digital - online backup 非官方
16567/udp Battlefield 2 and mods 非官方
17788/udp PPS网络电视 非官方
19226/tcp Panda Software AdminSecure Communication Agent 非官方
19638/tcp Ensim Control Panel 非官方
19813/tcp 4D database Client Server Communication 非官方
20000 Usermin - 基于网络的用户工具 官方
20720/tcp Symantec i3 Web GUI server 非官方
22347/tcp,udp WibuKey - default port for WibuKey Network Server of WIBU-SYSTEMS AG 官方
22350/tcp,udp CodeMeter - default port for CodeMeter Server of WIBU-SYSTEMS AG 官方
24554/tcp,udp binkp -Fidonet mail transfers over TCP/IP 官方
24800 Synergy:keyboard/mouse sharing software 非官方
24842 StepMania:Online:Dance Dance Revolution Simulator 非官方
25999/tcp Xfire 非官方
26000/tcp,udp id Software'sQuake server, 官方
26000/tcp CCP'sEVE Online Online gaming MMORPG, 非官方
27000/udp (through 27006) id Software's QuakeWorld master server 非官方
27010/udp Half-Life及其修改版,如Counter-Strike 非官方
27015/udp Half-Life及其修改版,如Counter-Strike 非官方
27374 Sub7's default port. Mostscript kiddies do not change the default port. 非官方
27500/udp (through 27900) id Software's QuakeWorld 非官方
27888/udp Kaillera server 非官方
27900 (through 27901) Nintendo Wi-Fi Connection 非官方
27901/udp (through 27910) id Software's Quake II master server 非官方
27960/udp (through 27969) Activision's Enemy Territory andid Software's Quake III Arena andQuake III and some ioquake3 derived games 非官方
28910 任天堂Wi-Fi连接 非官方
28960 Call of Duty 2 Common Call of Duty 2 port - (PC Version) 非官方
29900 (through 29901) Nintendo Wi-Fi Connection 非官方
29920 任天堂Wi-Fi连接 非官方
30000 Pokemon Netbattle 非官方
30564/tcp Multiplicity:keyboard/mouse/clipboard sharing software 非官方
31337/tcp Back Orifice - remote administration tool(oftenTrojan horse 非官方
31337/tcp xc0r3 - xc0r3 security antivir port 非官方
31415 ThoughtSignal - Server Communication Service(oftenInformational 非官方
31456-31458/tcp TetriNET ports (in order: IRC, game, and spectating) 非官方
32245/tcp MMTSG-mutualed overMMT (encrypted transmission) 非官方
33434 traceroute 官方
37777/tcp Digital Video Recorder hardware 非官方
36963 Counter Strike 2D multiplayer port (2D clone of popular CounterStrike computer game) 非官方
40000 SafetyNET p 官方
40523 data packets 不确定 6
43594-43595/tcp RuneScape 非官方
47808 BACnet Building Automation and Control Networks 官方

49152到65535号端口

根据定义,该段端口属于“动态端口”范围,没有端口可以被正式地注册占用。 [6]

参考文献

相关

外部链接

以上内容转自 wiki 百科 http://zh.wikipedia.org/wiki/TCP/UDP%E7%AB%AF%E5%8F%A3%E5%88%97%E8%A1%A8

端口探测列表

https://svn.nmap.org/nmap/nmap-services

数据报传递协议端口

显示了一个和数据报传递协议(DDP)有关的端口列表。DDP 在 AppleTalk 网络上被使用。

端口号码 / 层 名称 注释
1/ddp rtmp 路由表管理协议
2/ddp nbp 名称绑定协议
4/ddp echo AppleTalk Echo 协议
6/ddp zip 区块信息协议

Kerberos(工程 Athena/MIT)端口

和 Kerberos 网络验证协议相关的端口列表。在标记的地方,v5 代表 Kerberos 版本5协议。注意,这些端口没有在 IANA 注册。

端口号码 / 层 名称 注释
751 kerberos_master Kerberos 验证
752 passwd_server Kerberos 口令(kpasswd)服务器
754 krb5_prop Kerberos v5 从属传播
760 krbupdate [kreg] Kerberos 注册
1109 kpop Kerberos 邮局协议(KPOP)
2053 knetd Kerberos 多路分用器
2105 eklogin Kerberos v5 加密的远程登录(rlogin)


未注册的端口

一个未注册的端口列表。这些端口可能被安装在你的红帽企业 Linux 系统上的服务或协议使用,或者它们是在红帽企业 Linux 和运行其它操作系统的机器通信所必需的端口。

端口号码 / 层 名称 注释
15/tcp netstat 网络状态(netstat)
98/tcp linuxconf Linuxconf Linux 管理工具
106 poppassd 邮局协议口令改变守护进程(POPPASSD)
465/tcp smtps 通过安全套接字层的简单邮件传输协议(SMTPS)
616/tcp gii 使用网关的(选路守护进程)互动界面
808 omirr [omirrd] 联机镜像(Omirr)文件镜像服务
871/tcp supfileserv 软件升级协议(SUP)服务器
901/tcp swat Samba 万维网管理工具(SWAT)
953 rndc Berkeley 互联网名称域版本9(BIND 9)远程名称守护进程配置工具
1127 sufiledbg 软件升级协议(SUP)调试
1178/tcp skkserv 简单假名到汉字(SKK)日文输入服务器
1313/tcp xtel 法国 Minitel 文本信息系统
1529/tcp support [prmsd, gnatsd] GNATS 错误跟踪系统
2003/tcp cfinger GNU Finger 服务
2150 ninstall 网络安装服务
2988 afbackup afbackup 客户-服务器备份系统
3128/tcp squid Squid 万维网代理缓存
3455 prsvp RSVP 端口
5432 postgres PostgreSQL 数据库
4557/tcp fax FAX 传输服务(旧服务)
4559/tcp hylafax HylaFAX 客户-服务器协议(新服务)
5232 sgi-dgl SGI 分布式图形库
5354 noclog NOCOL 网络操作中心记录守护进程(noclogd)
5355 hostmon NOCOL 网络操作中心主机监视
5680/tcp canna Canna 日文字符输入界面
6010/tcp x11-ssh-offset 安全 Shell(SSH)X11 转发偏移
6667 ircd 互联网中继聊天守护进程(ircd)
7100/tcp xfs X 字体服务器(XFS)
7666/tcp tircproxy Tircproxy IRC 代理服务
8008 http-alt 超文本传输协议(HTTP)的另一选择
8080 webcache 万维网(WWW)缓存服务
8081 tproxy 透明代理
9100/tcp jetdirect [laserjet, hplj] Hewlett-Packard (HP) JetDirect 网络打印服务
9359 mandelspawn [mandelbrot] 用于 X 窗口系统的并行 Mandelbrot 生成程序
10081 kamanda 使用 Kerberos 的 Amanda 备份服务
10082/tcp amandaidx Amanda 备份服务
10083/tcp amidxtape Amanda 备份服务
20011 isdnlog 综合业务数字网(ISDN)登录系统
20012 vboxd ISDN 音箱守护进程(vboxd)
22305/tcp wnn4_Kr kWnn 韩文输入系统
22289/tcp wnn4_Cn cWnn 中文输入系统
22321/tcp wnn4_Tw tWnn 中文输入系统(台湾)
24554 binkp Binkley TCP/IP Fidonet 邮寄程序守护进程
27374 asp 地址搜索协议
60177 tfido Ifmail FidoNet 兼容邮寄服务
60179 fido FidoNet 电子邮件和新闻网络

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

Adf         常用端口
200-250
200=Adf.ClusterServer
201=Adf.CacheServer
202=Adf.CacheServer Console
209=Adf WitnessServer
210=...
220=Adf SessionServer
221=Adf SessionServer Console
226=Adf NumberServer
227=Adf NumberServer Console
228=Adf QueueServer
229=Adf QueueServer Reserve

230=Adf SimpleQueueServer
231=Adf SimpleQueueServer Reserve

Adf 预留定义端口

6200-6500

6200=Adf.CacheServer
6201=Adf.CacheServer Console

6202=...
6203=...

6224=Adf NumberServer
6225=Adf NumberServer HA

6226=...
6227=...

6228=Adf SessionServer
6229=Adf SessionServer Console

6230=Adf QueueServer
6231=Adf QueueServer Reserve

6232=Adf TopicServer
6233=Adf TopicServer Reserve

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

32231 GPSPoint UDP Gateway

发表在 article | 标签为 | common port已关闭评论

推荐算法

基于用户的协同过滤推荐算法原理和实现:

http://www.cnblogs.com/technology/p/4467895.html

 

今日头条的个性化推荐算法

http://www.mahaixiang.cn/internet/1418.html

 

基于时间效应和用户兴趣变化的改进推荐算法

http://www.doc88.com/p-8949047664061.html

 

新闻个性化推荐基本算法

http://blog.csdn.net/hxxiaopei/article/details/47007011

 

推荐算法一些看法

http://www.zhihu.com/question/20326697

 

相似度算法

http://blog.sina.com.cn/s/blog_62b83291010127bf.html

http://wdhdmx.iteye.com/blog/1343856

http://www.360doc.com/content/13/0809/13/891660_305827106.shtml

 

发表在 technologys | 推荐算法已关闭评论

.NET RSACryptoServiceProvider PEM + DER Support

原文:

www.cnblogs.com/adylee/p/3611461.html

http://www.tuicool.com/articles/nUbymaF

 

http://www.christian-etter.de/?p=771

 

In .NET, RSACryptoServiceProvider greatly simplifies common tasks
associated with public/private keys, such as signing of data and
verifying a signature.
Unfortunately, there is only a single format (proprietary XML) available for importing and exporting public/private key data.
The
two widely spread formats for key exchange, PEM and DER are not
supported, which limits the usability of the class when working with
different kinds of public key APIs.

There are a few workarounds though:

  • Write your own .NET code to support the desired formats, which might not be that simple, as the following blog post suggests.
  • Use a third party component, such as the PEMReader class of the Bouncy Castle Library (Java/C# port).
  • Leverage Microsoft Crypto API (CAPI), which provides support for
    opening and converting a variety of different public/private key file
    formats. Here I would like to demonstrate how this can be achieved by
    means of simple extension methods to theRSACryptoServiceProvider class.

Here is a sample RSA 1024 bit private key in PEM format:

-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDwIqfvxEjqHu8048x4wJ5EId6ASAbWdH5fzgHxvew5kXqECMNc
XzRqDVnDVPQT41UeZs8HxouBE+ZA8DfnVlHwP4EIeigOUaqy0sseKpO71tupFU+2
LjpcF6O7cVuLjt6476iYfSyrssK4hnmzVYGZNz16OSR9z/SuTd8BhohG4QIDAQAB
AoGBAOmEmhEUrN9XU8D4IVfv4DhbQ1c2M8gKovYhjEx8J6LX8O9C4lAKmRrkfrzv
+Sb59EVLLtrd3b2ZD1lpAMQrciMwC5PAa8da/J++lR1VjM5GbzqKjGtfx3WQlzNE
1ZaZ2FSY8lAPMM4uLczyD79PJQBsGCcx3KDJRR5ENp6an5cRAkEA/m1FEqol/KKh
xOyGsK4GVuansBXhrAgpwMlYLT+vF0gy1jzYQDNNQXzeQFYH6gZY66RTYFl3JPNL
8KXLyhwDLQJBAPGew6xkLBoYi4IO9I+NP/gIHzSiQeEl2OxZsgZiz0Yh5E9ndwMr
87jTX/4ZBwNlDC0E+MXsJpMSvTFNpw4rcwUCQQC5FU5JLKOjq79YnOPChWYxM2vL
Ka/YULvm9dGCYTCDFE9/EBYUZf2OZULctHjfYqyvBwRsM8j7hU26CzI7nbMlAkAA
kVjwXMPlw80AHzzf4XsXAB3ip8bz2nzqAUPz0+OczJOWxC15am8GLij5leF4VpJy
wKI9BNMKYW7kYMRVujBpAkEA7gQ8MGqjjrCAfOzrrC9ZuVdGRfEjUEdHMqiF+js7
XNBvnT5lBznUOd+eta6CGo7S5hjU7D3CEzmVGQfxUsRZ1w==
-----END RSA PRIVATE KEY-----

This is the corresponding public key in textual PEM representation:

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwIqfvxEjqHu8048x4wJ5EId6A
SAbWdH5fzgHxvew5kXqECMNcXzRqDVnDVPQT41UeZs8HxouBE+ZA8DfnVlHwP4EI
eigOUaqy0sseKpO71tupFU+2LjpcF6O7cVuLjt6476iYfSyrssK4hnmzVYGZNz16
OSR9z/SuTd8BhohG4QIDAQAB
-----END PUBLIC KEY-----

We cannot load these keys into the RSACryptoServiceProvider directly.
However the class supports an import method which is compatible with
CryptoAPI: ImportCspBlob().
With CAPI in return, we can do all the heavy lifting including format conversion which the .NET Framework does not support.
For public keys, the conversion process for PEM (string) key data requires the following steps:

1.Converting a public key in PEM string format into DER representation.

 CryptStringToBinaryA( sPEM, (UInt32)sPEM.Length, CRYPT_STRING_FLAGS.CRYPT_STRING_BASE64HEADER, IntPtr.Zero, ref dwBinarySize, out dwSkip, out dwFlags ) )

2.Retrieve the key through a CERT_PUBLIC_KEY_INFO struct.

 CryptDecodeObjectEx( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.X509_PUBLIC_KEY_INFO ), DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.CRYPT_DECODE_ALLOC_FLAG, IntPtr.Zero, ref pCertPublicKeyInfo, out dwCertPublicKeyInfoSize )

 3.Convert the returned RSA key into a Diffie-Hellman Version 3 Public Key BLOBs or DSS Version 3 Public Key BLOBs struct:

 CryptDecodeObjectEx( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.RSA_CSP_PUBLICKEYBLOB ), RSAData, (UInt32)RSAData.Length, CRYPT_DECODE_FLAGS.CRYPT_DECODE_ALLOC_FLAG, IntPtr.Zero, ref pCertPublicKeyBlob, out dwCertPublicKeyBlobSize )

4.Call RSACryptoServiceProvider.ImportCspBlob() for the resulting binary data.

For private keys, the following steps are required:

1.Converting a private key in PEM string format into DER representation.

 CryptStringToBinaryA( sPEM, (UInt32)sPEM.Length, CRYPT_STRING_FLAGS.CRYPT_STRING_BASE64HEADER, IntPtr.Zero, ref dwBinarySize, out dwSkip, out dwFlags ) )

2.For private keys, retrieve a pointer to an RSA private key BLOB directly:

 CryptDecodeObjectEx( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.PKCS_RSA_PRIVATE_KEY ), DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.CRYPT_DECODE_ALLOC_FLAG, IntPtr.Zero, ref pRSAPrivateKeyBlob, out pRSAPrivateKeyBlobSize )

3.Call RSACryptoServiceProvider.ImportCspBlob() for the resulting binary data.

 If you wrap the above logic into extension methods for RSACryptoServiceProvider, importing keys in PEM format and signing data can be done with a few lines of code:

 // -----BEGIN RSA PRIVATE KEY-----...-----END RSA PRIVATE KEY-----
string sPrivateKeyPEM = File.ReadAllText( "PrivateKey.pem" );
 
using ( RSACryptoServiceProvider rsa = new RSACryptoServiceProvider() )
{
    rsa.PersistKeyInCsp = false;
    rsa.LoadPrivateKeyPEM( sPrivateKeyPEM );
    using ( SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider() )
        signature = rsa.SignData( dataToSign, sha1 );
}

Verifying the same signature also becomes easy:

 // -----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----
string sPublicKeyPEM = File.ReadAllText( "PublicKey.pem" );
 
using ( RSACryptoServiceProvider rsa = new RSACryptoServiceProvider() )
{
    rsa.PersistKeyInCsp = false;
    rsa.LoadPublicKeyPEM( sPublicKeyPEM );
    using ( SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider() )
        bVerifyResultOriginal = rsa.VerifyData( dataToSign, sha1, signature );
}

Here is a cut-and-paste solution based on an extension class to RSACryptoServiceProvider:

 /*********************************************************************************
 * Copyright (c) 2013, Christian Etter info at christian-etter dot de
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *********************************************************************************/
 
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
 
/// <summary>Extension method for initializing a RSACryptoServiceProvider from PEM data string.</summary>
public static class RSACryptoServiceProviderExtension
{
    #region Methods
 
    /// <summary>Extension method which initializes an RSACryptoServiceProvider from a DER public key blob.</summary>
    public static void LoadPublicKeyDER( this RSACryptoServiceProvider provider, byte[] DERData )
    {
        byte[] RSAData = RSACryptoServiceProviderExtension.GetRSAFromDER( DERData );
        byte[] publicKeyBlob = RSACryptoServiceProviderExtension.GetPublicKeyBlobFromRSA( RSAData );
        provider.ImportCspBlob( publicKeyBlob );
    }
 
    /// <summary>Extension method which initializes an RSACryptoServiceProvider from a DER private key blob.</summary>
    public static void LoadPrivateKeyDER( this RSACryptoServiceProvider provider, byte[] DERData )
    {
        byte[] privateKeyBlob = RSACryptoServiceProviderExtension.GetPrivateKeyDER( DERData );
        provider.ImportCspBlob( privateKeyBlob );
    }
 
    /// <summary>Extension method which initializes an RSACryptoServiceProvider from a PEM public key string.</summary>
    public static void LoadPublicKeyPEM( this RSACryptoServiceProvider provider, string sPEM )
    {
        byte[] DERData = RSACryptoServiceProviderExtension.GetDERFromPEM( sPEM );
        RSACryptoServiceProviderExtension.LoadPublicKeyDER( provider, DERData );
    }
 
    /// <summary>Extension method which initializes an RSACryptoServiceProvider from a PEM private key string.</summary>
    public static void LoadPrivateKeyPEM( this RSACryptoServiceProvider provider, string sPEM )
    {
        byte[] DERData = RSACryptoServiceProviderExtension.GetDERFromPEM( sPEM );
        RSACryptoServiceProviderExtension.LoadPrivateKeyDER( provider, DERData );
    }
 
    /// <summary>Returns a public key blob from an RSA public key.</summary>
    internal static byte[] GetPublicKeyBlobFromRSA( byte[] RSAData )
    {
        byte[] data = null;
        UInt32 dwCertPublicKeyBlobSize = 0;
        if ( RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING,
            new IntPtr( (int)CRYPT_OUTPUT_TYPES.RSA_CSP_PUBLICKEYBLOB ), RSAData, (UInt32)RSAData.Length, CRYPT_DECODE_FLAGS.NONE,
            data, ref dwCertPublicKeyBlobSize ) )
        {
            data = new byte[ dwCertPublicKeyBlobSize ];
            if ( !RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING,
                new IntPtr( (int)CRYPT_OUTPUT_TYPES.RSA_CSP_PUBLICKEYBLOB ), RSAData, (UInt32)RSAData.Length, CRYPT_DECODE_FLAGS.NONE,
                data, ref dwCertPublicKeyBlobSize ) )
                throw new Win32Exception( Marshal.GetLastWin32Error() );
        }
        else
            throw new Win32Exception( Marshal.GetLastWin32Error() );
        return data;
    }
 
    /// <summary>Converts DER binary format to a CAPI CRYPT_PRIVATE_KEY_INFO structure.</summary>
    internal static byte[] GetPrivateKeyDER( byte[] DERData )
    {
        byte[] data = null;
        UInt32 dwRSAPrivateKeyBlobSize = 0;
        IntPtr pRSAPrivateKeyBlob = IntPtr.Zero;
        if ( RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.PKCS_RSA_PRIVATE_KEY ),
            DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.NONE, data, ref dwRSAPrivateKeyBlobSize ) )
        {
            data = new byte[ dwRSAPrivateKeyBlobSize ];
            if ( !RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.PKCS_RSA_PRIVATE_KEY ),
                DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.NONE, data, ref dwRSAPrivateKeyBlobSize ) )
                throw new Win32Exception( Marshal.GetLastWin32Error() );
        }
        else
            throw new Win32Exception( Marshal.GetLastWin32Error() );
        return data;
    }
 
    /// <summary>Converts DER binary format to a CAPI CERT_PUBLIC_KEY_INFO structure containing an RSA key.</summary>
    internal static byte[] GetRSAFromDER( byte[] DERData )
    {
        byte[] data = null;
        byte[] publicKey = null;
        CERT_PUBLIC_KEY_INFO info;
        UInt32 dwCertPublicKeyInfoSize = 0;
        IntPtr pCertPublicKeyInfo = IntPtr.Zero;
        if ( RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.X509_PUBLIC_KEY_INFO ),
            DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.NONE, data, ref dwCertPublicKeyInfoSize ) )
        {
            data = new byte[ dwCertPublicKeyInfoSize ];
            if ( RSACryptoServiceProviderExtension.CryptDecodeObject( CRYPT_ENCODING_FLAGS.X509_ASN_ENCODING | CRYPT_ENCODING_FLAGS.PKCS_7_ASN_ENCODING, new IntPtr( (int)CRYPT_OUTPUT_TYPES.X509_PUBLIC_KEY_INFO ),
                DERData, (UInt32)DERData.Length, CRYPT_DECODE_FLAGS.NONE, data, ref dwCertPublicKeyInfoSize ) )
            {
                GCHandle handle = GCHandle.Alloc( data, GCHandleType.Pinned );
                try
                {
                    info = (CERT_PUBLIC_KEY_INFO)Marshal.PtrToStructure( handle.AddrOfPinnedObject(), typeof( CERT_PUBLIC_KEY_INFO ) );
                    publicKey = new byte[ info.PublicKey.cbData ];
                    Marshal.Copy( info.PublicKey.pbData, publicKey, 0, publicKey.Length );
                }
                finally
                {
                    handle.Free();
                }
            }
            else
                throw new Win32Exception( Marshal.GetLastWin32Error() );
        }
        else
            throw new Win32Exception( Marshal.GetLastWin32Error() );
        return publicKey;
    }
 
    /// <summary>Extracts the binary data from a PEM file.</summary>
    internal static byte[] GetDERFromPEM( string sPEM )
    {
        UInt32 dwSkip, dwFlags;
        UInt32 dwBinarySize = 0;
 
        if ( !RSACryptoServiceProviderExtension.CryptStringToBinary( sPEM, (UInt32)sPEM.Length, CRYPT_STRING_FLAGS.CRYPT_STRING_BASE64HEADER, null, ref dwBinarySize, out dwSkip, out dwFlags ) )
            throw new Win32Exception( Marshal.GetLastWin32Error() );
 
        byte[] decodedData = new byte[ dwBinarySize ];
        if ( !RSACryptoServiceProviderExtension.CryptStringToBinary( sPEM, (UInt32)sPEM.Length, CRYPT_STRING_FLAGS.CRYPT_STRING_BASE64HEADER, decodedData, ref dwBinarySize, out dwSkip, out dwFlags ) )
            throw new Win32Exception( Marshal.GetLastWin32Error() );
        return decodedData;
    }
 
    #endregion Methods
 
    #region P/Invoke Constants
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_ACQUIRE_CONTEXT_FLAGS : uint
    {
        CRYPT_NEWKEYSET = 0x8,
        CRYPT_DELETEKEYSET = 0x10,
        CRYPT_MACHINE_KEYSET = 0x20,
        CRYPT_SILENT = 0x40,
        CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x80,
        CRYPT_VERIFYCONTEXT = 0xF0000000
    }
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_PROVIDER_TYPE : uint
    {
        PROV_RSA_FULL = 1
    }
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_DECODE_FLAGS : uint
    {
        NONE = 0,
        CRYPT_DECODE_ALLOC_FLAG = 0x8000
    }
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_ENCODING_FLAGS : uint
    {
        PKCS_7_ASN_ENCODING = 0x00010000,
        X509_ASN_ENCODING = 0x00000001,
    }
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_OUTPUT_TYPES : int
    {
        X509_PUBLIC_KEY_INFO = 8,
        RSA_CSP_PUBLICKEYBLOB = 19,
        PKCS_RSA_PRIVATE_KEY = 43,
        PKCS_PRIVATE_KEY_INFO = 44
    }
 
    /// <summary>Enumeration derived from Crypto API.</summary>
    internal enum CRYPT_STRING_FLAGS : uint
    {
        CRYPT_STRING_BASE64HEADER = 0,
        CRYPT_STRING_BASE64 = 1,
        CRYPT_STRING_BINARY = 2,
        CRYPT_STRING_BASE64REQUESTHEADER = 3,
        CRYPT_STRING_HEX = 4,
        CRYPT_STRING_HEXASCII = 5,
        CRYPT_STRING_BASE64_ANY = 6,
        CRYPT_STRING_ANY = 7,
        CRYPT_STRING_HEX_ANY = 8,
        CRYPT_STRING_BASE64X509CRLHEADER = 9,
        CRYPT_STRING_HEXADDR = 10,
        CRYPT_STRING_HEXASCIIADDR = 11,
        CRYPT_STRING_HEXRAW = 12,
        CRYPT_STRING_NOCRLF = 0x40000000,
        CRYPT_STRING_NOCR = 0x80000000
    }
 
    #endregion P/Invoke Constants
 
    #region P/Invoke Structures
 
    /// <summary>Structure from Crypto API.</summary>
    [StructLayout( LayoutKind.Sequential )]
    internal struct CRYPT_OBJID_BLOB
    {
        internal UInt32 cbData;
        internal IntPtr pbData;
    }
 
    /// <summary>Structure from Crypto API.</summary>
    [StructLayout( LayoutKind.Sequential )]
    internal struct CRYPT_ALGORITHM_IDENTIFIER
    {
        internal IntPtr pszObjId;
        internal CRYPT_OBJID_BLOB Parameters;
    }
 
    /// <summary>Structure from Crypto API.</summary>
    [StructLayout( LayoutKind.Sequential )]
    struct CRYPT_BIT_BLOB
    {
        internal UInt32 cbData;
        internal IntPtr pbData;
        internal UInt32 cUnusedBits;
    }
 
    /// <summary>Structure from Crypto API.</summary>
    [StructLayout( LayoutKind.Sequential )]
    struct CERT_PUBLIC_KEY_INFO
    {
        internal CRYPT_ALGORITHM_IDENTIFIER Algorithm;
        internal CRYPT_BIT_BLOB PublicKey;
    }
 
    #endregion P/Invoke Structures
 
    #region P/Invoke Functions
 
    /// <summary>Function for Crypto API.</summary>
    [DllImport( "advapi32.dll", SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptDestroyKey( IntPtr hKey );
 
    /// <summary>Function for Crypto API.</summary>
    [DllImport( "advapi32.dll", SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptImportKey( IntPtr hProv, byte[] pbKeyData, UInt32 dwDataLen, IntPtr hPubKey, UInt32 dwFlags, ref IntPtr hKey );
 
    /// <summary>Function for Crypto API.</summary>
    [DllImport( "advapi32.dll", SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptReleaseContext( IntPtr hProv, Int32 dwFlags );
 
    /// <summary>Function for Crypto API.</summary>
    [DllImport( "advapi32.dll", CharSet = CharSet.Auto, SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptAcquireContext( ref IntPtr hProv, string pszContainer, string pszProvider, CRYPT_PROVIDER_TYPE dwProvType, CRYPT_ACQUIRE_CONTEXT_FLAGS dwFlags );
 
    /// <summary>Function from Crypto API.</summary>
    [DllImport( "crypt32.dll", SetLastError = true, CharSet = CharSet.Auto )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptStringToBinary( string sPEM, UInt32 sPEMLength, CRYPT_STRING_FLAGS dwFlags, [Out] byte[] pbBinary, ref UInt32 pcbBinary, out UInt32 pdwSkip, out UInt32 pdwFlags );
 
    /// <summary>Function from Crypto API.</summary>
    [DllImport( "crypt32.dll", SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptDecodeObjectEx( CRYPT_ENCODING_FLAGS dwCertEncodingType, IntPtr lpszStructType, byte[] pbEncoded, UInt32 cbEncoded, CRYPT_DECODE_FLAGS dwFlags, IntPtr pDecodePara, ref byte[] pvStructInfo, ref UInt32 pcbStructInfo );
 
    /// <summary>Function from Crypto API.</summary>
    [DllImport( "crypt32.dll", SetLastError = true )]
    [return: MarshalAs( UnmanagedType.Bool )]
    internal static extern bool CryptDecodeObject( CRYPT_ENCODING_FLAGS dwCertEncodingType, IntPtr lpszStructType, byte[] pbEncoded, UInt32 cbEncoded, CRYPT_DECODE_FLAGS flags, [In, Out] byte[] pvStructInfo, ref UInt32 cbStructInfo );
 
    #endregion P/Invoke Functions
}

 

I am attaching a Visual Studio 2012 solution containing a sample usage for PEM and DER encoded files. Click here to download.

Solution containing sample keys:

点击查看原图

Test program output:

点击查看原图

发表在 technologys | .NET RSACryptoServiceProvider PEM + DER Support已关闭评论

Expires,Cache-Control,Last-Modified,ETag

1.Expires(过期时间)HTTP头信息Expires(过期时间) 属性是HTTP控制缓存的基本手段,这个属性告诉缓存器:相关副本在多长时间内是新鲜的。过了这个时间,缓存器就会向源服务器发送请求,检查文档是否被修 改。几乎所有的缓存服务器都支持Expires(过期时间)属性;

大部分Web服务器支持你用几种方式设置Expires属性;一般 的:可以设计一个绝对时间间隔:基于客户最后查看副本的时间(最后访问时间)或者根据服务器上文档最后被修改的时间;

Expires

头信息:对于设置静态图片文件(例如导航栏和图片按钮)可缓存特别有用;因为这些图片修改很少,你可以给它们设置一个特别长的过期时间,这会使你的网站对
用户变得相应非常快;他们对于控制有规律改变的网页也很有用,例如:你每天早上6点更新新闻页,你可以设置副本的过期时间也是这个时间,这样缓存
服务器就知道什么时候去取一个更新版本,而不必让用户去按浏览器的“刷新”按钮。

过期时间头信息属性值只能是HTTP格式的日期时间,其他的都会被解析成当前时间“之前”,副本会过期,记住:HTTP的日期时间必须是格林威治时 间(GMT),而不是本地时间。举例:

Expires: Fri, 30 Oct 1998 14:19:41

所以使用过期时间属性一定要确认你的Web服务器时间设置正确,一个途径是通过网络时间同步协议(Network Time Protocol NTP),和你的系统管理员那里你可以了解更多细节。

虽然过期时间属性非常有用,但是它还是有些局限,首先:是牵扯到了日期,这样Web服务器的时间和缓存服务器的时间必须是同步的,如果有些不同步, 要么是应该缓存的内容提前过期了,要么是过期结果没及时更新。

还有一个过期时间设置的问题也不容忽视:如果你设置的过期时间是一个固定的时间,如果你返回内容的时候又没有连带更新下次过期的时间,那么之后所有 访问请求都会被发送给源Web服务器,反而增加了负载和响应时间;

2.Cache-Control(缓存控制) HTTP头信息

HTTP 1.1介绍了另外一组头信息属性:Cache-Control响应头信息,让网站的发布者可以更全面的控制他们的内容,并定位过期时间的限制。

有 用的 Cache-Control响应头信息包括:

max-age=[秒] — 执行缓存被认为是最新的最长时间。类似于过期时间,这个参数是基于请求时间的相对时间间隔,而不是绝对过期时间,[秒]是一个数字,单位是秒:从请求时间 开始到过期时间之间的秒数。

s-maxage=[秒] — 类似于max-age属性,除了他应用于共享(如:代理服务器)缓存

public — 标记认证内容也可以被缓存,一般来说: 经过HTTP认证才能访问的内容,输出是自动不可以缓存的;

no-cache — 强制每次请求直接发送给源服务器,而不经过本地缓存版本的校验。这对于需要确认认证应用很有用(可以和public结合使用),或者严格要求使用最新数据 的应用(不惜牺牲使用缓存的所有好处);

no-store — 强制缓存在任何情况下都不要保留任何副本

must-revalidate — 告诉缓存必须遵循所有你给予副本的新鲜度的,HTTP允许缓存在某些特定情况下返回过期数据,指定了这个属性,你高速缓存,你希望严格的遵循你的规则。

proxy-revalidate — 和 must-revalidate类似,除了他只对缓存代理服务器起作用

举例:

Cache-Control: max-age=3600, must-revalidate


静态资源(HTML文件,图片文件等)的Repsone加上Expires/Cache-Control Header是很有效的一招。如果HTTP
Response中有Expires这样的Header的话,浏览器会Cache这个资源,理想状况下(注意,只是理想状况),在Expire
Date之前,不会再发HTTP请求给Server要这个资源,不过Expires的值只能是一个固定日期,比如“Thu 27 Nov 2008
07:00:00
GMT”,不能是一个类似“从现在开始之后10年”这样一个随机浮动的值,如果要这样的效果,可以用Cache-Control这样的Header,如果
HTTP Response中有这样的Header:“Cache-Control: max-age =
100”,表示这个资源在cache中的最大寿命是100秒。一般说来这种静态文件永远不应该过期,如果真的要给这个Cache加上一个期限,那我希望是
——一万年,“Cache-Control: max-age = 315360000000”

其实就应该给Expires设一个永远不会过期的时间,比如你现在有一个文件叫logo.gif,需要用一个新的logo的时候,你不要去 覆盖原来的文件,而把新的logo存成logo_v2.gif,让相关网页引用新的logo_v2.gif,这样可以让新老网页同时工作,实在犯不上为了 节省存储空间覆盖原有文件。

对Apache服务器,使用mod_expires,在httpd.conf或者.htaccess中加上

<FilesMatch “\\.(ico|gif|jpg|html)$”>ExpiresDefault “access plus 10 years”</FileMatch>

3.Last-Modified/If-Modified-Since

有些数据随时都在变化。 CNN.com 的主页经常几分钟就更新。另一方面,Google.com 的主页几个星期才更新一次 (当他们上传特殊的假日 logo,或为一个新服务作广告时)。 Web 服务是不变的:通常服务器知道你所请求的数据的最后修改时间,并且 HTTP 为服务器提供了一种将最近修改数据连同你请求的数据一同发送的方法。


果你第二次 (或第三次,或第四次) 请求相同的数据,你可以告诉服务器你上一次获得的最后修改日期:在你的请求中发送一个
If-Modified-Since 头信息,它包含了上一次从服务器连同数据所获得的日期。如果数据从那时起没有改变,服务器将返回一个特殊的
HTTP 状态代码 304,这意味着 “从上一次请求后这个数据没有改变”。这一点有何进步呢?当服务器发送状态编码 304
时,不再重新发送数据。您仅仅获得了这个状态代码。所以当数据没有更新时,你不需要一次又一次地下载相同的数据;服务器假定你有本地的缓存数据。


有现代的浏览器都支持最近修改 (last-modified)
的数据检查。如果你曾经访问过某页,一天后重新访问相同的页时发现它没有变化,并奇怪第二次访问时页面加载得如此之快——这就是原因所在。你的浏览器首次
访问时会在本地缓存页面内容,当你第二次访问,浏览器自动发送首次访问时从服务器获得的最近修改日期。服务器简单地返回 304: Not
Modified (没有修改),因此浏览器就会知道从本地缓存加载页面。在这一点上,Web 服务也如此智能。

4. ETag/If-None-Match

ETag
是实现与最近修改数据检查同样的功能的另一种方法:没有变化时不重新下载数据。其工作方式是:服务器发送你所请求的数据的同时,发送某种数据的
hash (在 ETag 头信息中给出)。hash 的确定完全取决于服务器。当第二次请求相同的数据时,你需要在 If-None-Match:
头信息中包含 ETag hash,如果数据没有改变,服务器将返回 304 状态代码。与最近修改数据检查相同,服务器仅仅 发送 304
状态代码;第二次将不为你发送相同的数据。在第二次请求时,通过包含 ETag hash,你告诉服务器:如果 hash
仍旧匹配就没有必要重新发送相同的数据,因为你还有上一次访问过的数据。

这几个http头可以作为meta标签发送到客户端,但是需要注意的是Http头中的设置优先级更高一些,例如:

<meta. http-equiv=”Expires” CONTENT=” Fri, 30 Oct 1998 14:19:41″>

<meta. http-equiv=”Cache-Control” CONTENT=”no-cache”>

总结

Expires/Cache-Control Header是控制浏览器是否直接从浏览器缓存取数据还是重新发请求到服务器取数据。只是Cache-Control比Expires可以控制的多一些, 而且Cache-Control会重写Expires的规则。

Last-
Modified/If-Modified-Since和ETag/If-None-Match是浏览器发送请求到服务器后判断文件是否
已经修改过,如果没有修改过就只发送一个304回给浏览器,告诉浏览器直接从自己本地的缓存取数据;如果修改过那就整个数据重新发给浏览器。

来源: http://www.51testing.com/html/28/116228-238337.html

发表在 technologys | 标签为 , , , , | Expires,Cache-Control,Last-Modified,ETag已关闭评论

服务器名字指示SNI(Server Name Indication)

Server Name Indication是用来改善SSL(Secure Socket Layer)和TLS(Transport
Layer Security)的一项特性。它允许客户端在服务器端向其发送证书之前请求服务器的域名。这对于在虚拟主机模式使用TLS是必要的。

TLS背景

加密一个面向流的通讯会话最常用的方法之一就是使用TLS协议。比如,当用户在浏览器的地址栏里面输入https时就是在使用这个协议。

为了确认用户想要连接的站点就是浏览器实际连接到的站点,TLS使用包含站点域名的数字签名证书。客户端软件(比如浏览器)通常信任这个证书,如果这个证书是由其内置信任的认证机构签发的。
在TLS启动阶段,客户端软件比较用户输入的URI的域名部分与在服务器证书里面找到的域名部分,如果比较失败,浏览器会提示用户,这个站点的证书存在问题。

缺点

SSL v2的设计顺应经典的公钥基础设施PKI(public key infrastructure)设计,后者认为一个服务器只提供一个服务从而也就只使用一个证书。这意味着服务器可以在TLS启动的早期阶段发送或提交证书,因为它知道它在为哪个域服务。

HTTP服务器开启虚拟主机支持后,每个服务器通过相同的地址可以为很多域提供服务。服务器检查每一个请求来决定它在为哪个域服务。这个信息通常从
HTTP请求头获得。不幸的是,当设置了TLS加密,服务器在读取HTTP请求里面的域名之前已经向客户端提交了证书,也就是已经为默认域提供了服务。

因此,这种为虚拟主机提供安全的简单途径经常导致使用了错误的数字证书,从而导致浏览器对用户发出警告。

钓鱼连接

实际上,这意味着每一个HTTP服务器只能为一个域提供安全浏览。而事实上每一个web服务器都为很多域提供服务,结果就是其他的域无法使用安全通
信,从而处于危险境地。此外,安全浏览的缺乏使浏览器无法认证服务器,亦即它无法校验站点是否真的是属于宣称它的那个人或实体。钓鱼的一个重要因素是他们
企图通过虚假站点来获取用户的信息。使用SSL或者TLS安全连接,浏览器可以基于它的证书来认证站点。钓鱼站点不会作为一个欺骗性的站点得到认证,浏览
器会警告这个安全风险。然而,没有安全HTTP就没有标准的方法去认证服务器,使这种钓鱼的企图很容易就能实现。

修正

一个叫做SNI的TLS扩展通过发送虚拟域的名字做为TSL协商的一部分修正了这个问题。这会使服务器更早的切换到正确的虚拟域,并且发送给浏览器包含正确名字的数字证书。

行动

在2005年,人们意识到从SSL v2到TLS没有很容易的升级路径,并且站点不得不升级他们的软件来。为了尽快的推进,Mozilla宣告完全抛弃对SSL v2的支持。Firefox社区确信其余的站点会升级他们的服务器到SSL v3或TLS v1。

从2005年开始,CAcert在虚拟服务器上用不同的方法使用TLS来进行试验,大部分试验是不满意并且不实际的。比如,可以使用
subjectAltName在一个数字证书中包含多个域,但是这是一个证书,意味着所有的域必须被一个人拥有并控制,并且每次域列表发生变化,证书必须
重新发放。

2004年,EdelKey project为OpenSSL里面的TLS/SNI开发了一个补丁。2006年这个补丁进入OpenSSL的开发分支,2007年,它被向后移植到了OpenSSL 0.9.8,也就是当前的发行版本。

支持状况

支持SNI的浏览器

* Mozilla Firefox 2.0 or later
* Opera 8.0 or later (the TLS 1.1 protocol must be enabled)
* Internet Explorer 7 or later on Windows Vista or higher
* Google Chrome (Vista, not XP)
* Safari 3.2.1 Mac OS X 10.5.6

支持SNI的服务器

* Apache 2.2.12 or later using mod_ssl (or alternatively with experimental mod_gnutls)
* Cherokee if compiled with TLS support
* Versions of lighttpd 1.4.x and 1.5.x with patch
* Nginx with an accompanying OpenSSL built with SNI support
* acWEB with OpenSSL 0.9.8j and later (on Windows)

支持SNI的库

* Mozilla NSS 3.11.1 client side only
* OpenSSL
0.9.8f (released 11 Oct 2007) – not compiled in by default, can be compiled in with config option ‘–enable-tlsext’.
0.9.8j (released 07 Jan 2009) – now compiled in by default
Unreleased 0.9.9 is likely to include SNI compiled in by default.
* GNU TLS

不支持SNI的操作系统,浏览器和库

客户端

* Internet Explorer 6 or earlier and any IE version on Windows XP , windows 2003 or earlier
* Konqueror/KDE in any version

服务器端

* Microsoft Internet Information Server IIS (As of 2009).
* Apache Tomcat 8 or earlier

* Qt
* Mozilla NSS server side
* Python

windows和IE

可以看得出,windows XP和windows 2003 server系统上的任何IE版本浏览器都是不支持SNI的, vista及以后系统上的IE 7及更高版本的IE浏览器支持SNI。IE6及更早版本的IE浏览器在任何系统上都是不支持SNI的。

tomcat

tomcat当前的稳定版8尚不支持SNI,tomcat 9才会支持,以后可能会backport到tomcat 8和7。可以使用nginx反向https代理后端的tomcat,参见[2]

SNI测试

用浏览器或其他https客户端比如wget等访问SNI测试站点https://sni.velox.ch/即可以知道浏览器或客户端是否支持SNI。

References:
[1]Server Name Indication
[2]Setting up NGINX SSL reverse proxy for Tomcat
[3]HowTo setup Tomcat serving two SSL Certificates using SNI?

 

文章来源: http://openwares.net/misc/server_name_indication.html

发表在 technologys | 标签为 | 服务器名字指示SNI(Server Name Indication)已关闭评论

C#堆栈、队列、递归实现的快速排序

参考: https://zh.wikipedia.org/zh-hant/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F#C.23

static void Qsort(int[] data, int low, int high)//递归实现
        {
            if (low >= high) return;
            int i, j, pivot;
            i = low;
            j = high;
            pivot = data[low];
            while (i < j)
            {
                while (data[j] > pivot) j--;
                data[i] = data[j];
                while (i < j && data[i] <= pivot) i++;
                data[j] = data[i];
            }
            data[i] = pivot;
            Qsort(data, low, i - 1);
            Qsort(data, i + 1, high);
        }
       //堆栈实现
        public static void StackQS(int[] data)
        {
            int i, j, low, high, pivot;
            Stack<int> MyStack = new Stack<int>();
            MyStack.Push(0);
            MyStack.Push(data.Length - 1);
            while (MyStack.Count > 0)
            {
                j = high = MyStack.Pop();
                i = low = MyStack.Pop();
                if (low >= high) continue;
                pivot = data[low];
                while (i < j)
                {
                    while (data[j] > pivot) j--;
                    data[i] = data[j];
                    while (i < j && data[i] <= pivot) i++;
                    data[j] = data[i];
                }
                data[i] = pivot;
                MyStack.Push(low);
                MyStack.Push(i - 1);
                MyStack.Push(i + 1);
                MyStack.Push(high);
            }
        }
      //队列实现
       public static void QueueQS(int[] data)
        {
            int i, j, low, high, pivot;
            Queue<int> MyQueue = new Queue<int>();
            MyQueue.Enqueue(0);
            MyQueue.Enqueue(data.Length-1);
            while(MyQueue.Count>0)
            {
                i = low = MyQueue.Dequeue();
                j = high = MyQueue.Dequeue();
                if (low >= high) continue;
                pivot = data[low];
                while(i<j)
                {
                    while (data[j] > pivot) j--;
                    data[i] = data[j];
                    while (i < j && data[i] <= pivot) i++;
                    data[j] = data[i];
                }
                data[i] = pivot;
                MyQueue.Enqueue(low);
                MyQueue.Enqueue(i-1);
                MyQueue.Enqueue(i+1);
                MyQueue.Enqueue(high);
            }
        }
发表在 .net | 标签为 , | C#堆栈、队列、递归实现的快速排序已关闭评论

C#集合--Dictionary

字典(dictionary)是一个集合,其中每个元素都是一个键/值对。字典(Dictionaries)是常用于查找和排序的列表。

.NET Framework通过IDictionary接口和IDictionary<TKey,TValue>接口,以及一些常用的子典了定义了子典协议。每个类在以下方面各有不同:

  • 元素是否已经排序
  • 元素是否能通过索引或键来获取
  • 字典类是generic的还是非generic的
  • 当字段较大时,根据键值获取元素速度的快慢

下表总结了每个字典类,以及它们在上述这几个方面的差异。它们都是在一个1.5G的PC上执行5000次操作得到的一个平均值。

Type 内部结构 支持索引 内存占用 随机插入的速度(毫秒) 顺序插入的速度(毫秒) 根据键获取元素的速度(毫秒)
未排序字典            
Dictionary<T,V> 哈希表 22 30 30 20
Hashtable 哈希表 38 50 50 30
ListDictionary 链表 36 50000 50000 50000
OrderedDictionary 哈希表
+数组
59 70 70 40
排序字典            
SortedDictionary<K,V> 红黑树 20 130 100 120
SortedList<K,V> 2xArray 20 3300 30 40
SortList 2xArray 27 4500 100 180

从时间复杂度来讲,从字典中通过键获取值所耗费的时间分别如下:

  • Hashtable, Dictionary和OrderedDictionary的时间复杂度为O(1)
  • SortedDictionary和SortList的时间复杂度为O(logN)
  • ListDictinary的时间复杂度为O(n)

n是集合元素的数量。

 

摘自: http://www.cnblogs.com/yang_sy/p/3678905.html

发表在 .net | C#集合--Dictionary已关闭评论

微博feed/push/pull/时间分区拉模式架构探讨

引用文章:

http://www.cnblogs.com/sunli/archive/2010/08/24/twitter_feeds_push_pull.html

[文章作者:孙立 链接:http://www.cnblogs.com/sunli/ 更新时间:2010-08-24]

 

 sns系统,微博系统都应用到了feed(每条微博或者sns里的新鲜事等我们称作feed)系统,不管是twitter.com或者国内的新浪微博,人人网等,在各种技术社区,技术大会上都在分享自己的feed架构,也就是推拉模式(timyang上次也分享了新浪微薄的模式)。下面我们就微博的feed推拉(push,pull)模式做一下探讨,并提出新的时间分区拉模式。

     当你发表一篇微博,那么所有关注你的followers(粉丝)都会在一定的时间内收到你的微薄,这有点像群发一封邮件,所有的抄送者都会在一定的时间内收到。到这里,你可能觉得没有什么难度。

 

    例新浪微博的姚晨粉丝有2594751,她发表任何一篇微博,都需要2594751个粉丝在一定的时间内收到,twitter的冯大辉发表一篇的话,需要19868个followers收到。

点击查看原图

 

 图三:微博整体结构

       图中展示了微博的整体数据流程,先了解下整体的数据结构,没有涉及到followers等的推拉模式处理。下面我们再看下推模式(push):

点击查看原图

 图四:推模式结构

   推模式需要把一篇微博推送给所有关注他的人(推给所有的粉丝),比如姚晨,我们就需要推送给2594751个用户的feeds表中。当然,feeds表可以很好的进行sharding,存储也都是一些数字型的字段,存储空间可能不是很大,用户在查询自己关注的所有人的feed时,速度快,性能非常高,但是推送量会非常大,姚晨发表一篇,就会产生200多万条数据。试想,一个大量用户的微薄系统通过使用推模式,是不是会产生非常惊人的数据呢?

    下面看下拉模式(pull)

点击查看原图

 

 图五:拉模式

     拉模式只需要用户发表微博时,存储一条微博数据到feeds表中(feeds表可以是一个临时表,只保存近期可接受范围的数据).用户每次查询feed时都会去查询feeds表。比如姚晨打开自己的微薄首页,就产生:SELECT id FROM feeds where uid in(following uid list) ORDER BY id DESC LIMIT n(查询最新的n条),缓存到memcached

uidlist=>{data:id list,timeline:上次查询出来的最新的一条数据的时间}

再次刷新:SELECT id FROM feeds where uid in(following uid list) AND timeline>(memcached存储的上次的timeline) ORDER BY id DESC LIMIT n

 

    这种模式实现起来也是比较简单和容易的,只是在查询的时候需要多考虑下缓存的结构。但是feeds表会产生很大的压力,怎么说feeds表也要保存最近十天半个月的数据吧,对于一个大点的系统,这会产生比较大的数据,如果following的人数比较多,数据库的压力就会非常大。而且一般在线的用户,客户端都会定期扫描,又会增加很大的压力,这在查询性能上没有推模式的效率高。

     下面我们在对拉模式做一下改进优化

点击查看原图

图五:拉模式(pull)-改进(时间分区拉模式)

           拉模式的改进主要是在feeds的存储上,使用按照时间进行分区存储。分为最近时间段(比如最近一个小时),近期的,比较长时期等等。我们再来看下查询的流程,比如姚晨登陆微博首页,假设缓存中没有任何数据,那么我们可以查询比较长时期的feeds表,然后进入缓存。下一次查询,通过查询缓存中的数据的timeline,如果timeline还在最近一个小时内,那么只需要查询最近一个小时的数据的feed表,最近一个小时的feeds表比图四的feeds表可要小很多,查询起来速度肯定快几个数量级了。

          改进模式的重点在于feeds的时间分区存储,根据上次查询的timeline来决定查询应该落在那个表。一般情况下,经常在线的用户,频繁使用的客户端扫描操作,经常登录的用户,都会落在最近的feeds表区间,查询都是比较高效的。只有那些十天,半个月才登录一次的用户需要去查询比较长时间的feeds大表,一旦查询过了,就又会落在最近时间区域,所以效率也是非常高的。

         关于时间的分区,需要根据数据量,用户访问特点进行一个合理的切分。如果数据发表量非常大,可以进行更多的分区。

        上面介绍的推模式和拉模式都有各自的特点,个人觉得时间分区拉模式弥补了图四的拉模式的很大的不足,是一个成本比较低廉的解决方案。当然,时间分区拉模式也可以结合推模式,根据某些特点来增加系统的性能。

发表在 push/pull | 标签为 | 微博feed/push/pull/时间分区拉模式架构探讨已关闭评论

linux mail

linux mail 命令参数:

使用mail发邮件时,必须先将sendmail服务启动。
mail –s “邮件主题” –c ”抄送地址” –b “密送地址” -f 发送人邮件地址 –F 发件人姓名 < 要发送的邮件内容

Usage: mail [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
[-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr …
mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]
mail [-BDeinNRv~] [-A account] [-u user]

三种常用格式发信:
  mail -s test yangfang@fudan.edu.cn #第一种方法,你可以把当前shell当成编辑器来用,编辑完内容后Ctrl-D结束
  echo “mail content”|mail -s test yangfang@fudan.edu.cn #第二种方法,我用的最多,可能是喜欢管道的缘故吧
  mail -s test yangfang@fudan.edu.cn < file #第三种方法,以file的内容为邮件内容发信

指定特定的发送人:
$ mail -s "just a test" -r 发送人地址 收信人邮箱地址 < 要发送的邮件内容文件

效果是: 信件内容将发送给 收信人邮箱,显示的发送人为 发送人姓名<发送人邮件地址>,显示的内容为 发送的邮件内容...
包含命令执行结果的MAIL发送:
echo -e `ls /tmp`|mail -s "test" -r xx@xx.com fff@aaa.com < /tmp/dd.txt

i 忽略 tty 的中断讯号。(interrupt)
I 强迫设成互动模式。(Interactive)
v 列印出讯息,例如送信的地点、状态等等。(verbose)
n 不读入 mail.rc 设定档。
s 邮件标题。
c cc 抄送邮件地址。
b bcc密送邮件地址

需要sendmail或postfix服务

如果单纯的发文件文件可以用
cat xxxx.txt |mail -s "主旨" abc@xxx.com fff@xxx.com

如果需要发送附件需要安装uuencode来编码 (yum install sharutils)
单独发附件,这样xxxx@xxx.com会收到一个data.txt的附件
uuencode /tmp/data_process.log  data.txt |mail xxx@xxx.com

如果需要正文和附件一起发:
uuencode /tmp/data_process.log  data.txt > /tmp/data_temp.txt
 

系统收到邮件都会保存在“/var/spool/mail/[linux用户名]”文件中。在linux中输入mail ,就进行了收件箱,并显示二十封邮件列表。


利用外部的smpt服务器:
通过修改配置文件可以使用外部SMTP服务器,可以不安装sendmail或postfix:
修改/etc/nail.rc (/etc/mail.rc)
set from=fromUser@domain.com smtp=smtp.domain.comset smtp-auth-user=username smtp-auth-password=passwordset smtp-auth=login

说明:
from        是发送的邮件地址
smtp        是发生的外部smtp服务器的地址
smtp-auth-user            是外部smtp服务器认证的用户名
smtp-auth-password        是外部smtp服务器认证的用户密码
smtp-auth                是邮件认证的方式

测试:
mail -s "test" username@163.com < content.txt 其中-s后面的是邮件标题,user@sohu.com是收件人地址,content.txt里面是邮件正文

mail 命令的使用
mailq可以查看系统队列

 

sendmail 发送:

 

echo "From: sender <sender@domain.com>
To: to <to@domain.com>
Content-type: text/html;charset=utf-8
Subject: Saying Hello

内容1行
内容2行
内容3行
内容4行
" | sendmail to@domain.com

发表在 linux | 标签为 | linux mail已关闭评论

systemctl

systemd查看开机自启动的程序(相当于chkconfig --list)

ll /etc/systemd/system/multi-user.target.wants/

 

运行一个服务:

systemctl start network.service

关闭网络服务:

systemctl stop network.service

重启网络服务:

systemctl restart network.service

显示一个服务(无论运行与否)的状态:

systemctl status network.service

在开机时启用一个服务:

systemctl enable network.service

在开机时禁用一个服务:

systemctl disable network.service

查看服务开机是否启动:

systemctl is-enabled network.service

 

常用systemctl命令start,stop,restart,status,enable,disable,is-enabled,is-active。

 

####################

1. 列出所有可用单元

# systemctl list-unit-files

2. 列出所有运行中单元

# systemctl list-units

3. 列出所有失败单元

# systemctl –failed

4. 检查某个单元(如 crond.service)是否启用

# systemctl is-enabledcrond.service

5. 列出所有服务

# systemctl list-unit-files –type=service

6. Linux中如何启动、重启、停止、重载服务以及检查服务(如 httpd.service)状态

# systemctl start httpd.service

# systemctl restart httpd.service

# systemctl stop httpd.service

# systemctl reload httpd.service

# systemctl status httpd.service

注意:当我们使用systemctl的start,restart,stop和reload命令时,终端不会输出任何内容,只有status命令可以打印输出。

7. 如何激活服务并在开机时启用或禁用服务(即系统启动时自动启动mysql.service服务)

# systemctl is-active mysql.service

# systemctl enable mysql.service

# systemctl disable mysql.service

8. 如何屏蔽(让它不能启动)或显示服务(如ntpdate.service)

# systemctl mask ntpdate.service

ln -s ‘/dev/null”/etc/systemd/system/ntpdate.service’

# systemctl unmask ntpdate.service

rm ‘/etc/systemd/system/ntpdate.service’

9. 使用systemctl命令杀死服务

# systemctl killcrond

10. 列出所有系统挂载点

# systemctl list-unit-files –type=mount

11. 挂载、卸载、重新挂载、重载系统挂载点并检查系统中挂载点状态

# systemctl start tmp.mount

# systemctl stop tmp.mount

# systemctl restart tmp.mount

# systemctl reload tmp.mount

# systemctl status tmp.mount

12. 在启动时激活、启用或禁用挂载点(系统启动时自动挂载)

# systemctl is-active tmp.mount

# systemctl enable tmp.mount

# systemctl disable tmp.mount

13. 在Linux中屏蔽(让它不能启用)或可见挂载点

# systemctl mask tmp.mount

ln -s ‘/dev/null”/etc/systemd/system/tmp.mount’

# systemctl unmask tmp.mount

rm ‘/etc/systemd/system/tmp.mount’

14. 列出所有可用系统套接口

# systemctl list-unit-files –type=socket

15. 检查某个服务的所有配置细节

# systemctl showmysql

16. 获取某个服务(httpd)的依赖性列表

# systemctl list-dependencies httpd.service

17. 启动救援模式

# systemctl rescue

18. 进入紧急模式

# systemctl emergency

19. 列出当前使用的运行等级

# systemctl get-default

20. 启动运行等级5,即图形模式

# systemctl isolate runlevel5.target

# systemctl isolate graphical.target

21. 启动运行等级3,即多用户模式(命令行)

# systemctl isolate runlevel3.target

# systemctl isolate multiuser.target

22. 设置多用户模式或图形模式为默认运行等级

# systemctl set-default runlevel3.target

# systemctl set-default runlevel5.target

23. 重启、停止、挂起、休眠系统或使系统进入混合睡眠

# systemctl reboot

# systemctl halt

# systemctl suspend

# systemctl hibernate

# systemctl hybrid-sleep

对于不知运行等级为何物的人,说明如下。

Runlevel 0 : 关闭系统

Runlevel 1 : 救援,维护模式

Runlevel 3 : 多用户,无图形系统

Runlevel 4 : 多用户,无图形系统

Runlevel 5 : 多用户,图形化系统

Runlevel 6 : 关闭并重启机器

 

...

 

 

 

 

发表在 linux | systemctl已关闭评论

nc

测试80端口

nc -z -w 1 www.google.com  80

nmap -sT www.google.com -p  80

 

测试UDP 53端口

nc -u -z -w 1 8.8.8.8 53

nmap -sU 8.8.8.8 -p 53

 


发表在 linux | 标签为 | nc已关闭评论