Showing posts with label live space. Show all posts
Showing posts with label live space. Show all posts

Thursday, February 19, 2009

[搬移]密码强度计算

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!909.entry
February 20, 2008


上网查了好几种算法,都不满意

最后根据几种算法,再加上最早就已经确定的加权的思想,把代码写成了

但是毕竟复杂度aaa111和a1a1a1是不一样的,可是目前的实力没法计算,只能用一些简单的count了

基本算法流程如下:

输入数据(密码字符串,用户名可选)=>

检查长度,小于4则出发错误;否则=>

检查用户名,如果case insensitive条件下和密码相同,直接报弱密码;否则=>

权值为密码长度*4=>

分别计算数字、特殊符号、大写字母、小写字母的个数=>

权值+= 数字个数 /6 * 4=>

权值+= 特殊符号个数 *4 =>

权值+=小写字母个数=>

权值+=大写字母个数*2=>

如果大小写都存在,则权值+=5 =>

如果数字加符号混合,权值+=15 =>

如果数字和字母混合,权值+=10 =>

如果字母和符号混合,权值+=15 =>

如果纯字母,权值-=10 =>

如果纯数字,权值-=15 =>

划定范围



现在这个权值的确定还是不合适,估计得花时间测试;而且范围的确定也不太好

基本确定了5级:weak, medium, good, strong, insane

目前的密码除了********算是weak,其他至少都是medium,insane的不少



第一次写了个ajax

用了prototype

比较了下prototype和jQuery的例子,发现前者比较适合自己的编程风格

(jQuery最早是soff告诉我的,而且联盟用的就是,还在关注...)

发现用了框架,开发真的很简单

继续Recoding...

[搬移]汉化了一个软件

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!905.entry
February 16, 2008


TrayIt!

一个使用Hook将窗体最小化到系统托盘的工具

很不错的

但是默认没有汉语的语言配置,索性就自己翻译了一个,虽然很多词实在想不出来用什么汉语表示

一直都是只可意会的

总之,汉化完了

虽然英文版对我而已没有任何障碍

另外,作者的typo实在太多了

[搬移]UnrealIRCd 密码生成

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!910.entry
February 21, 2008

密码块支持的格式可以为 password {[AUTH-TYPE;]};
默认都是明文的,所以可选的[]内容为空,如Oper block的password "31343540";
但是为安全考虑,必须对密码进行加密
unrealircd支持的格式有crypt, md5, and sha1, ripemd-160
最开始以为用函数直接生成就行了,但是系统始终报Incorrect password
查了查文档,没找到;翻了翻论坛,看到一个/mkpasswd,参数格式是 /mkpasswd AUTHTYPE PASSWORD
执行需要有Oper的权限
目前已经把IRCd的NetAdmin密码加密了,还有restart和die的,只是这两个的权限都没分配

OVER

[搬移]the comparision of scrambled words ...

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!911.entry
February 21, 2008


for HTS prog mission 1, find unscrambled words from a wordlist

three ways available:

a) compare the checksum

b) compare the string after been sorted

c) split to array and then use array_diff



for a) : 1278 lines of wordlist, but less than 800 different checksums, this way is somewhat fast but not very accurate.

for b) : i coded a sort function to sort a string, then loop comparing it with sorted strings from the wordlist line by line, this takes about 1.02s.

for c) : a function like this:

function diff($string1, $string2)
{
return array_diff(str_split($string1, 1), str_split($string2, 1));
}

the main part of the two php scripts are almost the same, but in this way it only takes about 0.23s to find unscrambled words from the 1278-line-txt-wordlist file.

[搬移]诡异地把php-gtk编译好了

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!937.entry
March 06, 2008

命名按照当时在3.3上配的环境,但是每次编译都error

而且代码还调用了一个php脚本生成文件

差一点准备手工改那个.c和dsp了

刚才特意注意了下编译的错误信息,居然发现是环境变量的目录的问题,因为从网上下的zip包的lib和include的gtk都太老了,所以又把新的那部分给覆盖了过去,而且还把cairo也放到了include下



目前扩展只编译成功了php_gtk2.dll和php_gtk_extra2.dll,其他的估计得等相关的win32版本出来才行

等待吧...

[搬移]Enable Http Proxy for pear/pecl command on M$ windows

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!966.entry
March 30, 2008

set http_proxy=http://user:pass@10.1.8.9:38080


然后就可以

pear download DB

