Zope&Plone
Up one levelATGoogleMaps魔改造版が完成したっぽい
多分Product作成のお約束ごとに沿ってないコードだと思うけど(;´Д`)
- Category(s)
- Zope&Plone
この辺とこの辺でうだうだやってたものがようやく形になりました。ベースverが0.5.2なので、こいつは「ATGoogleMaps 0.5.2 GPX-SP beta1」と勝手に命名しますw
やっぱりPlone Productをいじるというのは死にますわ。Class構成とかAPIがてんで分からんw んなもんでソースはパクりのパクりのそのまたパクりの連続で、動かしてみてさてどーなるというソフト屋としてはかなり非効率な行程を組んでましたwww
んで、今回入れ込んでみた機能はこんな感じ。
- GPXトラックログを読み込んでGoogleMapsでログを表示するコンテンツの追加(class=GGPXPolyline)
- ↑のログファイルを読み込んだ時に時速等も解析して時速と高度グラフを同時生成+表示(表示ON/OFFあり)。
- ↑のコンテンツ管理画面で、Mapセンターの緯度経度をinput boxに表示させる機能も追加。ログのライン上にマーカーを追加したいときが楽になるはず(GMarkerにあったのをそのまま移植した)。
- GMapを表示したときに配下のGMarker、GGPXPolylineをすべて統合した形で表示するように変更。
- ↑で取得出来るkmlファイルも同じように統合。
- GMap、GGPXPlolylineで表示するGoogleMapsのセンターは全アイテムの緯度経度から中央点とズーム値を算出して初期画面では全部が見えるようにしてみた。
とこんな感じかなと。余談ですがGoogle Earthっておもろいですねぇ。こいつのログ再生機能が結構お気に入りになりましたw
っと、話を戻して。機能的には↑のように、ヲレが欲しいものは全部ぶちこんだので結構満足してるんですが、最大の難点ただ一つ・・・。それは、鯖とクライアントに対する負荷が高いこと_| ̄|○
テストで読み込んだGPXファイルがだいたい3000pointあって鯖に読み込ませるのに約20秒。そのあとクライアントがその3000pointをJavaScriptでゴリゴリ処理しするもんだからさぁ大変。
GMap配下に複数のログを存在させてたら確実に落ちますwww 3200point×3ファイルで1萬pointぐらいになるとかなりキテました・・・。
鯖の負荷はうp時だけなのでまぁいいとして、問題はクライアント側ほほうですな・・・。うーん。やっぱりトラックログの間引きとかやらないとダメかな。って言ったってそんなのどうやってやんのさorz
- The URL to Trackback this entry is:
- http://www.maruz.net/blog/122/tbping
DNSBLを使ってCOREBlog2スパム対策強化
スパム撃墜数増加を切に望む
- Category(s)
- Zope&Plone
本BlogにNGキーワードによるコメントSPAM、トラックバックSPAM対策を行って早一年。
コメントスパムのほうはいいとしても、問題はトラックバックスパム。NGキーワードを設定してもまた新たなワードでぽつぽつと入ってきてるのですよ。おまけに「これはNGだ!」って登録したキーワードではその後になると来ない。つまり、NGキーワード登録数がどんどん増えていくだけで効果はあまりないと言うわけで 。・゚・(つД`)・゚・。
そこで、思いついたのが DNSBL 。SPAMメール対策では既に qmail+rblsmtpd を使ってやっているんですけど、同じような感じで blog にも同等な機能を実装してみようと。
んで、いろいろ調べていくと、「クライアントIPを逆にした文字列+DNSBLのDNS名」でDNS問い合わせを行って、返答が返ってきたらそいつはBlackListに登録されている。ということが判明。
早速判定するソースを作って、Ploneへの実装は・・・取りあえず External Method として登録して、NGキーワードスパム対策を施してある tbping と validateComment にうだうだ判定文を追加してみました。(COREBlog2スパム対策(まとめ) のソースを既に入れ込んであると仮定してそれからの追加分を・・・)
◆ $[ZOPEINSTANCE]/Extensions/checkDNSBL.py (External Methodとして登録)
########################################################################
#
# isDNSBLResisterdIP( IP Address )
# True : Black IP
# False : White IP
#
#######################################################################
def isDNSBLRegisteredIP( ipaddr ) :
import socket
import re
debug = 0
# DNSBL List
dnslist = ['niku.2ch.net','all.rbl.jp','bsb.spamlookup.net','sbl-xbl.spamhaus.org','bl.spamcop.net']
# White List (Regex)
wlist = ['192\.168\.*','127\.0\.0\.1']
# check IP Addr String
ipaddr=str(ipaddr)
ipaddr=ipaddr.strip()
p = re.compile('^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$')
if p.match(ipaddr) == None:
if debug : print "Illigal IP Addr"
return False
# Check White List
for w in wlist :
p = re.compile( w )
if p.match( ipaddr ) :
return False
# Inquires DNSBLs
ips = ipaddr.split('.')
rtc = False
for dns in dnslist :
addr = ips[3] + '.' + ips[2] + '.' + ips[1] + '.' + ips[0] + '.' + dns
try :
tmp = socket.gethostbyname( addr )
if debug : print "ip=%s rtn = %s" % (tmp,addr)
rtc = True
break
except socket.gaierror :
continue
else :
return True
return rtc
◆ $[ZMI]/portal_skins/custom/validateComment (太文字のところが変えたとこ)
from Products.CMFPlone import transaction_note
REQUEST=context.REQUEST
client_ip=REQUEST.getClientAddr()
moderated = None
reqs = ['title','body']
#See setting and append required field list
if context.getComment_require_author():
reqs.append('author')
if context.getComment_require_email():
reqs.append('email')
if context.getComment_require_url():
reqs.append('url')
errors = []
for key in reqs:
if REQUEST.has_key(key) and not REQUEST[key]:
state.setError(key, 'Please enter a value', new_status='failure')
errors.append(key)
# check BlackList IP
if context.isDNSBLRegisteredIP( client_ip ) :
state.setError(client_ip, 'Your IP Address was resistered in BLACKLIST.', new_status='failure')
moderated = 'BlackList IP'
if moderated == None :
for key in ['title', 'body', 'author', 'email', 'url']:
if REQUEST.has_key(key):
m = context.validateBuzzWords(REQUEST[key], True)
if not m:
state.setError(key, 'Please remove NG words.', new_status='failure')
moderated = 'NG words'
#Try to send mail for Bad comment
if moderated != None:
context.addCommentMail(
author=REQUEST['author'],email=REQUEST['email'],
url=REQUEST['url'],title=REQUEST['title'],
body=REQUEST['body'], moderated=moderated,
remoteip=client_ip)
if state.getErrors():
if moderated == 'BlackList IP' :
state.set(portal_status_message='The comment addition is refused. Your IP is resistered in the blacklist.')
else :
state.set(portal_status_message='Please correct the errors shown.')
return state
◆ $[ZMI]/portal_skins/custom/tbping (太文字のところが変えたとこ)
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import log
cbtool = getToolByName(context, 'coreblog2_tool')
REQUEST = context.REQUEST
form = REQUEST.form
RESPONSE = context.REQUEST.RESPONSE
entry = context
excerpt = ''
if form.has_key('excerpt'):
excerpt = form['excerpt']
title = cbtool.convert_charcode(form['title'])
blog_name = cbtool.convert_charcode(form['blog_name'])
excerpt = cbtool.convert_charcode(excerpt)
moderated = True
client_ip = REQUEST.getClientAddr()
#Try to add trackback
try:
# !!!STAART modify by shimizukawa!!!
moderated = True
# check BlackList IP
if context.isDNSBLRegisteredIP( client_ip ) :
moderated = False
for text in [title, blog_name, excerpt]:
m = context.validateBuzzWords(text, True)
if not m:
#state.setError(key, 'Please remove NG words.', new_status='failure')
moderated = False
#Try to send mail for Bad comment
if not moderated:
context.addTrackbackMail(
title=title, url='',
blog_name=blog_name,
excerpt=excerpt,
moderated=moderated,
remoteip=client_ip,
message='NEED MODERATE',)
raise 'NEED MODERATE'
# !!!END modify by shimizukawa!!!
#Send notify mail if need
if context.getSend_trackback_notification():
try:
to_addr = context.getNotify_to()
from_addr = context.getNotify_to()
msgbody = context.translate('trackback_notify_body')
elements = {}
for k in ('blog_name','title','excerpt','url','excerpt'):
if form.has_key(k):
elements[k] = REQUEST.form[k]
else:
elements[k] = ''
elements['post_ip'] = client_ip
elements['entry_url'] = context.absolute_url()
msgbody = msgbody % (elements)
msgsubject = context.translate('trackback_notify_title')
mgsheader = """To: %s
From: %s
Mime-Version: 1.0
Content-Type: text/plain; Charset=utf-8
""" % (to_addr,from_addr)
cbtool.send_mail(mgsheader+msgbody, to_addr, from_addr, msgsubject)
except Exception,e:
log( 'COREBlog2/tbping: '
'Some exception occured, %s' % e )
entry.addTrackback2Entry(title=title,url=form['url'],\
blog_name=blog_name,excerpt=excerpt)
return context.tbping_result(client=context,REQUEST=REQUEST,\
error_code=0,message='Thanks :-)')
except:
if moderated:
return context.tbping_result(client=context,REQUEST=REQUEST,\
error_code=1,message='Error occured!')
else:
return context.tbping_result(client=context,REQUEST=REQUEST,\
error_code=1,message='SPAMMER乙')
一番最後の tbping_result() はちょっとしたオチャメですwwww
これで一応設置は完了。はてさて、どれだけ撃墜数が増えるか(wktk。あと、DNSBLチェックメソッドも Plone Product として作り込みたいですねえ。Plone 上から DNSのリスト とか、ホワイトリスト とか変えたいですし。
参照させていただいたサイト
- COREBlog2スパム対策(まとめ) ※これから大元のNGキーワードによるスパム対策を施してます
- ィワタマ|SiDE-b :: RBL(DNSBL)でコメント・スパムをブロックする
- ぜろちゃんねる(0ch BBS Script)掲示板のスパム対策 : Under Construction, Baby
- Zope Tips ※External Methodの登録の仕方を参照しますた
- The URL to Trackback this entry is:
- http://www.maruz.net/blog/148/tbping
ブルートフォースアタックに対抗
IPホイホイ本格稼働ww
- Category(s)
- 鯖立て
- Zope&Plone
いやー、アタック来てるわ来てるわw 昔は ssh だけだった(と思った)のですが、最近は ftp にまでも・・・(;´Д`)
※↓ sshのログ
2008-02-16 19:55:43.305903500 Failed password for root from 220.227.149.240 port 54310 ssh2
2008-02-16 19:55:43.852357500 Could not reverse map address 220.227.149.240.
2008-02-16 19:55:44.942319500 Received disconnect from 220.227.149.240: 11: Bye Bye
2008-02-16 19:55:44.944846500 tcpserver: end 23600 status 65280
2008-02-16 19:55:44.944859500 tcpserver: status: 0/3
2008-02-16 19:55:45.425903500 tcpserver: status: 1/3
2008-02-16 19:55:45.426067500 tcpserver: pid 23602 from 220.227.149.240
2008-02-16 19:55:45.428029500 tcpserver: ok 23602 ns1.maruz.net:192.168.1.2:22 :220.227.149.240::54913
2008-02-16 19:55:48.466449500 Failed password for postgres from 220.227.149.240 port 54913 ssh2
2008-02-16 19:55:48.473409500 Could not reverse map address 220.227.149.240.
2008-02-16 19:55:49.025943500 Received disconnect from 220.227.149.240: 11: Bye Bye
2008-02-16 19:55:49.028646500 tcpserver: end 23602 status 65280
2008-02-16 19:55:49.028754500 tcpserver: status: 0/3
2008-02-16 19:55:49.513898500 tcpserver: status: 1/3
2008-02-16 19:55:49.514345500 tcpserver: pid 23604 from 220.227.149.240
2008-02-16 19:55:49.516848500 tcpserver: ok 23604 ns1.maruz.net:192.168.1.2:22 :220.227.149.240::55460
2008-02-16 19:55:52.567030500 input_userauth_request: illegal user accept
2008-02-16 19:55:52.567189500 Failed password for illegal user accept from 220.227.149.240 port 55460 ssh2
2008-02-16 19:55:52.573715500 Could not reverse map address 220.227.149.240.
2008-02-16 19:55:53.060667500 Received disconnect from 220.227.149.240: 11: Bye Bye
2008-02-16 19:55:53.063184500 tcpserver: end 23604 status 65280
2008-02-16 19:55:53.063196500 tcpserver: status: 0/3
2008-02-16 19:55:53.549249500 tcpserver: status: 1/3
2008-02-16 19:55:53.549467500 tcpserver: pid 23606 from 220.227.149.240
2008-02-16 19:55:53.551231500 tcpserver: ok 23606 ns1.maruz.net:192.168.1.2:22 :220.227.149.240::56028
2008-02-16 19:55:56.583752500 input_userauth_request: illegal user leo
2008-02-16 19:55:56.583945500 Failed password for illegal user leo from 220.227.149.240 port 56028 ssh2
2008-02-16 19:55:56.590482500 Could not reverse map address 220.227.149.240.
2008-02-16 19:55:57.069369500 Received disconnect from 220.227.149.240: 11: Bye Bye
2008-02-16 19:55:57.071888500 tcpserver: end 23606 status 65280
2008-02-16 19:55:57.071998500 tcpserver: status: 0/3
2008-02-16 19:56:00.550304500 tcpserver: status: 1/3
※ ↓ftp のログ
Feb 3 08:45:04 ns1 proftpd[1892]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - Maximum login attempts (3) exceeded
Feb 3 08:45:16 ns1 proftpd[1900]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - USER Administrator: no such user found from 62.99.164.138.sh.interxion.inode.at [62.99.164.138] to 192.168.1.2:21
Feb 3 08:45:17 ns1 last message repeated 2 times
Feb 3 08:45:17 ns1 proftpd[1900]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - Maximum login attempts (3) exceeded
Feb 3 08:45:28 ns1 proftpd[1901]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - USER Administrator: no such user found from 62.99.164.138.sh.interxion.inode.at [62.99.164.138] to 192.168.1.2:21
Feb 3 08:45:30 ns1 last message repeated 2 times
Feb 3 08:45:30 ns1 proftpd[1901]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - Maximum login attempts (3) exceeded
Feb 3 08:45:41 ns1 proftpd[1902]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - USER Administrator: no such user found from 62.99.164.138.sh.interxion.inode.at [62.99.164.138] to 192.168.1.2:21
Feb 3 08:45:43 ns1 last message repeated 2 times
Feb 3 08:45:43 ns1 proftpd[1902]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - Maximum login attempts (3) exceeded
Feb 3 08:45:55 ns1 proftpd[1903]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - USER Administrator: no such user found from 62.99.164.138.sh.interxion.inode.at [62.99.164.138] to 192.168.1.2:21
Feb 3 08:45:56 ns1 last message repeated 2 times
Feb 3 08:45:56 ns1 proftpd[1903]: ns1.maruz.net (62.99.164.138.sh.interxion.inode.at[62.99.164.138]) - Maximum login attempts (3) exceeded
ということで、ftp と ssh に対して本格対処しました。今度は前々から構想のあった「IPホイホイ」付きでw
IPホイホイでアタックを仕掛けてきたヴァカIPを晒していますが、そのIPに対して田代h(ry とか うぃ(ry とかやっちゃだめだぞ?いいか?絶対だぞ?やるなよ?!wwwww
- The URL to Trackback this entry is:
- http://www.maruz.net/blog/179/tbping
ECS4.0完全移行直前
再三に渡って移行するよメール来てたのにねw
- Category(s)
- Zope&Plone
あっぶねww忘れてたwww
そのまま行けば我が物欲倉庫は4/1からの AWS3.0 → ECS4.0(AWS4.0?) 完全移行により、全く使えない状態になるところです。
とは言っても、↑で使っているProduct、ATAmazonは完全無欠な開発停止状態。svnリポジトリを見てもだめでした。このProductで使っているamazonラッパーモジュール(?)である、pyamazon.py もこれでもかってぐらいに開発停止状態。つまり、自力で ECS4.0 対応しないとダメな訳で(;´Д`)
AWS3.0 で Amazon からデータを取ってこれるのは今日までなのでもう必死ですw 取れないとどうマイグレーションしたらええのか分からんし。
以下、移行に伴い参照してるサイト。
---- 4/1 0:24 追記 ----
あれ。まだAWS3.0が使えます(;´Д`) 調べてみたらおそらくPST(太平洋標準時)での2008/03/31 23:59:59がリミットと思われ。なのであと16時間ぐらいマージンがあったりして。
---- 4/1 3:25 追記 ----
でけた。”超暫定対応”ですが、移行完了。本鯖にて稼働中。
暫定とはとりあえず、ASINによるアイテム情報取得に対応しただけ。キーワードサーチとかやったらアウトだけど、アイテム追加はそれで可能。あと、ECS4.0から新たに取れるデータとかは取ってきてるけど表示には反映してないと。
- ATAmazon 3.0(svn branches/for-plone2-5) + ECS 4.0 暫定対応版↓
- http://trac.maruz.net/browser/ATAmazon/trunk?rev=102
- 「Zipでくれ」の場合はこっち↓
- ↑のtrac 差分(r97-102) ※取りあえずこれで全部取れますよ
- The URL to Trackback this entry is:
- http://www.maruz.net/blog/194/tbping
ECS 4.0 に対応した ATAmazon
Webブラウザ de Google Earth
久しぶりにATGoogleMapsいじるかぬ
- Category(s)
- Zope&Plone
「Google Earth」をWebブラウザで表示可能、APIとプラグインを公開
こ、これは・・・。試してみたくなっちゃうぢゃないかw エスパー翻訳発動だ~(←API仕様書が英語だから)。
- The URL to Trackback this entry is:
- http://www.maruz.net/blog/214/tbping
Re:ATGoogleMaps魔改造版が完成したっぽい
相変わらずマニアックなのねん。。
全然分からんのねんw
Re:ATGoogleMaps魔改造版が完成したっぽい
たしかにマニアックって言やぁマニアックw
まぁ ttp://www.maruz.net/testmap に行ってみればどんなもんか分かるんでないかと。