存档

2009年8月 的存档

两只Jetbeam

2009年8月31日 Python

JETBEAM III M 和 ST

jet1

jet2

jet3

分类: 09 . 我的玩具 标签:

黑客手册 2009-09

2009年8月31日 Python

恩,有点细节我还是没注意到,不过想要的效果应该算是出来了,还以为土豆会用白色字体的那张呢 ……

nohack0909

分类: 01 . 杂七杂八 标签:

朗基努斯(Longinus)其人

2009年8月31日 Python

据说这个人是真正存在的,但西方的信仰就好象我们相信道教中的天师一样,都认为存在着却又没有可说服人的确切存在物,不过这依然不影响大家的信仰,如果说破了、证明了,也许就难以成为信仰了。

朗基努斯这个人多次在圣经中被提及,但提到他的方式仅仅说到他是百夫长(注:罗马时期的军衔,百人编队的队长是百夫长,但罗马时期的百夫长长官的往往不是百人而是80个人左右)而没有提到他的名字是什么(参考:Matthew 27:54 和 Mark 15:39)。
Longinus这个名字曾出现于伪经《Gospel of Nicodemus》中。而这个名字第一次在书面中出现是在一份福音手稿中出现的,手稿中画有一张耶稣受刑的图片,图片中一个士兵手举一只长矛,图片旁边就写着“Longinus”这个词,而这个词与希腊语中的长枪(longche)一词很接近,所以有人认为这是希腊语longche一词在拉丁化之后的样子(不过拉丁语中仍然有长枪、长矛这个词:lancea)。
这里士兵手持的长矛就是圣枪(holy lance)了(因为它占满了耶稣的血),这个长矛还有一些其他叫法:朗基努斯之枪(spear of longinus 或 Lance of Longinus)或是命运之枪(spear of destiny)。

christ_on_the_cross

longinus_pierces_the_side_of_christ

分类: 05 . 不靠谱的神话 标签:

解析 firefox 的 Bookmark

2009年8月28日 Python

因为家里有多台电脑,所以一直想弄个脚本来做firefox的书签检查,主要是定期检查每台电脑之间的书签分别发生了什么样的变化,以便及时更新和统一书签,也防止一些书签误删

不过做这个的第一步就是要解析firefox的书签,firefox的大部分内容都是通过sqlite来存储的,还算比较容易,sqlite文件在firefox的profiles文件夹中,一般路径是在 %APPDATA%MozillaFirefoxProfiles 目录下有个以default结尾的目录,目录中会有多个sqlite文件,其中 places.sqlite 是最重要的,书签以及访问历史记录都存储在这里

书签不是直接存储在一个特定表里,而是分别在 moz_bookmarks 和 moz_places 两个表中,moz_places中记录了书签还有所有访问过的地址,而moz_bookmarks只是记录了一些书签的id(在moz_bookmarks中体现为 fk 列) 和 书签的名字(moz_bookmarks中体现为title列),而moz_bookmarks 的fk 列 和 moz_places 中的 id 列是对应的,而moz_places 中的 url 列又记录了所有的地址,因此,就有这样的对应关系:

moz_bookmarks 中 :fk —> tilte  ,moz_places中: id —> url ,同时:fk == id ,即,两张表通过fk和id来建立联系

当然,除了这些之外,如果需要查找上级目录的话(firefox标签中的目录),还需要考虑到其他列,在这里先把最简单的对应关系搞清楚,其他的以后慢慢再研究了

列出全部书签的id、title和url的代码如下,这里考虑到一些特殊字符的原因,所以title需要用utf-8输出,而Windows的命令行不支持utf-8,所以会看到乱码,不过后期会考虑保存成excel或是xml文件以方便比对,所以这里可以先忽略这个编码问题了 ……

#!/usr/bin/env python
# encoding = gbk
# Python[AT]Live.it
 
import os
import sys
import codecs
import sqlite3
 
#moz_places = ‘places.sqlite’
moz_profile = os.getenv(appdata) + \Mozilla\Firefox\Profiles
profiles_dir = os.listdir(moz_profile)
 
if 1 == len(profiles_dir):
    
moz_places = moz_profile + \’ + profiles_dir[0] + \places.sqlite
 
else:
    print "There are more than one directories in :"
    print "t%sn" %moz_profile
    c = 1
    for i in profiles_dir:
        print "[%d] %s
