用户设备IP三者绑定自动上号

发送任务:

# -*- coding: utf-8 -*-
# @Author  : Codeooo
# @Time    : 2021/10/27


import json
import uuid
import random

from db.RedisDB import RedisDB


alphabet = ''.join(str(uuid.uuid4()).split('-'))


def deviceRandom():
    # android iD:
    androidid = "a786f7eb46d80d8"

    # 厂商 "Xiaomi" "HUAWEI" "OPPO" "VIVO" "GOOGLE" ""
    _manifuature = ["Xiaomi","HUAWEI","OPPO","VIVO","GOOGLE"]

    manifuature  = random.choice(_manifuature)

    # 序列号
    serialno = alphabet[:16].upper()

    # imei = "866001033006546"
    imei = f"{random.randint(166001033006546,996001033006546)}"

    wifiaddress = f"{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}"

    wifiname = f"{alphabet[24:28].upper()}-{alphabet[28:32].upper()}"

    # 手机品牌
    brand = manifuature

    # 手机型号
    model = brand

    # IMSI = "460066624657531"
    IMSI = f"{random.randint(460000000000030,990000000000030)}"

    product = ""

    # 蓝牙名称
    btnam = alphabet[16:24].upper()

    # 蓝牙MAC
    btaddr =  f"{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}:{random.choice(alphabet) + random.choice(alphabet)}"
    print("btaddr",btaddr)

    phoneno = f"1{random.randint(3000000000,9000000000)}"

    displayId = f"AL1512-mido-build-{random.randint(20000101,20211101)}005127"

    # 基带版本
    baseVersion = f"{random.randint(100,999)}_GEN_PACK-1.{random.randint(1000000,9999999)}.{random.randint(1000000,9999999)}.1"

    # 运营商
    operatornam =  random.choice(["中国移动","中国电信","中国联通"])

    numeric = "46000"

    country = "cn"

    deviceFirst = f"setphone -a {androidid} -m {manifuature} -s {serialno} -i {imei} -w {wifiaddress} -n {wifiname} -b {brand} -o {model} -e {IMSI} -p {product} --btnam {btnam} --btaddr {btaddr}"

    deviceLast = f" --phoneno {phoneno} --displayId {displayId} --baseVersion {baseVersion} --operatornam {operatornam} --numeric {numeric} --country {country}"

    device = deviceFirst + deviceLast
    print(device)

    return  device




if __name__ == '__main__':


    task = {
        "user": "18647664673",
        "pwd": "3bbrhfc6",
        "status": "1",
        "ip":"218",
        "setPhone":deviceRandom()
    }

    print(f"本次登陆用户{task.get('user')}")
    RedisDB().set_info("a786f7eb46d80d8", json.dumps(task))

云机监听登陆:

/*
@Author  : Codeooo
@Time    : 2021/10/25
ks.9.5.10.20016.apk
*/


auto.waitFor();


function updateStatus(deviceId,status) {
    for (var i=0; i<5; i++) {
        var url = "http://你的服务/userSave/" + deviceId + "/" + status ;
        var res = http.get(url);
        if (res.statusCode === 200) {
            print("===回写updateStatus成功===");
            return
        }
    }
}


function caseLogin(data,deviceId) {

    if (data.user) {

        //获取账号信息
        toast(data.user);
        user = data.user;
        pwd = data.pwd;

        //ip 设备 初始化
        setIp(data.ip);
        sleep(1000);
        setPhone(data.setPhone,deviceId);
        sleep(1000);
        //授权
        authentication();
        sleep(2000);

        loginToken = login(user, pwd);
        if (loginToken){
            updateStatus(deviceId,0);
            // qrBase();
        }else{
            updateStatus(deviceId,2);
            //close("快手");
        }
    }

}


function caseQr(data,deviceId) {
    if (data.img) {
        qrBase();
        images.save(images.fromBase64(data.img), "/sdcard/code.jpg", "jpg", 50);
        //app.viewFile("/sdcard/code.jpg");
        media.scanFile("/sdcard/code.jpg");
        print("===图片下载成功===");
        qrToken = qrLast();
        if (qrToken){
            updateStatus(deviceId,0);
            //qrBase()
        }else{
            updateStatus(deviceId,2);
            //close("快手");
        }
    }

}


function ksFans(deviceId) {

    while (1) {
        var url = "http://你的服务/getTask/" + deviceId;
        var res = http.get(url);
        if (res.statusCode !== 200) {
            print("===请求main失败===");
        } else {
            var data = res.body.json();
            if (data.status) {
                caseLogin(data,deviceId);
                caseQr(data,deviceId);
            }
        }
        //sleep(3000);
    }
}

function login(user, pwd) {
    app.launchApp("快手");
    print("===启动快手成功===");

    sleep(2000);

    //更改协议同意
    id("positive").findOne().click();
    print("===协议同意===");
    sleep(1000);


    id("left_text").findOne().click();//left-login
    print("===点击登陆按钮===");

    sleep(1000);
    id("other_login_tv").findOne().click(); //other
    print("===选择其他登陆方式===");

    sleep(1000);

    //id("protocol_checkbox").findOne(1000).click();//yes http
    //print("===协议同意===");

    id("sina_login_view").findOne().click(); //weibo
    print("===选择微博方式登陆===");
    sleep(1000);

    id("etLoginUsername").findOne().setText(user);
    print("===账号输入完毕===");
    id("etPwd").findOne().setText(pwd);
    print("===密码输入完毕===");

    sleep(1000);
    id("new_bnLogin").findOne().click();
    print("===点击登陆===");

    sleep(3000);
    id("new_bnLogin").findOne().click();
    print("===授权成功===");

    if (desc("精选").findOne(15000)) {
        if (desc("关闭").findOne(2000)){
            desc("关闭").findOne().click()
        }
        toast("===登陆成功===");
        return true;
    } else {
        toast("===登陆失败===");
        return false;
    }
}



