也谈微信 跳一跳 外挂

这个东西其实网上有现成的外挂了,各种方式。图形识别,人肉丈量。都是不错的选择,可以参考这个链接https://github.com/wangshub/wechat_jump_game。基于安卓adb实现的外挂。我没用过这个,但是识别效率肯定比在手机上会高一些。其实我还是想自己实现一个外挂,没别的意思,就是纯粹好玩。

于是就想基于触动精灵来实现一个外挂,为了简单。于是想到了下面的识别办法:
1. 逐行进行扫描来识别要跳转的目标坐标。为了提高效率可以适当增加扫描步进。定义一个矩形区域,要跳转的目标相对来说位置都比较固定。
2. 获取小人的位置,通过触动精灵的查找颜色功能进行定位坐标,虽然有一定误差,但是只要能获取到坐标,用来计算还是基本没问题的。
3. 计算跳跃距离,通过直接三角形的勾股定理进行计算。按压时间需要根据距离进行修正,我在小米 5s上测试用的1.2 基本还算可以。

已知问题:
1. 通过触动精灵进行颜色匹配搜索坐标的做法效率较低,需要比较长的时间。
2. 运行一段时间之后,找色函数和获取小人坐标的函数会发生错误,导致无法获取到真正的坐标。我加了几个判断,出现问题的时候直接重新启动脚本就可以了。
3. 由于是基于颜色进行匹配的,因而相对来时识别的坐标的准确度比上面的python版本要低很多。

改进方式:
1. 针对搜索坐标的函数进行匹配,折半查找,如果小人在左侧,直接搜索右侧。如果小人在右侧直接搜索左侧。
2. 匹配到错误之后直接重启脚本,使用触动精灵的循环运行功能
3. 其他未知的功能修改?我也不知道有啥。哈哈

脚本文件:

require "TSLib"
require("math")
-----------------------------------------------
-- Auto jump scripy
-- Code by obaby
-- http://www.h4ck.org.cn
-- Findu App http://findu.co
-----------------------------------------------

-- define scan zone with (x1,y1) (x2,y2)
scanZone_x1 = 50;
scanZone_y1 = 600;
scanZone_x2 = 1000;
scanZone_y2 = 922;


-- get the target object position
function getDestXY()
	-- body
	mSleep(1000);
	isfound = 0;
	dest_x = 0;
	dest_y = 0;
	for y = scanZone_y1,scanZone_x2,30 do
		for x =scanZone_x1,scanZone_x2,30 do
			colorb = getColor(x, y)
			colorc = getColor(x-30, y)
			colord = getColor(x+50, y)
			delta = math.abs(colorb -colorc)
			delta2 = math.abs(colord - colorb)
			--toast(delta.." :x:"..x.." :y:"..y,1)
			--mSleep(100)
			if delta >1000 then
				--toast(delta.." :x:"..x.." :y:"..y,1)
				nLog("COLO TO::ColorB:"..colorb.." ColorC:"..colorc);
				isfound = 1;
				dest_x = x;
				dest_y = y;
				--mSleep(5000);
				break;
			end

			--dialog("ColorB:"..colorb.."ColorC:"..colorc, 3);
			--mSleep(3000)
			--x= x+10

		end
		--y= y+10
		if isfound ==1 then

			break;
		end

	end
	return dest_x, dest_y
end

-- get the 
function getDistance(dest_x, dest_y)
	-- body
	--mSleep(1000);
	x, y = findColorInRegionFuzzy( 0x39375f , 80, 0, 926, 1070, 1370); 
	if x == -1 then
		x, y = findColorInRegionFuzzy( 0x39375f , 70, 0, 926, 1070, 1370); 
	end
	if x == -1 then
		x, y = findColorInRegionFuzzy( 0x39375f , 80, 0, 926, 1070, 1370); 
	end
	if x ==-1 then
		return 0;
	end

	org_x = 796;
	org_y = 1100;
	org_x1 = 336
	org_y1 = 1110
	if dest_x >500 then
		org_x = org_x1;
		org_y = org_y1;
	end
	nLog("JUMP FR::src_x:"..x.." src_y:"..y);
	distance = math.sqrt(math.pow(dest_x - x,2) + math.pow(dest_y-y,2));
	
	if math.abs(dest_y - y) < (1116-940) then
		return (1116-940)*1.4;
	end
	
	
	return distance;
end


while (true) do
	-- body
	if (isColor( 581, 1626, 0xffffff, 85) and  isColor( 558, 1714, 0x262628, 85)) then
		break;
	end

	dest_x , dest_y = getDestXY();
	dist = getDistance(dest_x,dest_y);
	toast("dest_x:"..dest_x.." dest_y:"..dest_y.." distance:"..math.floor(dist),3);
	--toast(dist,1)
	--can not get dest position or can not get the source position
	nLog("JUMP TO::dst_x:"..dest_x.." dst_y:"..dest_y.." distance:"..math.floor(dist));
	if dest_x ==scanZone_x1 or dist == 0 or dest_y == scanZone_y1 or dest_x ==scanZone_x2 then
		toast("Get posison error",1);
		nLog("ERRO ER:: Get position error")
		break;
	end 
	
	touchDown(dest_x, dest_y);
	mSleep(dist*1.3);
	touchUp(dest_x, dest_y);
	
end

Git hub:https://github.com/obaby/wechat_jump_lua

☆版权☆

* 网站名称:obaby@mars
* 网址:https://h4ck.org.cn/
* 个性:https://oba.by/
* 本文标题: 《也谈微信 跳一跳 外挂》
* 本文链接:https://h4ck.org.cn/2018/01/6061
* 短链接:https://oba.by/?p=6061
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


猜你喜欢:

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注