\%s" %( c , moz_profile , i )
        c = c+1
    print "n"
 
    try:
        idx = raw_input("Choooooooooose : ")
    except KeyboardInterrupt:
        print "terminated by user !"
        sys.exit(0)
    try:
        idx = int( idx.strip() )
    except ValueError:
        print "Error …"
        sys.exit(1)
 
    moz_places = moz_profile +
\ + profiles_dir[idx-1] + \places.sqlite
    print "n"
    #sys.exit(0)
 
if os.path.exists(moz_places):
    pass
 
else:
    print "Can not locate the profilesnt%snt I am dying …" %moz_places
    sys.exit(1)
 
db = sqlite3.connect( moz_places )
cur = db.cursor()
 
# urls
try:
    cur.execute("select id,url from moz_places")
 
except sqlite3.OperationalError:
    print "Database maybe locked , Please shutdown the Firefox browser first."
    sys.exit(1)
 
urls = cur.fetchall()
 
url_dict = {}
for url in urls:
    if None not in url:
        url_dict[ url[0] ] = str( url[1] )
 
# titles
cur.execute("select fk,title from moz_bookmarks")
titles = cur.fetchall()
 
for item in titles:
    if None not in item:
        print "id = %s , title = %s , url = %s " %(item[0] , item[1].encode("utf-8") , url_dict[item[0]])
 
db.close()
# E_O_F

执行截图

out

本地WEBShell检查工具WSS(WebShellScanner)

2009年8月28日 Python

用 python 写的一个本地检查webshell的东西,也很简单,就是关键字匹配的问题,大概4月份就搞出来了,测试了几次之后就没再动过,今天突然看到别人写的检查工具才想起来自己也有一个,不过代码比较难看,而且因为要打开大量文件,I/O占用会比较多,即使不使用re.findall而使用re.compile也是没有太大改观, 不过这似乎是很多类似工具都是如此

我写这个东西的想法:

1、webshell还是本地查比较好

2、我需要一个框架,框架不负责直接的关键字检测,关键字单独存储,更新时只更新关键字

3、框架叫做 wss.py,存储关键字的文件叫keywords.xml,用户也可以自定义

4、关键字支持正则表达式

5、检查何种文件(通过后缀判断)也在关键字文件中标注

6、基于第2和第5条,程序可实现对任意后缀文件的检查,前提是写出关键字和对应的文件后缀

7、程序可以自动提交新的关键字,以自己的BLOG作为平台作为关键字文件的更新源

8、忘了

在 ubuntu 804 + python 2.5 + gnosis 和 windows + python 2.5 + gnosis 上测试通过

程序本身有自动更新关键字功能、也有自动上传关键字文件功能,不过我的BLOG上相关页面一直没有做出来,因此上传和更新功能暂时不可用,所以先不要使用-u选项,相关更新功能和页面我会尽快搞定

因为自己英语也不好,所以信息都用的中文,应该一看就明白,默认关键字存储在 keywords.xml 里,也可以自己根据要求制定,keywords.xml的编写方式在xml里有注释

主程序叫做 wss.py :http://www.room702.cn/tools/wss/wss.py.gz

keywords.xml在这里:http://www.room702.cn/tools/wss/keywords.xml.gz

没有python的话,下载已打包成exe的程序(含keywords.xml):http://www.room702.cn/tools/wss/wss.tar.gz

另附gnosis模块下载地址:http://gnosis.cx/download/

wss01

wss02

Python异常:too many file descriptors in select()

2009年8月27日 Python

Twisted.Network.Programming.Essentials 第二章中的portscan.py 完成了一个端口扫描的功能

代码portscan.py

#!/usr/bin/env python
# Example 2-5
# portscan.py
 
from twisted.internet import reactor, defer
from connectiontest import testConnect
 
def handleAllResults(results, ports):
#    print results[0]
    
for port, resultInfo in zip(ports, results):
 
        
success, result = resultInfo
        
if success:
            
print "Connected to port %i" % port
    
reactor.stop( )
 
import sys
 
host = sys.argv[1]
ports = range(1, 201)
testers = [testConnect(host, port) for port in ports]
defer.DeferredList(testers, consumeErrors=True).addCallback( handleAllResults , ports )
 
reactor.run( )

代码connectiontest.py

#!/usr/bin/env python
# Example 2-4
# connectiontest.py
 
from twisted.internet import reactor, defer, protocol
 