[搬移]清除CCProxy日志

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1006.entry
May 10, 2008

唉,代理丢了。。。

只能用ad上国际了



10.1.8.10的ad,暂时还是用ccproxy开代理做限制的

然后,按帐户,记录日志



不想留下记录



    $dir = 'D:/CCProxy/Log'; //定义日志目录 

$files = glob($dir.'/log*.txt');//日志文件
foreach($files as $value)//循环
{
$mtime = filemtime($value);//获取修改时间
$contents = file_get_contents($value);//获取文件内容
$contents = preg_replace('/\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\] \d+\.\d+\.\d+\.\d+ sskaje.*\n/', '', $contents);//替换为空
file_put_contents($value, $contents);//写入
$file = file($value);//重新获取
$file[0] = (count($file)-1) . "\r\n";//计算行数
file_put_contents($value, implode('', $file));//重新写入
touch($value, $mtime, $mtime);//恢复修改时间
}
?>

[搬移]Build PHP's Extensions with VS 2005

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1030.entry
June 16, 2008


习惯了编译ImageMagick的PHP API,经常遇到编译错误
不过这些错误也就只有在VC6下才会有
而且,VC6,实在太老了
索性,迁移吧

看了看php官方文档,确认用vs05编译可行
然后,03的虚拟机花了3个小时装了VS05,打了sp1
再装了Intel C++ Compiler
接下来,先编译ImageMagick,没问题,一切正常,编译比较顺利
不过想用Intel C++ Compiler编译的时候,发现错误实在太多了
应该是intel的东西对语法要求比较严格吧

嗯,把php的编译环境搭好,先编译resolv.lib,很轻松,dsw直接转sln就可以编译了
然后,配好win32build,加好环境变量
又把扩展的相关文件拷过去了
基本还是vc6下的一套东西

编译,不行,出错
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\sys/stat.inl(49) : error C
2466: cannot allocate an array of constant size 0
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\sys/utime.inl(39) : error
C2466: cannot allocate an array of constant size 0
这种错误
无语
没见过
上网查,baidu甭想了
google,没有明确的东西
但是看到了php 的bug report里有个 http://bugs.php.net/bug.php?id=39130
定位到了main/config.w32.h

/* vs.net 2005 has a 64-bit time_t. This will likely break
* 3rdParty libs that were built with older compilers; switch
* back to 32-bit */
#define _USE_32BIT_TIME_T 1
#define HAVE_STDLIB_H 1

看到了块注释的部分,嗯,把这个第一行注释掉就行了

然后,imagick,magickwand顺利编译
eaccelerator的,还得在svn里吧fnmatch的.c和.h都拷过来才能编译

[搬移]双重路由 ?

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1044.entry
July 20, 2008

为了让自己的emule运行在highid下,没辙了,配路由映射吧

首先,IP段换了,从10.1.8.0/23变成了 10.1.16.0/23,三个屋
结果吧,我想大家都在一个教研室/实验室,出问题了很容易查到人,索性就把ARP的规则去了吧
好吧,那就去了
结果,早上才发现,还是有台机器中毒了,而那台机器很和谐地ARP,而QQ/MSN又很和谐的用IE的核走HTTP传数据
然后就很和谐地中毒了
XD

okay
然后,新的VPN/代理也从 10.1.8.10 -> 10.1.16.10
首先,VPN拨号进去,分配的是一个静态的地址,这个VPN是在windows 2003上用路由和远程访问配置的,主要作用是做NAT,只是我觉得无非多点几个checkbox而已,还不至于麻烦到懒得配VPN,索性VPN也就上去了
okay,电驴用的是6251端口,随机的,也就定下来了
由于NAT已经配好了,现在开始设置
“IP路由选择”里边选“NAT/基本防火墙”,在右边的主窗口选择公网的网卡,右击,属性
在“服务和端口”标签页里,“添加”,“服务描述”随便填,因为前一个窗口的IP池没配置,所以这里第一个radio只有一个可用选项
协议,TCP
“传入端口”填6251,“专用地址”填172.16.0.123
这个是VPN静态设置的IP
“传出端口”也填6251

确定
这一块就搞定了

然后,路由器
Dlink的DI-704P
之前尝试特殊应用程序,而没有选择虚拟服务器
因为前者实在弄不懂是干嘛的,而后者就是标准的路由端口映射
结果发现填的数据不是自己想要的
所以选择了虚拟服务器
添加项目即可

