Python Challenge 9-bz2

Source: Internet
Author: User

Question Nineth Address: http://www.pythonchallenge.com/pc/def/integrity.html



is still a picture, we click Will pop-up user name, password let us enter, guess after parsing will get. Continue to view the HTML code.

<!--un: ' bzh91ay&sya\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3m\x07<]\xc9\x14\xe1ba\ x06\xbe\x084 ' pw: ' bzh91ay&sy\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3m\x13<]\xc9\x14\xe1bbp\x91\ Xf08 '-

We see this string of comments, UN,PW is the abbreviation of username and password, then parse this string of comments will be able to get clearance password.

By then

Bzh91ay&sy
At the beginning, according to learning that the BZ2 module was used to encrypt the results.


Import Bz2un = ' bzh91ay&sya\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3m\x07<]\xc9\x14\xe1ba\ x06\xbe\x084 ' pw = ' bzh91ay&sy\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3m\x13<]\xc9\x14\xe1bbp\x91\ Xf08 ' Print bz2.decompress (un) print bz2.decompress (PW)

The above code we can easily get the required user name and password

Hugefile



BTW, see in the reference

<area shape= "Poly" coords= " 179,284,214,311,255,320,281,226,319,224,363,309,339,222,371,225,411,229,404,242,415,252,428,233,428,214,394,207,383,205,3 90,195,423,192,439,193,442,209,440,215,450,221,457,226,469,202,475,187,494,188,494,169,498,147,491,121,477,136,481,96,471 , 94,458,98,444,91,420,87,405,92,391,88,376,82,350,79,330,82,314,85,305,90,299,96,290,103,276,110,262,114,225,123,212,125 , 185,133,138,144,118,160,97,168,87,176,110,180,145,176,153,176,150,182,137,190,126,194,121,198,126,203,151,205,160,195,16 8,217,169,234,170,260,174,282 "href=". /return/good.html ">

This string of code, is a collection of points, describes the shape of the bee, the mouse to move up, click to enter the page to jump.



############################################################################################################### #####################


We use the BZ2 module to bzip2 for compression, or encryption. The Compress method is used to compress the data bits of a string, returning a 8-bit string. If you want to get raw data, use the decompress method.


Import Bz2message = "The Meaning of life" compressed_message = bz2.compress (message) Decompressed_message = bz2.decompress (compressed_message) print "Original:", repr (message) print "Compressed message:", repr (compressed_message) print " decompressed message: ", repr (decompressed_message) # resultoriginal: ' The Meaning of life ' compressed message: ' bzh91ay& Amp Sy\xcb\x18\xf4\x9e\x00\x00\t\x11\[email protected]\x00#\xe7\x84\x00 \x00 "\x8d\x94\xc3!\[email protected]\xd0\x00\ xfb\xf6u\xa6\xe1p\xb8z.\xe4\x8ap\xa1!\x961\xe9< ' decompressed message: ' The Meaning of life '


The BZ2 module also provides bz2compressor and Bz2decompressor classes that support incremental compression and decompression.


Using the BZ2 module for incremental compression

Import Bz2text = "The Meaning of life" data = "comp = bz2. Bz2compressor () for Word in Text.split ():    Data + = comp.compress (Word + "") Data + = Comp.flush () print repr (bz2.decompre SS (data) # result ' The meaning of life '

Compression is not performed at the same time, but is segmented in the for loop, but the results of the decompression are still the same.



There are also bz2file methods, similar to the open method, that can be used to automatically read or write to compressed files.


Using the BZ2 module for stream compression

Import Bz2file = bz2. Bz2file ("samples/sample.bz2", "R") for line in file:    print repr (line) $ Python bz2-example-3.py ' We'll perhaps  Eventually is writing only small\n "modules which is identified by name as they are\n" used to build larger ones Devices like\n ' ...



Reference:

Http://effbot.org/librarybook/bz2.htm

http://pymotw.com/2/bz2/

Http://bbs.chinaunix.net/thread-3608204-1-1.html

Python Challenge 9-bz2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.