Python: A recipe for cryptic code? Python: Uma receita para críptico código?
I have heard that Python is a great programming language which is so much superior to everything around etc. Ouvi dizer que uma grande programação Python é uma linguagem que é muito superior a tudo em torno etc
The following code in python is touted as the world’s smallest p2p client & server. O código a seguir em python é apresentado como o mais pequeno do mundo p2p cliente e servidor.
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) # Tinyp2p.py 1.0 (documentação em http://freedom-to-tinker.com/tinyp2p.html)
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, EW Felten sys importação, OS, SimpleXMLRPCServer, xmlrpclib, novamente, hmac # (C) 2004, EW Felten
ar,pw,res = (sys.argv,lambda u:hmac.new(sys.argv[1],u).hexdigest(),re.search) ar, pw, res = (sys.argv, lambda u: hmac.new (sys.argv [1], u). 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 ls (p =""): retorno filtro (lambda n: (p =="") ou res (p, n), os.listdir (os.getcwd ()))
if ar[2]!=”client”: # license: http://creativecommons.org/licenses/by-nc-sa/2.0 se ar [2]! = "cliente": # license: http://creativecommons.org/licenses/by-nc-sa/2.0
myU,prs,srv = (”http://”+ar[3]+”:”+ar[4], ar[5:],lambda x:x.serve_forever()) myU, prs, srv = ( "http://" + ar [3 ]+":"+ ar [4], ar [5:], lambda x: x.serve_forever ())
def pr(x=[]): return ([(y in prs) or prs.append(y) for y in x] or 1) and prs def pr (x =[]): retorno ([(y no PRS) ou prs.append (y) para y em x] ou 1) e prs
def c(n): return ((lambda f: (f.read(), f.close()))(file(n)))[0] def c (n): return ((lambda f: (f.read (), f.close ()))( arquivo (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 = lambda p, n, uma: (p == pw (myU)) e (((n == 0) e pr (a)) ou ((n == 1) e [ls (a)]) ou c (a))
def aug(u): return ((u==myU) and pr()) or pr(pxy(u).f(pw(u),0,pr([myU]))) def Agosto (u): retorno ((u == myU) e pr ()) ou pr (pxy (u). f (pw (u), 0, pr ([myU])))
pr() and [aug(s) for s in aug(pr()[0])] pr () e [Ago (s) para s em Agosto (pr () [0])]
(lambda sv:sv.register_function(f,”f”) or srv(sv))(xs((ar[3],int(ar[4])))) (lambda sv: sv.register_function (f, "f") ou srv (sv)) (xs ((ar [3], int (ar [4 ]))))
for url in pxy(ar[3]).f(pw(ar[3]),0,[]): para a URL no pxy (ar [3]). f (pw (ar [3]), 0 ,[]):
for fn in filter(lambda n:not n in ls(), (pxy(url).f(pw(url),1,ar[4]))[0]): no filtro de fn (lambda n: não nos n ls (), (pxy (URL). f (pw (URL), 1, ar [4])) [0]):
(lambda fi:fi.write(pxy(url).f(pw(url),2,fn)) or fi.close())(file(fn,”wc”)) (lambda fi: fi.write (pxy (URL). f (pw (URL), 2, fn)) ou fi.close ()) (arquivo (fn, "wc"))
Source: Fonte: 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. Eu comecei a minha carreira com a programação montagem língua (escrita minúscula. Com programas e jogando com cuties como masm e tasm), e depois mudou-se para C, mesmo com a bagunça java byte códigos para se divertir.
But this wonderful gem of a program (displayed above) beat the crap out of me. Mas esta maravilhosa jóia de um programa (mostrada acima) bater o crap fora de mim.
Python, going by this example, looks to me a sure-fire recipe for creating obfuscated code. Python, passando por este exemplo, parece-me um certo-fogo receita para a criação obfuscated código. I would rather read 80×86 instructions, thank you very much! Prefiro ler 80 × 86 instruções, muito obrigado!
PS. Java programmers, you can relax. Programadores Java, você pode relaxar. Python programmers (oops hackers as per naive bayesian dude) writing such code will never be able to maintain it. Programadores Python (opa hackers bayesian ingénuo como por dude) escrito tal código não será capaz de manter a mesma. 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). Assim, você vai ser posta em dúvida para substituir esses "hackers" e reescrever todo o coisa em Java (uso da palavra refactoring para obter uma melhor tracção em gestão).
Filed under Arquivado em Humor Loucuras , Java Software Java Software , Technology Tecnologia , Web , Web Services Web Services | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article E-mail este artigo
You may also like to read Você pode também gosta de ler |




April 13th, 2005 at 3:55 am 13 de abril de 2005, às 3:55 am
I’ma java programmer (and an occasioanl python/jython one). Sou um programador java (e um occasioanl python / Jython um). But this is not really fair. Mas este não é realmente justo. One can write obfuscated code in any language. Obfuscated um pode escrever código em qualquer idioma. This code is like when you write multiple statments in one line in any C style language (like in java). Este código é como quando você escrever em um múltiplo statments linha em qualquer estilo linguagem C (como em Java). Or you can nest a lot of method calls, which you normally don’t do if you wan’t maintanable code. Ou você pode ninho um lote de convites método, que você normalmente não fazer se você querer Maintanable código.
This code is meant to be compact and not readible or maintainable. Este código é utilizado para ser compacto e não readible ou manter. There are no blocks (no indentations) only one liner methods and lambda (inline defined) functions. Não existem blocos (sem entalhes) apenas uma linha métodos e lambda (inline definido) funções. Python does look good when you program it in the right, standard style. Python é bom quando você olhar programa-o na direita, estilo padrão. 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). E há uma coisa dessas, assim como com java (apesar de existirem algumas inconsistências irritantes, como algumas pessoas e os usos stdlib camelo caso, aqui e ali sublinhados, etc).
April 13th, 2005 at 5:06 am 13 de abril de 2005, às 5:06 am
Be sure to catch the readable rebuke Certifique-se de capturar os legível reprovarão
:
http://www.mechanicalcat.net/richard/log/Python/Ugly_Python
…wonder if that runs in Jython? … Admira que se corre em Jython?
April 13th, 2005 at 5:14 am 13 de abril de 2005, às 5:14 am
@Laszlo Marai @ Laszlo Marai
> But this is not really fair. > Mas este não é realmente justo.
Life isn’t fair either A vida não é justa nem
BTW: You mentioned that the code is meant to be compact and not readable or maintable. BTW: O senhor mencionou que o código se destina a ser compacto e não legível ou maintable. Then why did he code it in Python? Então porque é que ele é código em Python? Why not in assembly language? Por que não em assembléia língua? It would have been much faster and more compact. Teria sido muito mais rápido e mais compacta.
Any code written in high level language should be readable and maintable. Qualquer código escrito em linguagem alto nível deve ser legível e maintable.
I seriously doubt you can match this level of obfuscation in Java. Eu seriamente duvidar que você pode igualar este nível de obfuscation em Java. Heck I can even read the decompiled obfuscated(using standard obfuscators; not by the programmer) java code properly. Heck Posso até ler o descompilado obfuscated (utilizando o padrão obfuscators; não pelo programador) java código corretamente.
PS: Be sure to check the categories this post is under. PS: Não esqueça de verificar as categorias está sob este post.
April 13th, 2005 at 5:32 am 13 de abril de 2005, às 5:32 am
From De 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 importação java.awt .*; importação java.util .*; público classe C estende Frame D = (Data novo Data (); void T (Data d) (D = d; repaint ();) dupla P = Math.PI , A = P / 2, a, c, U =. 05; int W, H, m, R; dupla E (int a, int u) (retorno (3 * P / 2 +2 * P * a / u )% (2 * P);) void N (Graphics g, q dupla, dupla s) (g.fillPolygon (novo int [] (H (s, q), H (U, q + A), H (U , q +3 * A)), novas 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 = tamanho (). Largura, tamanho H = (). Altura); 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
C> java C C> Java C
Author & Submitter: David M. Hewitt/1999″ Autor e Apresentador: David M. Hewitt / 1999 "
April 13th, 2005 at 6:37 am 13 de abril de 2005, às 6:37 am
not the shortest p2p app, there is at least a shorter one in ruby and an even shorter one in perl. Não mais curto espaço p2p app, há pelo menos um curto em um rubi e uma maior frequência de um perl.
See Ver
http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/123945
for the first, I can’t find the latter. para o primeiro, eu não posso encontrar a última.
Btw, doing this things in python is more impressive. BTW, fazendo isso coisas em python é mais impressionante.
April 13th, 2005 at 7:08 am 13 de abril de 2005, às 7:08 am
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. Você selecionou o que é provavelmente o único e mais obsfucated pedaço de código em Python existência e estão a tentar fazer uma generalização sobre a totalidade do idioma com base nele. It’s folly. É loucura.
> Why not in assembly language? > Por que não em assembléia língua? It would have been much faster and more compact. Teria sido muito mais rápido e mais compacta.
It would have taken longer, required many more lines, and would have been limited to running on a specific platform. Teria tido mais tempo, necessários muitos mais linhas, e teria sido limitada a correr em uma plataforma específica.
> Any code written in high level language should be readable and maintable. > Qualquer código escrito em linguagem alto nível deve ser legível e maintable.
More folly. Mais loucura. Python syntax *encourages* readable and maintainable code, it doesn’t require it. Python incentiva * * sintaxe legível e manutenção código, ela não exige isso.
October 3rd, 2007 at 7:21 am 3 Oct, 2007, 7:21 am
I tend to agree with the artical. Eu costumo estar de acordo com o artigo. Have a look at examples in the Python tutorials: De uma olhada em exemplos nos tutoriais Python:
return “;”.join(["%s=%s" % (k, v) for k, v in params.items()]) retorno ";". aderir ([ "% s =% s"% (k, v) para k, v, em params.items ()])
This statement could easily be written using a loop and be much easier to understand. Esta afirmação poderia facilmente ser escritos usando um loop e ser muito mais fácil de entender. 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. Parece ser legal para programadores Python tentar escrever um programa inteiro em uma linha e da sintaxe da linguagem parece ter sido concebido dessa forma.
Java uses plain english keywords that makes it less crytic. Java utiliza planície Inglês palavras-chave que torna menos crytic.