然后
http://www.emule.org.cn/porttest/?tcpport=6251&submit=%B2%E2%A1%A1%CA%D4
测试
嗯,成功

两次连接的日志
2008-7-20 1:52:56: 正在连接到 no1.eserver.emule.org.cn (no1.eserver.emule.org.cn:8080 - 正在使用模糊协议)...
2008-7-20 1:52:56: 连接到no1.eserver.emule.org.cn(no1.eserver.emule.org.cn:8080),发送登陆请求
2008-7-20 1:53:07: 警告 no1.eserver.emule.org.cn (no1.eserver.emule.org.cn:8080) - You have a lowid. Please review your network config and/or your settings.
2008-7-20 1:53:07: 模糊连接已经建立在: no1.eserver.emule.org.cn (no1.eserver.emule.org.cn:8080)
2008-7-20 1:53:07: 新的客户ID为 2546274

2008-7-20 1:55:32: 正在连接到 no1.eserver.emule.org.cn (no1.eserver.emule.org.cn:8080 - 正在使用模糊协议)...
2008-7-20 1:55:32: 连接到no1.eserver.emule.org.cn(no1.eserver.emule.org.cn:8080),发送登陆请求
2008-7-20 1:55:32: 模糊连接已经建立在: no1.eserver.emule.org.cn (no1.eserver.emule.org.cn:8080)
2008-7-20 1:55:32: 新的客户ID为 1329300446

[搬移]编译 curl with openssl && zlib

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1047.entry
July 23, 2008


编译 curl with openssl && zlib
首先下载源码文件
zlib-1.2.3
openssl-0.9.8h
curl-curl-7.18.2
解压之后,形成如下目录树:
build -
curl -
curl-7.18.2
openssl
-
openssl-0.9.8h
zlib
-
zlib-1.2.3

zlib:
用MSVS2005 的command prompt启动
进入zlib的源码目录,执行
nmake -f win32/Makefile.msc
执行完成不必做多余操作

openssl:
首先得安装Perl并添加到path变量中
接下来
perl Configure VC-WIN32 --prefix=E:/build/openssl/openssl
为编译curl的openssl支持,得静态编译
所以
nmake -f ms\nt.mak
nmake -f ms\nt.mak install

curl:
cd进入目录,这里我们首先得编译libcurl
进入lib目录
修改Makefile.vc8
!IFNDEF ZLIB_PATH
ZLIB_PATH = ../../../zlib/zlib-1.2.3
!ENDIF
!IFNDEF OPENSSL_PATH
OPENSSL_PATH = ../../../openssl/openssl-0.9.8h
!ENDIF
然后执行
nmake /f makefile.vc8 CFG=release-ssl-zlib
进行release版的静态编译
完毕之后当前目录会有个 libcurl.lib
这里很诡异的事情,如果直接用vc6的dsw文件生成的文件在release\curllib.lib
而用makefile.vc6/8则是libcurl.lib,不知道写makefile的人咋想的
然后回到 curl-7.18.2/src
继续
nmake -f Makefile.vc8 cfg=release-ssl-zlib
完毕,当前目录就有个curl.exe,就是静态编译后的版本

[搬移]关于PHP的标签闭合

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1321.entry
November 26, 2008

犯错了才会明白

原来不闭合的一大好处是,防止出现无谓的空字符

在OB启用的情况下,页面没有太大差别

但是如果是其他类型的mimetype -> header,例如图片。。。

所以,现在没事,不再闭合标签

[搬移] PHP 5.3 新 Namespace 初探

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1337.entry
December 06, 2008


白天的时候,收到邮件,PHP5.2.7正式发布了,经历了5个RC。同时,早几分钟,PHP5.3的Alpha3也正式发布了。诡异的是居然把Alpha4放在RC的栏目里。

从官网新闻的说明,最重要的更新,第一项就是namespace,而且按官网所说,相关文档已经更新。
翻了翻相关的文档部分,一个最大的区别,操作符的变化。毕竟以前只是简单地拿文档的用例做过测试,并没有尝试在自己的代码里加入相关内容,所以对细节的东西了解还是不多,但是操作符号的变化,最直观。

前一个版本的文档中,namespace的操作符也是所谓的 Scopes Resolution Operator, 即 ::;但是新的版本中,已经换成了反斜杠 \
于是,子空间的用法类似 namespace NameSpace\SubNameSpace,namespace中全局函数的标准调用方法 \strlen($string)

