Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'subject:Python': 0.06; 'error:': 0.07; 'string': 0.09; '__init__': 0.09; 'false.': 0.09; 'restart': 0.09; 'unhandled': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; 'windows': 0.15; 'addr,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'idle,': 0.16; 'idle.': 0.16; 'lambda': 0.16; 'mean,': 0.16; 'pause': 0.16; 'skip:[ 50': 0.16; 'through,': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'fine': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'this:': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:- 40': 0.29; 'chris': 0.29; 'am,': 0.29; 'tim': 0.29; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; 'chase': 0.31; "d'aprano": 0.31; 'equality': 0.31; 'steven': 0.31; 'file': 0.32; 'running': 0.33; '(most': 0.33; "i'd": 0.34; 'skip:s 30': 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'being': 0.38; 'server': 0.38; 'handle': 0.38; 'pm,': 0.38; 'recent': 0.39; 'changed': 0.39; 'skip:u 10': 0.60; 'length': 0.61; "you're": 0.61; 'back': 0.62; 'transparent': 0.68; 'results': 0.69; 'skip:r 30': 0.69; '=====': 0.84; 'getresponse': 0.84; 'so...': 0.84; 'universe': 0.84; '2013,': 0.91; 'request:': 0.91; 'to:none': 0.92; '***': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=66h7IF/G7Rx5srOxWHnc4eI78VQUHQMznUT42lddLXk=; b=hjlekuNragTyfPh0q0gaT4h6KiFEfZ1+5GCytcUbZPxuCsLkz8gX1Piybz/QW36FvN C2fkdXg1/Z6IUuDJGZp0MZw08OJtgONz7BFc84r9QJKBbxpuXi56BITlne0OVYGeO5tl 3hs7RpC5pRLnYi7ZQ22rzxim4KK3A6tHEGVtdj51vBgNRZUZZGyzgKxixv1HvwJS/M11 ZCEGJrSuD98Mmaio4bDDavBpbDw1SKM3BbdNd99ATl/qoRQKZBYGzPqYJu1uY3myD3p7 c5LSQgiPXLgzYC0t1htTlsBjn0IzIqF9q3pIPp5xAZdUGvZNkgS5UPlifwCmnY2UUfYu oC8A== MIME-Version: 1.0 X-Received: by 10.53.12.229 with SMTP id et5mr5393407vdd.32.1401724552963; Mon, 02 Jun 2014 08:55:52 -0700 (PDT) In-Reply-To: <538c9a78$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <538c69d5$0$29978$c3e8da3$5496439d@news.astraweb.com> <20140602072718.071feab3@bigbox.christie.dr> <538c9a78$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 3 Jun 2014 01:55:52 +1000 Subject: Re: Obfuscated Python hack From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 85 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401724555 news.xs4all.nl 2964 [2001:888:2000:d::a6]:37430 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72419 On Tue, Jun 3, 2014 at 1:38 AM, Steven D'Aprano wrote: > On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: > >> On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase >> wrote: >>> Stripping off the exec() call makes it pretty transparent that you're >>> attempting (successfully on some platforms) to set the value of "4" to >>> "5". But a cute hack. >> >> And not on Windows inside IDLE, where attempting to use 4 results in a >> ===== RESTART ===== crash. > > Sounds like a bug in IDLE. > > What happens if you try it in Windows without IDLE, just using the > standard interactive interpreter? It works fine without IDLE. Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win 32 >>> exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s [1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi')) >>> 10 - 6 == 10 - 5 True In IDLE: >>> exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi')) >>> 10 - 6 == 10 - 5 >>> ================================ RESTART ================================ There's a bit of a pause before the RESTART line comes through, and repeating the equality check after that comes back with a straight-forward False. Running IDLE from a terminal gives this: C:\Documents and Settings\M>\python27\python -m idlelib.idle ---------------------------------------- Unhandled server exception! Thread: SockThread Client Address: ('127.0.0.1', 4414) Request: Traceback (most recent call last): File "C:\python27\lib\SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "C:\python27\lib\SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "C:\python27\lib\SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\python27\lib\idlelib\rpc.py", line 503, in __init__ SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr) File "C:\python27\lib\SocketServer.py", line 649, in __init__ self.handle() File "C:\python27\lib\idlelib\run.py", line 268, in handle rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) File "C:\python27\lib\idlelib\rpc.py", line 280, in getresponse response = self._getresponse(myseq, wait) File "C:\python27\lib\idlelib\rpc.py", line 300, in _getresponse response = self.pollresponse(myseq, wait) File "C:\python27\lib\idlelib\rpc.py", line 424, in pollresponse message = self.pollmessage(wait) File "C:\python27\lib\idlelib\rpc.py", line 376, in pollmessage packet = self.pollpacket(wait) File "C:\python27\lib\idlelib\rpc.py", line 357, in pollpacket self._stage0() File "C:\python27\lib\idlelib\rpc.py", line 364, in _stage0 self.bufneed = struct.unpack("