class CallbackAndDisconnectProtocol(protocol.Protocol):
 
    
def connectionMade(self):
 
        
self.factory.deferred.callback("Connected!")
        
self.transport.loseConnection( )
 
class ConnectionTestFactory(protocol.ClientFactory):
 
    
protocol = CallbackAndDisconnectProtocol
 
    
def __init__(self):
 
        
self.deferred = defer.Deferred( )
 
    
def clientConnectionFailed(self, connector, reason):
 
        
self.deferred.errback(reason)
 
def testConnect(host, port):
 
    
testFactory = ConnectionTestFactory( )
    
reactor.connectTCP(host, port, testFactory)
    
return testFactory.deferred
 
def handleSuccess(result, port):
 
    
print "Connected to port %i" % port
    
reactor.stop( )
 
def handleFailure(failure, port):
 
    
print "Error connecting to port %i: %s" % ( portfailure.getErrorMessage( ) )
    
reactor.stop( )
 
 
if __name__ == "__main__":
 
    
import sys
    
if not len(sys.argv) == 3:
        
print "Usage: connectiontest.py host port"
        
sys.exit(1)
 
    
host = sys.argv[1]
    
port = int(sys.argv[2])
    
connecting = testConnect(host, port)
    
connecting.addCallback(handleSuccess, port)
    
connecting.addErrback(handleFailure, port)
    
reactor.run( )

但是当修改 ports = range(1, 201) 为 ports = range(1, 513) 甚至修改为更大的值时,会出现一个异常:exceptions.ValueError: too many file descriptors in select()

引起异常的原因是由于 Windows 对文件描述符有一定限制,这个限制值是 512 ,而在 Linux 下这个限制为 32767
如果超过这个限制值,就会出现类似上面的异常

关于文件描述符(file descriptor)可参考:http://en.wikipedia.org/wiki/File_descriptor

新版MSN在 Windows 2003 上安装文件的下载地址

2009年8月26日 Python

今天打开MSN登录时又提示有更新,而Windows 2003 自然是仍不能安装,因此继续按照以前方法把地址抓下来,这部分可以参考以前的文章:http://www.room702.cn/index.php/archives/36

这次仍旧是打开wlsetup-web.exe 这个文件(用exescope),发现那个cab文件的地址依旧是 http://g.live.com/1rewlive3cat/zh-chs/catalog-web.cab

下载下来后,用grep和一些简单的编辑器就可以把里面的地址提取出来,再使用grep -v 来排除那些amd64和x64的下载地址,只余下x86的就剩这些了:
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/fssclient_x86-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Mail-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Messenger-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/MicrosoftSearchEnhancementPack-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/MovieMaker-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/olc-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/PhotoLibrary-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/ProviderServicesNative-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/RichUpload-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Silverlight.2.0-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/SyncNative-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/WindowsLiveSync-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/wllogin-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/wltinstall-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/WLXSuite-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/writer-ship-zh-chs.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/ChoiceGuard-ship-neutral.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Contacts-ship-neutral.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/D3DX9×86.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/SpamFilterData-ship-neutral.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/SQLServerCE31-EN.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/WIC.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Windows6.0-KB954708-x86.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/WindowsXP-KB954708-x86-ENU.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/crt-neutral.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/dotnetfx-neutral.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/SegoeFont.cab
http://wl.dlservice.microsoft.com/download/A/2/D/A2D35A7B-90D8-47C5-9F4F-507F96A542BA/zh-chs/Watson-x86.cab

根据我的测试,只装了Messenger-ship-zh-chs.cab 里的东西后,MSN就可以正常使用了
然后装了 Mail-ship-zh-chs.cab 和 writer-ship-zh-chs.cab 里的MSI后,我的live mail 和 live writer 也可以正常使用

又一只 python 爬虫

2009年8月20日 Python

比之前那个python爬虫简单
简单看了下效果,简单工作应该能应付,还没仔细看代码

sSpider.py.tgz

用于BT4(Back Track 4)的spoonwpa & spoonwep2

2009年8月19日 Python

BT3上的lzm解出来的,比charon的安装简单,直接对应目录拷贝就行了

spoonwpa.tgz

spoonwep2.tgz

『备忘』FreeBSD Error Info : Process environment requires procfs

2009年8月18日 Python

今天运行 ps  aux | grep sshd 的时候提示:

Process environment requires procfs

解决方法:mount -t procfs procfs /proc