Python: A recipe for cryptic code? Pythonの:秘密コードのための秘策ですか?
I have heard that Python is a great programming language which is so much superior to everything around etc.していると聞いたことは素晴らしいプログラミング言語であるPythonの方がずっと周りなどすべてに優れている
The following code in python is touted as the world’s smallest p2p client & server.は、次のコードはPythonでは、喧伝されて、世界最小のP2Pのクライアント&サーバーです。
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) # tinyp2p.py 1.0 (ドキュメントは、 http://freedom-to-tinker.com/tinyp2p.html )
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, EW Feltenインポートするシステムは、 OSやsimplexmlrpcserver 、 xmlrpclib 、再は、 HMAC # ( c ) 2004 、ニューfelten
ar,pw,res = (sys.argv,lambda u:hmac.new(sys.argv[1],u).hexdigest(),re.search)アーカンソー、週、解像度= ( sys.argv 、ラムダu : hmac.new ( sys.argv [ 1 ] 、大)です。 hexdigest ( ) 、 re.search )
pxy,xs = (xmlrpclib.ServerProxy,SimpleXMLRPCServer.SimpleXMLRPCServer) pxy 、くださいXS = ( xmlrpclib.serverproxy 、 simplexmlrpcserver.simplexmlrpcserver )
def ls(p=”"):return filter(lambda n:(p==”")or res(p,n),os.listdir(os.getcwd())) def負け( p =""):リターンフィルタ(ラムダn : ( p =="")または解像度(人、 n ) 、 os.listdir ( os.getcwd ( ) ) )
if ar[2]!=”client”: # license: http://creativecommons.org/licenses/by-nc-sa/2.0もしアーカンソー[ 2 ] ! = "クライアント" : #ライセンス: http://creativecommons.org/licenses/by-nc-sa/2.0
myU,prs,srv = (”http://”+ar[3]+”:”+ar[4], ar[5:],lambda x:x.serve_forever())ミュウ、 prs 、のSRV = ( " http:// "で+アーカンソー[ 3 ]+":"+アーカンソー[ 4 ] 、アーカンソー[ 5 : ] 、ラムダx : x.serve_forever ( ) )
def pr(x=[]): return ([(y in prs) or prs.append(y) for y in x] or 1) and prs def広報( x =[]):リターン( [ ( yをprs )またはprs.append ( Y )のためy Xで]または1 )とprs
def c(n): return ((lambda f: (f.read(), f.close()))(file(n)))[0] def c ( n ) :リターン( (ラムダf : ( f.read ( ) 、 f.close ()))(ファイル( n ) ) ) [ 0 ]
f=lambda p,n,a:(p==pw(myU))and(((n==0)and pr(a))or((n==1)and [ls(a)])or c(a)) f =ラムダ人、 nはA : ( p ==週(ミュウ) ) ( ( ( n == 0 )とPR ( a )項参照)または( ( n == 1 )と[負け( 1 ) ] ) 、またはc ( a )項参照)
def aug(u): return ((u==myU) and pr()) or pr(pxy(u).f(pw(u),0,pr([myU]))) def年08月( U )より:リターン( (運==ミュウ)とPR ( ) )や広報( pxy ( U )より。 f (週( U )より、 0 、広報( [ミュウ] ) ) )
pr() and [aug(s) for s in aug(pr()[0])]広報( )と[ 08月(秒)をsの08月(広報( ) [ 0 ] ) ]
(lambda sv:sv.register_function(f,”f”) or srv(sv))(xs((ar[3],int(ar[4])))) (ラムダsv文書: sv.register_function (メス、 " f "を)またはSRV ( sv文書) ) (くださいXS ( (アーカンソー[ 3 ] 、 int (アーカンソー[ 4 ]))))
for url in pxy(ar[3]).f(pw(ar[3]),0,[]):ためのURLをpxy (アーカンソー[ 3 ] ) 。 f (週(アーカンソー[ 3 ] ) 、 0 ,[]):
for fn in filter(lambda n:not n in ls(), (pxy(url).f(pw(url),1,ar[4]))[0]):をfnにはフィルタ(ラムダn :特定nと負け( ) 、 ( pxy ( url )と呼びます。 f (週( URL )を、 1 、アーカンソー[ 4 ] ) ) [ 0 ] ) :
(lambda fi:fi.write(pxy(url).f(pw(url),2,fn)) or fi.close())(file(fn,”wc”)) (ラムダ私: fi.write ( pxy ( url )と呼びます。 f (週( URL )を、 2 、 fn ) )またはfi.close ( ) ) (ファイル(視野数は、 "トイレ" ) )
Source:ソース: TinyP2P tinyp2p
I started my programming career with assembly language (writing tiny .com programs and playing with cuties like masm and tasm), then moved to C, even mess with java byte codes for fun.私のキャリアを始めたアセンブリ言語のプログラミング(書き込み超小型。 co.jpのプログラムと遊んでいるようなmasmとcuties tasm ) 、入力し、移動をC 、 Javaのバイトコードを楽しいとかかわり合いになる。
But this wonderful gem of a program (displayed above) beat the crap out of me.しかし、この素晴らしい宝石のようにプログラム(上に表示されます)を徹底的にびびったよ。
Python, going by this example, looks to me a sure-fire recipe for creating obfuscated code. pythonですが、行くられたこの例では、火のように私に確認のための秘策難読化コードを作成します。 I would rather read 80×86 instructions, thank you very much!私の方を読む80 × 86手順については、どうもありがとうございました!
PS. psのです。 Java programmers, you can relax. Javaのプログラマは、リラックスすることができます。 Python programmers (oops hackers as per naive bayesian dude) writing such code will never be able to maintain it. Pythonのプログラマー(おっと純真なベイズのハッカーと1男)そのようなコードを書くことは決してないことを維持することです。 So you will definitely be called in to replace such “hackers” and rewrite the whole thing in Java (use the word refactoring to get better traction with management). definitelyと呼ばれるので、次回以降を置き換えるにはこのような"ハッカー"と全体を書き換えることはジャワ(リファクタリングという言葉を使うより良いトラクションを得るに管理) 。
Filed under提出されて Humorユーモア , 、 Java Software Javaソフトウェア , 、 Technology技術 , 、 Webウェブ , 、 Web Services Webサービス | |
| |
RSS 2.0 RSS 2.0を | |
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |




April 13th, 2005 at 3:55 am 2005年4月13日の午前9:55
I’ma java programmer (and an occasioanl python/jython one).私のJavaプログラマ(および、 Pythonのoccasioanl / jython 1つ) 。 But this is not really fair.しかし、これ本当に公平ではない。 One can write obfuscated code in any language.難読化のコードを1つの任意の言語を書いています。 This code is like when you write multiple statments in one line in any C style language (like in java).このコードは、複数のstatmentsように作成するときに任意のcスタイルの行を1つの言語(ジャワのように) 。 Or you can nest a lot of method calls, which you normally don’t do if you wan’t maintanable code.たりすることができます。巣、多くのメソッド呼び出し、これを行う場合に、通常はありませんwan't maintanableコードです。
This code is meant to be compact and not readible or maintainable.このコードではないということでコンパクトでreadibleまたは維持します。 There are no blocks (no indentations) only one liner methods and lambda (inline defined) functions.ブロックがない(インデント)ライナーの方法を1つだけとラムダ(インライン定義されて)関数です。 Python does look good when you program it in the right, standard style. Pythonの良いように見えるし、右側のときにプログラムのこと、標準のスタイルです。 And there is such a thing, just as with java (though there are some annoying inconsistencies, like some people and the stdlib uses camel case here and underscores there, etc).とにはそのようなことは、ジャワのと同様に(ただし迷惑な矛盾には、いくつかのようないくつかの人々とラクダの場合、ここstdlibおよびアンダースコアが使用して、等) 。
April 13th, 2005 at 5:06 am 2005年4月13日5:06アム
Be sure to catch the readable rebuke非難に乗ろうとすることを確認読める
: :
http://www.mechanicalcat.net/richard/log/Python/Ugly_Python http://www.mechanicalcat.net/richard/log/python/ugly_python
…wonder if that runs in Jython? …かどうかで実行さjythonですか?
April 13th, 2005 at 5:14 am 2005年4月13日5:14アム
@Laszlo Marai @ラズロマライ
> But this is not really fair. >しかし、これ本当に公平ではない。
Life isn’t fair either人生ではない普通のいずれか
BTW: You mentioned that the code is meant to be compact and not readable or maintable.ところで:言及することを意図して、コードの読み取りまたはmaintableではなくコンパクトです。 Then why did he code it in Python?コードを入力し、なぜ彼がPythonでこれをですか? Why not in assembly language?アセンブリ言語なぜですか? It would have been much faster and more compact.それは多くがより速く、よりコンパクトです。
Any code written in high level language should be readable and maintable.高レベルの言語で書かれて任意のコードを読み取り可能とすべきであるmaintableです。
I seriously doubt you can match this level of obfuscation in Java.私を真剣に疑いを難読化することができます。このレベルの試合はジャワです。 Heck I can even read the decompiled obfuscated(using standard obfuscators; not by the programmer) java code properly.ヘック私デコンパイル難読化を読むこともできます(使用して標準obfuscators ;ではなく、プログラマ) Javaコードを適切にします。
PS: Be sure to check the categories this post is under. psの:カテゴリーを必ず確認し、この投稿されています。
April 13th, 2005 at 5:32 am 2005年4月13日は5:32アム
From 〜から http://www.gamedev.net/hosted/javaextreme/obfpoll.htm : :
import java.awt.*;import java.util.*;public class C extends Frame{Date D=new Date();void T(Date d){D=d;repaint();}double P=Math.PI,A=P/2,a,c,U=.05;int W,H,m,R;double E(int a,int u){return(3*P/2+2*P*a/u)%(2*P);}void N(Graphics g,double q,double s){g.fillPolygon(new int[]{H(s,q),H(U,q+A),H(U,q+3*A)},new int[]{J(s,q),J(U,q+A),J(U,q+3*A)},3);}public void paint(Graphics g){Color C=SystemColor.control;g.setColor(C);g.fillRect(0,0,W=size().width,H=size().height);W-=52;H-=52;R=Math.min(W/2,H/2);g.translate(W/2+25,H/2+36);g.setColor(C.darker());for(m=0;m javac C.javaインポートjava.awt .* ;インポートjava.util .* ;公共クラスCの拡張フレーム(日付d =新しい日付( ) ;無効トン(日付奥行) ( d = Dである;再描画( ) ; )ダブルp = math.pi 、 、 = π / 2 、 、 A 、 Cの、 u =. 05 ; intワット、 h再生、 M 、研究;ダブルメール( intは、 intから) (リターン( 3 * π / 2 +2 *型番*のA / u ) % ( 2 *型番) ; )無効n (グラフィックスグラム、ダブル問、ダブル秒) ( g.fillpolygon (新しいint [ ] (時(秒、問) 、時( uでは、問+ A )が、 h (運、問+3 * 1 ) ) 、新しいint [ ] (無し(秒、問) 、 Jさん( uでは、問+ A )が、 Jさん( uでは、問+3 * 1 ) ) 、 3 ) ; )公共無効塗料(グラフィックグラム) (色c = systemcolor.control ;をクリアg.setColor ( c ) ; g.fillrect ( 0,0 、ワット=サイズ( ) 。幅、 h =サイズ( ) 。高さ) ;のW - = 52 ; h - = 52 ;研究= math.min (幅/ 2 、別H / 2 ) ; g.translate (幅/ 2 +25 、別H / 2 +36 ) ;をクリアg.setColor ( c.darker ( ) ) ;を(オス= 0 ;メートルのjavac c.java
C> java C c >ジャワc
Author & Submitter: David M. Hewitt/1999″著者&投稿者:デビッド男性ヒューイット/ 1999 "
April 13th, 2005 at 6:37 am 2005年4月13日は6:37アム
not the shortest p2p app, there is at least a shorter one in ruby and an even shorter one in perl.特定の最短のP2Pアプリでは、少なくとも1つのルビーを短くすると、さらに短くPerlの1つにします。
See見る
http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/123945
for the first, I can’t find the latter.は、第一に、私は後者を見つけることができません。
Btw, doing this things in python is more impressive.ところで、これを行うことがPythonでは、他の印象的です。
April 13th, 2005 at 7:08 am 2005年4月13日は午後1:08
You picked what is probably the single most obsfucated chunk of Python code in existence and are attempting to make a generalization about the entire language based on it.何を選んだのは、おそらく最もobsfucatedの存在やチャンクのPythonのコードを概括しようとすることについては、全体の言語に基づいています。 It’s folly.ことの愚かさです。
> Why not in assembly language? >なぜ特定のアセンブリ言語ですか? It would have been much faster and more compact.それは多くがより速く、よりコンパクトです。
It would have taken longer, required many more lines, and would have been limited to running on a specific platform.長く取ることが、必要な多くの行に限られていたとは、特定のプラットフォームで実行されています。
> Any code written in high level language should be readable and maintable. >任意のコードの高レベルの言語で書かれてmaintableすべきであると読める。
More folly.他の愚行です。 Python syntax *encourages* readable and maintainable code, it doesn’t require it. Pythonの構文* *読みやすく保守コードを奨励、それを必要としません。
October 3rd, 2007 at 7:21 am 2007年10月3日は午前7時21時
I tend to agree with the artical.私に同意する傾向にサポートします。 Have a look at examples in the Python tutorials:を見てPythonのチュートリアルの例では:
return “;”.join(["%s=%s" % (k, v) for k, v in params.items()])リターン" ; "です。参加( [ " % sの= % sを" % ( k 、 v )をk 、 vでparams.items ( ) ] )
This statement could easily be written using a loop and be much easier to understand.このステートメントは簡単にループを使用するに書き込まれると理解が格段に容易にします。 It seems to be cool to Python programmers try to write the entire program in one line and the syntax of the language seems to be designed that way.涼しいと思われるPythonのプログラマーにしようと書いて、プログラム全体で1つのラインとする言語の構文のようにできるように設計してくれます。
Java uses plain english keywords that makes it less crytic.ジャワでは、分かりやすい英語のキーワードとなり、それが少ないcryticです。