脚本文件中,namespace语句的启用,必须保证前面没有declare之外的使用,多个namespace的时候只要处理第一个。
顺道一句,ticks按计划,在5.3中已经被deprecated了,而在6中将移除。
但是同时这里又多了一个项目,encoding,形如 declare(encoding='UTF-8');

然后,部分调用的用法,如use,暂时还没测试。


EDIT: 并非所有的global函数都得用\来调用,事实是,某些根本不能这样用,不确定是不是namespace的机制还没写好,测试了,require_once, isset之类的“函数”是没法这样的,必须直接调用,否则就有个T_STRING的错误。毕竟这些不是真正的函数。http://www.php.net/manual/en/reserved.php

[搬移]test for get_called_class();

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1345.entry
December 25, 2008

class ap {
public function ap_call() {
echo "\t", get_called_class(), "\n";
}

public function ap_sub_call_p() {
$p = new p;

$p->p_call();
}

public function ap_sub_call_c() {
$c = new c;

$c->c_call();
}
}

class p extends ap{
public function p_call() {
echo "\t", get_called_class(), "\n";
}

public function p_parent_call_ap() {
$ap = new ap;

$ap->ap_call();
}

public function p_sub_call_c() {
$c = new c;

$c->c_call();
}
}

class c extends p {
public function c_call() {
echo "\t", get_called_class(), "\n";
}

public function c_parent_call_p() {
$p = new p;

$p->p_call();
}

public function c_parent_call_ap() {
$ap = new ap;

$ap->ap_call();
}
}

$ap = new ap;
$p = new p;
$c = new c;

echo "These are called in/from ap:\n";
$ap->ap_call();
$ap->ap_sub_call_p();
$ap->ap_sub_call_c();

echo "\n\nThese are called in/from p:\n";
$p->p_call();
$p->p_parent_call_ap();
$p->p_sub_call_c();
echo "These are inherit from ap:\n";
$p->ap_call();
$p->ap_sub_call_p();
$p->ap_sub_call_c();

echo "\n\nhese are called in/from c:\n";
$c->c_call();
$c->c_parent_call_ap();
$c->c_parent_call_p();

echo "These are inherit from p:\n";
$c->p_call();
$c->p_parent_call_ap();
$c->p_sub_call_c();

echo "These are inherit from ap:\n";
$c->ap_call();
$c->ap_sub_call_p();
$c->ap_sub_call_c();

/*
result:

These are called in/from ap:
ap
p
c


These are called in/from p:
p
ap
c
These are inherit from ap:
p
p
c


hese are called in/from c:
c
ap
p
These are inherit from p:
c
ap
c
These are inherit from ap:
c
p
c
*/

[搬移]Smarty Error: Fatal error: Call to undefined function _smarty_tplfunc_*********()

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1347.entry
January 01, 2009


Fatal error: Call to undefined function _smarty_tplfunc_d7b98222edd24b4c42c830151342bfe2_0() in G:\wwwroot\vhosts\Newborn\include\class\externals\smarty\libs\Smarty.class.php on line 1828


出错在缓存开启的时候
只要把编译的模板和缓存都清掉就行了

[搬移]mysql error 121 when creating tables

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1346.entry
December 26, 2008



一个原因是外键名重复,改个名就行了

[搬移]很2的开socks代理方式 :X

http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1348.entry
January 03, 2009



ssh localhost -f -N -D0.0.0.0:31080 -g

然后输密码

虽然会有错误提示,但是可以正常用 :X

netstat -anp | more 看看就知道了

省去了开客户端的麻烦

[搬移] mysql error when using symlink to share databases

搬移自 http://sskaje.spaces.live.com/blog/cns!CD0E835D6C568521!1349.entry
January 07, 2009


working under ubuntu.
just wanna make mysql databases created under m$win can be used.
1st, fstab, just to mount the partition automatically
2nd, symlink, #/var/lib/mysql, do 'ln -s /media/App/Server/MySQL/MySQL\ Server\ 5.1/data/forum forum'
3rd, restart mysql.
vbb reports a fatal error; when using mysql client, show tables would report an error like '
mysql> show tables;
ERROR 1018 (HY000): Can't read dir of './forum/' (errno: 13)
'

why ?

iv already chown mysql\: to that directory.

er...

apparmor...

check the /etc/apparmor.d/usr.sbin.mysqld, add some lines to make that directory readable/writable to mysqld.