function qrLast() {

    var str = "相册";
    var x = text(str).findOne().bounds().left;// 首次出现的x坐标
    var y = text(str).findOne().bounds().top;// 首次出现的y坐标
    click(x, y);
    print("===点击相册===");
    sleep(2000);

    click(10, 200);
    print("===第一张图===");

    if (id("login_confirm_ok").findOne(12000)) {
        id("login_confirm_ok").findOne().click();
        toast("===登陆成功===");
        return true;
    } else {
        toast("===二维码过期===");
        if (text("知道了").exists()) {
            text("知道了").findOne().click();
        }

        id("left_btn").findOne().click();
        print("===点击左上角===");
        sleep(2000);

        return false;
    }
}

function qrBase() {

    sleep(2000);

    id("left_btn").findOne().click();
    print("===点击左上角===");
    sleep(2000);

    swipe(device.width / 2, 800, device.width / 2, 500, 1000);
    print("===下滑找更多===");

    sleep(2000);

    var str = "更多";
    var xQ = text(str).findOne().bounds().left;// 首次出现的x坐标
    var yQ = text(str).findOne().bounds().top;// 首次出现的y坐标
    click(xQ+10, yQ-10);
    //row("7").findOne().click();
    print("===点击更多===");
    sleep(2000);


    // var strQr = "扫一扫";
    // var xQr = text(strQr).findOne().bounds().left;// 首次出现的x坐标
    // var yQr = text(strQr).findOne().bounds().top;// 首次出现的y坐标
    // click(xQr+10, yQr-10);

    click(250,600);
    print("===点击扫一扫===");
    sleep(1000)

}


function createRedisKey(deviceId) {

    for (var i=0; i<5; i++) {
        var url = "http://你的服务/createRedisKey/" + deviceId;
        var res = http.get(url);
        if (res.statusCode !== 200) {
            print("===createRedisKey失败===");
        } else {
            var data = res.body.json();
            return data.result
        }
    }
    return false;
}

function auth(packagename,phone,photo,write,read) {
    var sh = new Shell(true);
    sh.exec(phone);//执行代码运行中属于异步运行
    sh.exec(photo);//执行代码运行中属于异步运行
    sh.exec(write);//执行代码运行中属于异步运行
    sh.exec(read);//执行代码运行中属于异步运行
    sleep(1000);
    sh.exit;
}



function authentication() {
    //授权
    var packageName = getPackageName("快手");
    var phone = "pm grant com.smile.gifmaker android.permission.READ_PHONE_STATE";
    var photo = "pm grant com.smile.gifmaker android.permission.CAMERA";
    var write = "pm grant com.smile.gifmaker android.permission.WRITE_EXTERNAL_STORAGE";
    var read = "pm grant com.smile.gifmaker android.permission.READ_EXTERNAL_STORAGE";
    auth(packageName,phone,photo,write,read);
}


function cmd(cmdStr,cmdStr1) {
    var sh = new Shell(true);
    sh.exec(cmdStr);
    if (cmdStr1){
        sh.exec(cmdStr1);
    }
    sleep(1000);
    sh.exit;
}


function clear(mastPackagename,otherPackagename) {
    var sh = new Shell(true);
    sh.exec("pm clear"+" "+mastPackagename);//执行代码运行中属于异步运行
    sh.exec("pm clear"+" "+otherPackagename);//执行代码运行中属于异步运行
    sleep(1000);
    sh.exit;
}

function setPhone(cmdStr,deviceId) {
    if(cmdStr){
        cmd(cmdStr,"setphone -a " + deviceId);
        toast("设备大师指定刷新")
    }else{
        cmd("setphone","setphone -a " + deviceId);
        toast("设备大师随机刷新")
    }
    clear(getPackageName("快手"),getPackageName("微博"));
}

// 92a98c170a174060bac927f026e90c78
function setIp(deviceIp) {
    if (deviceIp){
        cmd("ipclient 92a98c170a174060bac927f026e90c78 1 region true cities " + deviceIp,"");
        // cmd("ipclient 92a98c170a174060bac927f026e90c78 1","");
    }else{
        cmd("ipclient 92a98c170a174060bac927f026e90c78 1","");
    }
    toast("云机代理ip: " + deviceIp )
}




//设备id
var deviceId = device.getAndroidId();
print(deviceId);

//创建秘钥
createRedisKey(deviceId);

//主流程
ksFans(deviceId);


// adb pull /storage/emulated/0/脚本/login/build/login_v1.0.0.apk  D:\KS


// setphone -a a786f7eb46d80d8 -m Xiaomi -s 1QASSCJ99J91UTPO -i 866001033006546 -w 71:00:e7:2c:32:5e -n FAST-Ym31 -b xiaomi -o Redmi Note 4x -e 460066624657531 -p {product}

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年7月15日
下一篇 2023年7月15日

相关推荐