Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: who said python can't be obsfucated!?
cokofreedom@gmail.com a écrit :
> def s(c):return[]if c==[]else s([_ for _ in c[1:]if _<c[0]])+[c[0]]
> +s([_ for _ in c[1:]if _>=c[0]])
>
> Anyone else got some wonders...?

Nothing as bad, but:

sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p
in m.split('@')])


Report this thread to moderator Post Follow-up to this message
Old Post
Bruno Desthuilliers
04-03-08 11:29 AM


Re: who said python can't be obsfucated!?
Bruno Desthuilliers wrote:

> sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p
> in m.split('@')])


Pff... you call that a quicksort?


From http://www.p-nand-q.com/python/obfuscated_python.html


import sys

funcs = range(10)

def A(_,o):
_[3]=_[5]()

def B(_,o):
o[_[2]]=_[9]()

def C(_,o):
_[3]=_[7]()

def D(_,o):
o[_[1]]=_[14]()

def E(_,o):
_[1]=_[4]()

def F(_,o):
_[2]=_[6]()

def G(_,o,O):
if _[O[0]]():return O[-1](_,o) or 1

def H(o, start, stop):
_=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x,
 y:y|1,0,0][1](start,funcs[4](range(funcs
[3](),
 len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0]

for i in range(4,19):
_[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\
"x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\
"range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\
"](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\
" x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\
" (_[2],funcs[4](range(funcs[3](),_[10]())
))$fun"\
" cs[4](range(funcs[3](),_[10]()))$range(_
[10]()"\
"*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\
"_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\
"[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\
",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\
" F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\
"5,D])".split('$')[:][i-4]:eval("eval('eval(s)')")

while _[11]():
while _[17](): pass
while _[18](): pass
o[_[2]] = _[0]
return _[2]

def quicksort(list,start,stop):
exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\
':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\
' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\
'[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\
'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\
'0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\
'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\
'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\
'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\
'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\
'ambda x,y:  y|1,0,0][1](split,funcs[4](funcs[3]())))
'\
'\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\
',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\
'[3]())]), stop)\n')

# test code: 2000 elements to sort
list = []
import whrandom,time
for i in range(2000):
list.append(whrandom.randint(1,100))
start = time.clock()
quicksort(list,0,len(list)-1)
print "Sorting took %.2f" % (time.clock() - start)

# just a test loop to see if everything *is* sorted
element = -1
for i in list:
if i >= element:
element = i
else:
print "FUNK DAT: %20s" % str(i)
break


Report this thread to moderator Post Follow-up to this message
Old Post
Marco Mariani
04-03-08 01:44 PM


Re: who said python can't be obsfucated!?
Bruno Desthuilliers wrote:

> sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p
> in m.split('@')])


Pff... you call that a quicksort?


From http://www.p-nand-q.com/python/obfuscated_python.html


import sys

funcs = range(10)

def A(_,o):
_[3]=_[5]()

def B(_,o):
o[_[2]]=_[9]()

def C(_,o):
_[3]=_[7]()

def D(_,o):
o[_[1]]=_[14]()

def E(_,o):
_[1]=_[4]()

def F(_,o):
_[2]=_[6]()

def G(_,o,O):
if _[O[0]]():return O[-1](_,o) or 1

def H(o, start, stop):
_=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x,
 y:y|1,0,0][1](start,funcs[4](range(funcs
[3](),
 len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0]

for i in range(4,19):
_[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\
"x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\
"range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\
"](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\
" x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\
" (_[2],funcs[4](range(funcs[3](),_[10]())
))$fun"\
" cs[4](range(funcs[3](),_[10]()))$range(_
[10]()"\
"*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\
"_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\
"[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\
",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\
" F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\
"5,D])".split('$')[:][i-4]:eval("eval('eval(s)')")

while _[11]():
while _[17](): pass
while _[18](): pass
o[_[2]] = _[0]
return _[2]

def quicksort(list,start,stop):
exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\
':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\
' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\
'[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\
'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\
'0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\
'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\
'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\
'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\
'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\
'ambda x,y:  y|1,0,0][1](split,funcs[4](funcs[3]())))
'\
'\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\
',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\
'[3]())]), stop)\n')

# test code: 2000 elements to sort
list = []
import whrandom,time
for i in range(2000):
list.append(whrandom.randint(1,100))
start = time.clock()
quicksort(list,0,len(list)-1)
print "Sorting took %.2f" % (time.clock() - start)

# just a test loop to see if everything *is* sorted
element = -1
for i in list:
if i >= element:
element = i
else:
print "FUNK DAT: %20s" % str(i)
break


Report this thread to moderator Post Follow-up to this message
Old Post
Marco Mariani
04-03-08 01:44 PM


Re: who said python can't be obsfucated!?
Marco Mariani a écrit :
> Bruno Desthuilliers wrote:
> 
>
>
> Pff... you call that a quicksort?
>

Nope, only somewhat obfuscated Python. And it seems it's at least
obfuscated enough for you to believe it could be a quicksort
implementation !-)


Report this thread to moderator Post Follow-up to this message
Old Post
Bruno Desthuilliers
04-03-08 01:44 PM


Re: who said python can't be obsfucated!?
Bruno Desthuilliers wrote:
 
> Nope, only somewhat obfuscated Python. And it seems it's at least
> obfuscated enough for you to believe it could be a quicksort
> implementation !-)

You're right, but I'm past the quine age and don't bother parsing
obfuscated code (*) anymore.




(*) outside my day job, that is.

Report this thread to moderator Post Follow-up to this message
Old Post
Marco Mariani
04-03-08 01:44 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Python archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.