Micro-credit script to see if the _python is deleted by the micro-trust buddy

Source: Internet
Author: User
Tags urlencode uuid python script

One day, a classmate to small hair Github source code, said it can easily find to delete their own micro-trust friends, so began to die road.

Github source code please see: 0x5e/wechat-deleted-friends

Objective

I believe you must have received such a mass message, it is said to be classified as playing a micro-letter one of the five skills ╮(╯▽╰)╭ but, in fact, just run a script, it is easy to find out to remove their friends (easily broken glass heart, escape

GitHub: Open source blame me?

Principle

New group, if not added is deleted friends (don't talk in groups, others are invisible).

Using the micro-letter Web version of the interface, there are some small problems, but now the results seem to have a small part of the reason unknown ... I've never tried to pull black. Will eventually leave the next only their own group, need to manually delete.

Method

Download the Python script and run it. Start Terminal, and cut to the file directory:

Python wdf.py

The code is as follows

#!/usr/bin/env python # coding=utf-8 import os import urllib, urllib2 import re import cookielib import time Import XML. Dom.minidom Import JSON import sys import math DEBUG = False Max_group_num = 35 # per group number Qrimagepath = OS.GETCWD () + '/qr  Code.jpg ' tip = 0 uuid = ' Base_uri = ' Redirect_uri = ' Skey = ' Wxsid = ' Wxuin = ' Pass_ticket = ' deviceId = ' e000000000000000 ' baserequest = {} contactlist = [] my = [] def getuuid (): global uuid URL = ' Https://login.weix In.qq.com/jslogin ' params = {' AppID ': ' WX782C26E4C19ACFFB ', ' fun ': ' new ', ' Lang ': ' Zh_cn ', ' _ ': Int (tim E.time ()),} request = Urllib2. Request (url = URL, data = Urllib.urlencode (params)) response = Urllib2.urlopen (request) data = Response.read () # PR int Data # window. Qrlogin.code = 200; Window.
  Qrlogin.uuid = "ozwt_bffrg=="; REGX = R ' window. Qrlogin.code = (\d+); Window.
  Qrlogin.uuid = "(\s+?)" ' PM = Re.search (regx, data) code = Pm.group (1) uuid = Pm.group (2) if codE = ': Return True return False def showqrimage (): Global Tip url = ' https://login.weixin.qq.com/qrcode/ ' + uuid params = {' t ': ' WEBWX ', ' _ ': Int (Time.time ()), request = Urllib2. Request (url = URL, data = Urllib.urlencode (params)) response = Urllib2.urlopen (request) tip = 1 F = open (Qrimagepa Th, ' WB ') F.write (Response.read ()) F.close () If Sys.platform.find (' Darwin ') >= 0:os.system (' open%s '% Qrim  Agepath) elif sys.platform.find (' Linux ') >= 0:os.system (' xdg-open%s '% qrimagepath) Else:os.system (' Call %s '% Qrimagepath print ' Please use micro-scan two-dimensional code to login ' Def waitforlogin (): Global tip, Base_uri, redirect_uri url = ' https://l ogin.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s '% (tip, uuid, int (time.time ()) request = Urllib2.
  Request (url = URL) response = Urllib2.urlopen (request) data = Response.read () # Print data # window.code=500;
  REGX = R ' window.code= (\d+); ' PM = Re.search (rEGX, data) code = Pm.group (1) If code = = ' 201 ': #已扫描 print ' successfully scanned, please click OK on the phone to login ' tip = 0 elif Code = = ' 200 ':
    #已登录 print ' Is logging in ... ' regx = R ' window.redirect_uri= ' (\s+?) "; PM = Re.search (regx, data) Redirect_uri = Pm.group (1) + ' &fun=new ' Base_uri = Redirect_uri[:redirect_uri.rfind
  ('/')] elif Code = = ' 408 ': #超时 Pass # elif Code = = ' or ' Code = = ': Return code def login (): Global Skey, Wxsi D, Wxuin, pass_ticket, baserequest request = Urllib2. Request (URL = redirect_uri) response = Urllib2.urlopen (request) data = Response.read () # Print data ' <
      error> <ret>0</ret> <message>OK</message> <skey>xxx</skey>
      <wxsid>xxx</wxsid> <wxuin>xxx</wxuin> <pass_ticket>xxx</pass_ticket> <isgrayscale>1</isgrayscale> </error> ' doc = xml.dom.minidom.parseString (data) root = doc . documeNtelement for node in root.childNodes:if node.nodename = = ' Skey ': skey = Node.childnodes[0].data elif No De.nodename = = ' Wxsid ': wxsid = node.childnodes[0].data elif node.nodename = ' Wxuin ': Wxuin = node.childn Odes[0].data elif Node.nodename = = ' Pass_ticket ': pass_ticket = node.childnodes[0].data # print ' Skey:%s, WX  Sid:%s, Wxuin:%s, Pass_ticket:%s '% (Skey, Wxsid, Wxuin, pass_ticket) if skey = = ' or Wxsid = = ' or Wxuin = = ' or Pass_ticket = = ': return False baserequest = {' UIn ': Int (Wxuin), ' Sid ': wxsid, ' Skey ': Skey, ' De Viceid ': DeviceId,} return True def webwxinit (): url = base_uri + '/webwxinit?pass_ticket=%s&skey=%s&r=% S '% (Pass_ticket, skey, int (Time.time ())) params = {' Baserequest ': baserequest} request = Urllib2. Request (url = URL, data = Json.dumps (params)) Request.add_header (' ContentType ', ' Application/json; Charset=utf-8 ') res
 Ponse = Urllib2.urlopen (Request) data = Response.read () if DEBUG = = True:f = Open (OS.GETCWD () + '/webwxinit.json ', ' WB ') f.write (data) F.C Lose () # Print Data Global contactlist, I dic = json.loads (data) contactlist = dic[' contactlist '] my = dic[' U Ser '] errmsg = dic[' baseresponse ' [' errmsg '] if Len (errmsg) > 0:print errmsg Ret = dic[' baseresponse '] [' Re T '] if Ret!= 0:return False return True def webwxgetcontact (): url = base_uri + '/webwxgetcontact?pas s_ticket=%s&skey=%s&r=%s '% (Pass_ticket, skey, int (Time.time ())) request = Urllib2. Request (url = URL) request.add_header (' ContentType ', ' Application/json; Charset=utf-8 ') response = Urllib2.urlopen (req uest) data = Response.read () if DEBUG = = True:f = Open (OS.GETCWD () + '/webwxgetcontact.json ', ' WB ') F.write (
  Data) F.close () # print Data dic = json.loads (data) memberlist = dic[' memberlist '] # reverse traversal, otherwise delete the problem. Specialusers = [' Newsapp ', ' fmessage ', ' filehelper ',' Weibo ', ' qqmail ', ' fmessage ', ' tmessage ', ' qmessage ', ' qqsync ', ' floatbottle ', ' Lbsapp ', ' Shakeapp ', ' medianote ', ' Qqfriend ', ' Readerapp ', ' Blogapp ', ' Facebookapp ', ' Masssendapp ', ' Meishiapp ', ' Feedsapp ', ' VoIP ', ' blogappweixin ', ' Weixin ', ' brandsessionholder ', ' weixinreminder ', ' wxid_novlwrv3lqwv11 ', ' gh_22b87fa7cb3c ', ' officialaccounts ', ' Notification_messages ', ' wxid_novlwrv3lqwv11 ', ' gh_22b87fa7cb3c ', ' wxitil ', ' userexperience_alarm ', ' Notification_ Messages '] for I in Xrange (Len (memberlist)-1,-1,-1): member = Memberlist[i] If member[' Verifyflag '] & 8 != 0: # Public number/service number Memberlist.remove (member) elif member[' UserName '] in Specialusers: # Special Account Memberlist.remov E (Member) elif member[' UserName '].find (' @@ ')!=-1: # Group chat memberlist.remove (member) elif member[' UserName '] =  = My[' UserName ']: # own Memberlist.remove (member) return memberlist def createchatroom (UserNames): Memberlist = [] for UserName in UserNames:MemberList.append({' UserName ': UserName}) url = Base_uri + '/webwxcreatechatroom?pass_ticket=%s&r=%s '% (pass_ticket, int (time.time ()) params = {' Baserequest ': baserequest, ' MemberCount ': Len (memberlist), ' memberlist ': memberlist, ' T OPIc ': ', request = Urllib2. Request (url = URL, data = Json.dumps (params)) Request.add_header (' ContentType ', ' Application/json; Charset=utf-8 ') res Ponse = Urllib2.urlopen (request) data = Response.read () # print Data dic = json.loads (data) Chatroomname = dic[' Chatroomname '] memberlist = dic[' memberlist '] deletedlist = [] for member in Memberlist:if member[' Memberstatus '] = = 4: #被对方删除了 deletedlist.append (member[' UserName ']) errmsg = dic[' baseresponse ' [' errmsg '] if Len (errmsg) & Gt 0:print errmsg return (Chatroomname, deletedlist) def deletemember (Chatroomname, UserNames): url = Base_uri + ' /webwxupdatechatroom?fun=delmember&pass_ticket=%s '% (pass_ticket) params = {' Baserequest ': BasErequest, ' chatroomname ': chatroomname, ' delmemberlist ': ', '. Join (UserNames), request = Urllib2. Request (url = URL, data = Json.dumps (params)) Request.add_header (' ContentType ', ' Application/json; Charset=utf-8 ') res Ponse = Urllib2.urlopen (request) data = Response.read () # print Data dic = json.loads (data) errmsg = dic[' Basere  Sponse '] [' errmsg '] if Len (errmsg) > 0:print errmsg Ret = dic[' baseresponse ' [' ret '] if Ret!= 0:return False return True def addmember (Chatroomname, UserNames): url = base_uri + '/webwxupdatechatroom?fun=addmember& amp;pass_ticket=%s '% (pass_ticket) params = {' Baserequest ': baserequest, ' chatroomname ': chatroomname, ' Ad Dmemberlist ': ', '. Join (UserNames),} request = Urllib2. Request (url = URL, data = Json.dumps (params)) Request.add_header (' ContentType ', ' Application/json; Charset=utf-8 ') res Ponse = Urllib2.urlopen (request) data = Response.read () # print Data dic = json.loads (data) Memberlist = dic[' memberlist '] deletedlist = [] for member in Memberlist:if member[' memberstatus '] = = 4: #被对 Side deleted Deletedlist.append (member[' UserName ']) errmsg = dic[' baseresponse ' [' errmsg '] if Len (errmsg) > 0:p Rint errmsg return deletedlist def main (): opener = Urllib2.build_opener (urllib2. Httpcookieprocessor (Cookielib. Cookiejar ()) Urllib2.install_opener (opener) if getuuid () = = False:print ' Get UUID failed ' return Showqrimage ( ) Time.sleep (1) while Waitforlogin ()!= ": Pass Os.remove (Qrimagepath) if login () = = False:print '  Login failed ' return if webwxinit () = = False:print ' initialization failed ' return memberlist = Webwxgetcontact () MemberCount = Len (memberlist) print ' Address book total%s bit buddy '% MemberCount chatroomname = ' result = [] for i in xrange (0, Int (math.ceil (Membercount/float (Max_group_num))): UserNames = [] nicknames = [] Deletedlist = ' for J-in xrange (0, Max_group_num): If I * Max_group_num + J >= Membercount:break member = memberlist[i * Max_group_num + j] Usernames.appe nd (member[' UserName ']) nicknames.append (member[' nickname '].encode (' Utf-8 ')) print ' group%s '% (i + 1 print ', '. Join (nicknames) print ' Enter key ... ' Raw_input () # New Group/Add member if Chatroomname = = ': (

    Chatroomname, deletedlist) = Createchatroom (UserNames) else:deletedlist = AddMember (Chatroomname, UserNames) Deletedcount = Len (deletedlist) if deletedcount > 0:result + = deletedlist print ' Find%s deleted friends '% delete DCount # raw_input () # Delete member Deletemember (Chatroomname, UserNames) # todo Delete group resultnames = [] for M Ember in Memberlist:if member[' UserName '] in result:nickname = member[' nickname '] if member[' Remarkname ' ]!= ': Nickname + = ' (%s) '% member[' remarkname '] resultnames.append (Nickname.encode (' Utf-8 ')) print '-- --------The list of friends that were deleted----------' print ' \ n '. Join (resultnames) print '-----------------------------------' # Windows coding problem Repair # Http://blog.csdn.ne 
    t/heyuxuanzee/article/details/8442718 class Unicodestreamfilter:def __init__ (self, target): Self.target = target self.encoding = ' utf-8 ' self.errors = ' replace ' self.encode_to = self.target.encoding def write (self, s) : if type (s) = = Str:s = S.decode (' utf-8 ') s = S.encode (self.encode_to, self.errors). Decode (self.encode_t  O) self.target.write (s) if sys.stdout.encoding = = ' cp936 ': sys.stdout = Unicodestreamfilter (sys.stdout) if __name__ = = ' __main__ ': print ' The results of this procedure may cause some psychological discomfort, please use carefully ... ' print ' enter key to continue ... ' raw_input () main () print ' Back



 Chei End ' Raw_input ()

Thank you for reading, I hope to help you, thank you for your support for this site!

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.