准备前期
一:安卓手机,这里推荐星联指纹手机,支持一键新机。(本代码基于指纹手机编写)
二:TK老号,权重高的。(如何制作也可以私信up主)
三:网络,自行准备。
一,Python代码编写登录。
步骤一:打开Tik Tok—>打开登录页面,输入账密之后,就可以登录了
登录之后可获取用户名。
#Python代码,该代码用到了指纹手机的库,有不懂的地V球:TiktokLM 或者 Tik382
"""有不懂的地V球:TiktokLM 或者 Tik382"""
import cv2
import ctypes
import sys
import os
import time
from xml.dom import minidom
import xml.etree.ElementTree as ET
# 载入动态链接库
import numpy as np
# myt rpc lib
class MytRpc(object):
def __init__(self) -> None:
# self._lib_PATH 替换成自己的链接库路径
self._lib_PATH = os.path.dirname(os.path.abspath(__file__)) + "/lib/libmytrpc.so"
self._handle = 0
self.ptr = None
if os.path.exists(self._lib_PATH) == False:
self._lib_PATH = os.path.dirname(os.path.abspath(__file__)) + "/libmytrpc.so"
def __del__(self):
if self._handle > 0:
self._rpc.closeDevice(self._handle)
# 初始化
def init(self, ip, port, timeout):
ret = False
# if os.path.exists(self._lib_PATH) == True:
if sys.platform == "linux":
self._rpc = ctypes.CDLL(self._lib_PATH)
else:
# self._rpc = ctypes.WinDLL(self._lib_PATH)
self._rpc = ctypes.WinDLL('D:/small_et/x64/libmytrpc.dll')
b_time = int(time.time())
while True:
self._handle = self._rpc.openDevice(bytes(ip, "utf-8"), port, 10)
if self._handle > 0:
ret = True
print("rpc " + ip + " ok!")
break
else:
now = int(time.time())
if now - b_time > timeout:
print("rpc " + ip + " timeout " + str(timeout))
break
else:
time.sleep(10)
else:
print("File not Found: " + self._lib_PATH)
return ret
# 释放指针内存
def free_rpc(self):
try:
if self.ptr:
print("释放指针内存")
self._rpc.freeRpcPtr(self.ptr)
except Exception as e:
print(e)
# 执行命令
def exec_cmd(self, cmd):
ret = False
if self._handle > 0:
# cmd = " pm install /data/local/TikTok_26.5.3_apkcombo.com.apk"
# cmd = "ls"
self._rpc.execCmd.restype = ctypes.c_char_p
ptr = self._rpc.execCmd(self._handle, ctypes.c_int(1), ctypes.c_char_p(cmd.encode('utf-8')))
if ptr is not None:
ret = ptr.decode('utf-8')
print("exec " + cmd + " :" + ret)
else:
ret = True
return ret
# 导出节点信息
# bDumpAll 导出所有节点 0 1
def dumpNodeXml(self, bDumpAll):
ret = False
try:
if self._handle > 0:
self._rpc.dumpNodeXml.argtypes = [ctypes.c_long, ctypes.c_int]
self._rpc.dumpNodeXml.restype = ctypes.c_void_p
ptr = self._rpc.dumpNodeXml(self._handle, bDumpAll)
p2 = ctypes.cast(ptr, ctypes.c_char_p)
ret = p2.value.decode("utf-8")
# 释放指针内存
self._rpc.freeRpcPtr.argtypes = [ctypes.c_void_p]
return ret
except Exception as e:
print(e)
return ret
# finally:
# # 释放指针内存
# self._rpc.freeRpcPtr(ptr)
# 截图导出为bytes 数组
# type 0 png 1 jpg
# quality 图片质量 0-100
# 返回字节数组
def takeCaptrueCompress(self, type, quality):
ret = False
if self._handle > 0:
dataLen = ctypes.c_int(0)
ptr = self._rpc.takeCaptrueCompress(self._handle, type, quality, ctypes.byref(dataLen))
if ptr:
try:
# 将ptr转换为bytes对象
buf = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_ubyte * dataLen.value)).contents
# 使用OpenCV将bytes对象转换为图像
img_array = bytes(buf)
ret = img_array
# img_np = np.frombuffer(img_array, dtype=np.uint8)
# img = cv2.imdecode(img_np, cv2.IMREAD_COLOR)
# # 显示图像
# cv2.imshow("Image", img)
# cv2.waitKey(0)
finally:
# 释放指针内存
self._rpc.freeRpcPtr(ptr)
return ret
# 文字输入
def sendText(self, text):
ret = False
if self._handle > 0:
ret = self._rpc.takeCaptrueCompress(self._handle, ctypes.c_char_p(text.encode('utf-8')))
return ret
# 开启指定的应用
def openApp(self, pkg):
ret = False
if self._handle > 0:
ret = self._rpc.openApp(self._handle, ctypes.c_char_p(pkg.encode('utf-8')))
return ret
# 停止指定的应用
def stopApp(self, pkg):
ret = False
if self._handle > 0:
ret = self._rpc.stopApp(self._handle, ctypes.c_char_p(pkg.encode('utf-8')))
return ret
# 获取当前屏幕的方向
# 4个方向(0,1,2,3)
def getDisplayRotate(self):
ret = False
if self._handle > 0:
ret = self._rpc.getDisplayRotate(self._handle)
return ret
# 按下操作
def touchDown(self, finger_id, x, y):
ret = False
if self._handle > 0:
ret = self._rpc.touchDown(self._handle, finger_id, x, y)
return ret
# 弹起操作
def touchUp(self, finger_id, x, y):
ret = False
if self._handle > 0:
ret = self._rpc.touchUp(self._handle, finger_id, x, y)
return ret
# 滑动操作
def touchMove(self, finger_id, x, y):
ret = False
if self._handle > 0:
ret = self._rpc.touchMove(self._handle, finger_id, x, y)
return ret
# 单击操作
def touchClick(self, finger_id, x, y):
ret = False
if self._handle > 0:
ret = self._rpc.touchClick(self._handle, finger_id, x, y)
return ret
# 按键操作
def keyPress(self, code):
ret = False
if self._handle > 0:
ret = self._rpc.keyPress(self._handle, code)
return ret
# 获取用户名
def get_user_name(comm):
try:
rpc = MytRpc()
# c_ip = "192.168.10.127"
rpc_port = 9083
if rpc.init(comm, rpc_port, 120):
time.sleep(1)
xml = rpc.dumpNodeXml(0)
rpc.free_rpc()
if xml:
strs = xml.split("\" resource-id=\"com.zhiliaoapp.musically:id/kcq\"")
if len(strs) > 1:
names = strs[0].split("@")
if len(names) > 1:
name = names[len(names) - 1]
return name
return None
except Exception as e:
return None
# doc = minidom.parseString(s)
# et = ET.fromstring(s)
# for chile in et[0]:
# print(chile.attrib)
# print("=======")
文件需要放到指定的文件夹,不然无法读取
import os
import shutil
import imghdr
import filetype
#account_email_file = "C:\\Users\\Administrator\\Pictures\\order_202303030257531613599623.txt"
"""有不懂的地V球:TiktokLM 或者 Tik382"""
"""文件操作类"""
"""读取文件内容"""
def read_file_content(path):
#print("path = " + str(path))
file_content = list()
with open(path, "r") as f:
file_content = f.readlines()
return file_content
"""追加写入文本"""
# type "w" 清空写入 "a" 追加写入
def write_file_content(path, content, type):
parent_path = os.path.abspath(os.path.join(path, ".."))
# 如果上级文件夹不存在,则创建
if not os.path.exists(parent_path):
os.makedirs(parent_path)
# 如果文件不存在,则创建
if not os.path.isfile(path):
f = open(path, 'w')
f.close()
with open(path, mode=type) as file:
if type == "w":
file.write(content)
else:
file.write(content + "\n")
"""单纯遍历文件夹下的文件"""
def read_file(root_path):
file_paths = list()
for file_name in os.listdir(root_path):
file_paths.append(root_path + "\\" + file_name)
return file_paths
"""遍历文件夹以及子文件夹下的全部文件"""
def read_files(root_path):
file_paths = list()
for root, dirs, files in os.walk(root_path):
if len(files) > 0:
for file in files:
file_paths.append(root + "\\" + file)
return file_paths
"""创建文件夹目录"""
def mkdir(parent_path):
if not os.path.exists(parent_path):
print("文件夹不存在, 创建文件夹")
os.makedirs(parent_path)
elif os.path.isfile(parent_path):
print("存在同名文件,创建文件夹")
os.makedirs(parent_path)
"""复制源文件到指定路径下并且改名字"""
def copy_file(source_file_path, target_file_path):
if not os.path.isfile(source_file_path):
print("源文件不存在,无法复制")
return None
parent_path = os.path.abspath(os.path.join(target_file_path, ".."))
#print("判断文件上级文件夹是否存在,不存在则创建")
mkdir(parent_path)
fpath,fname = os.path.split(source_file_path)
print("文件路径:", fpath)
print("文件名称:", fname)
shutil.copy(source_file_path, target_file_path)
return 1
"""打开指定文件夹"""
def open_file(file_path):
if not os.path.exists(file_path):
print("文件或者文件夹不存在")
return
os.startfile(file_path)
"""判断是否是图片格式"""
def is_image(source_file):
imgType_list = {'rgb', 'gif', 'pbm', 'pgm', 'ppm',
'tiff', 'rast', 'xbm', 'jpeg', 'bmp',
'png', 'webp', 'jpg'}
if imghdr.what(source_file) in imgType_list:
return True
return False
"""判断是否是视频格式"""
def is_vedio(source_file):
vedioType_list = {'ogm', 'wmv', 'mpg', 'webm', 'ogv',
'mov', 'asx', 'mpeg', 'mp4', 'm4v',
'avi', 'webp'}
kind = filetype.guess(source_file)
if kind.extension in vedioType_list:
return True
return False
"""删除文件夹 / 文件"""
def delete_files(file_dir):
print("删除文件夹")
if not os.path.exists(file_dir):
print("文件不存在")
return
if os.path.isdir(file_dir):
print("文件夹删除")
shutil.rmtree(file_dir)
if os.path.isfile(file_dir):
print("文件删除")
os.remove(file_dir)
#读取改图片#
def read_photo_copy(root_path):
file_paths = list()
refile_name = 0
for file_name in os.listdir(root_path):
file_paths.append(root_path + "\\" + file_name)
if is_image(root_path + "\\" + file_name):
refile_name = refile_name + 1
kind = filetype.guess(root_path + "\\" + file_name)
copy_file(root_path + "\\" + file_name, "C:\\Users\\Administrator\\Pictures\\缓存\\图片库\\" + str(refile_name) + "." + kind.extension)
return file_paths
def read_video_copy(root_path):
file_paths = list()
refile_name = 0
for file_name in os.listdir(root_path):
file_paths.append(root_path + "\\" + file_name)
if is_vedio(root_path + "\\" + file_name):
refile_name = refile_name + 1
kind = filetype.guess(root_path + "\\" + file_name)
copy_file(root_path + "\\" + file_name, "C:\\Users\\Administrator\\Pictures\\缓存\\视频库\\" + str(refile_name) + "." + kind.extension)
return file_paths
"""判断文件内容是否更新"""
def is_new_file(file_path, last_data):
print("检查文件是否更新")
if not os.path.isfile(file_path):
print("文件不存在")
return -1
with open(file_path, "r") as file:
file_lines = file.readlines()
if file_lines:
for i in range(0, len(file_lines)):
line = file_lines[i].strip(" ").strip("\n")
#print(line)
if str(line) == str(last_data):
return i
return -1
"""创建文件"""
def mkfile(file_path):
parent_path = os.path.abspath(os.path.join(file_path, ".."))
#print("判断文件上级文件夹是否存在,不存在则创建")
mkdir(parent_path)
if not os.path.isfile(file_path):
print("存在同名文件,创建文件夹")
file = open(file_path, "w")
file.close()
def read_last_email():
mkfile("C:\\Users\\Administrator\\Pictures\\缓存\\最后邮箱.txt")
#write_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\邮箱.txt", "dfdhdfh", "w")
last_email = read_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\最后邮箱.txt")
if last_email:
print("最后的邮箱是 = " + str(last_email[0]))
return last_email[0].strip(" ").strip("\n")
return -1
def read_last_ouklook_email():
mkfile("C:\\Users\\Administrator\\Pictures\\缓存\\最后outlook邮箱.txt")
#write_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\邮箱.txt", "dfdhdfh", "w")
last_email = read_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\最后outlook邮箱.txt")
if last_email:
print("最后的outlook邮箱是 = " + str(last_email[0]))
return last_email[0].strip(" ").strip("\n")
return -1
def read_last_Google():
mkfile("C:\\Users\\Administrator\\Pictures\\缓存\\最后Google.txt")
#write_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\邮箱.txt", "dfdhdfh", "w")
last_email = read_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\最后Google.txt")
if last_email:
print("最后的Google邮箱是 = " + str(last_email[0]))
return last_email[0].strip(" ").strip("\n")
return -1
# 读取图片#
def read_photo_remenber(root_path):
try:
mkfile("C:\\Users\\Administrator\\Pictures\\缓存\\头像缓存.txt")
last_photo = read_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\头像缓存.txt")
print("last_photo = " + str(last_photo))
if len(last_photo) == 0:
print("----")
write_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\头像缓存.txt", str("-1"), "w")
last_photo = read_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\头像缓存.txt")
print("最后头像 = " + str(last_photo[0]))
file_paths = list()
refile_name = 0
for file_name in os.listdir(root_path):
file_paths.append(root_path + "\\" + file_name)
if is_image(root_path + "\\" + file_name):
refile_name = refile_name + 1
print("图片数量 = " + str(len(file_paths)))
if len(file_paths) == 0:
print("没有图片")
return None
if int(last_photo[0]) > len(file_paths):
print("上次记录值大于当前值,从0开始")
last_photo[0] = 0
last_photo_list = int(last_photo[0])
while is_image(file_paths[last_photo_list]) == False:
print("不为图片格式")
last_photo_list = last_photo_list + 1
if last_photo_list > len(file_paths):
print("上次记录值大于当前值,从0开始")
last_photo_list = 0
last_photo_list = last_photo_list + 1
write_file_content("C:\\Users\\Administrator\\Pictures\\缓存\\头像缓存.txt", str(last_photo_list) , "w")
print(file_paths[last_photo_list])
return file_paths[last_photo_list]
except Exception as e:
print(e)
return None
以上代码为获取用户名代码,