Skip to content

Commit

Permalink
重构赌场破解到新gui里
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuandiaodiaodiao committed Dec 22, 2020
1 parent aad7ebc commit 2021579
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 29 deletions.
Empty file removed __init__.py
Empty file.
5 changes: 3 additions & 2 deletions perico/argsolver.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--height', type=int, help='屏幕高度',default=1080)
parser.add_argument('--width', type=int, help='屏幕宽度',default=1920)
parser.add_argument('--height', type=int, help='屏幕高度',default=2109)
parser.add_argument('--width', type=int, help='屏幕宽度',default=3834)
parser.add_argument('--tp', type=str, help='一键提高产量',default="f8")
parser.add_argument('--perico', type=str, help='佩里克指纹',default="f9")
parser.add_argument('--afk', type=str, help='自动挂机',default="null")
Expand All @@ -12,4 +12,5 @@
parser.add_argument('--modelpath', help='模型路径',type=str,default="./model")
parser.add_argument('--keydelay', help='按键延迟',type=float,default="0")
parser.add_argument('--allstop', help='停止服务',type=str,default="delete")
parser.add_argument('--dc', help='dc指纹',type=str,default="f10")
args = parser.parse_args()
105 changes: 105 additions & 0 deletions perico/dc/dc_cv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import cv2
import aircv as ac
import numpy as np
from logger import logger
from prepare import get_gtav_image


def getpic():
fullimg = get_gtav_image()
# print(fullimg.shape)
fullimg = cv2.resize(fullimg, (1920, 1080))
h, w = fullimg.shape[0], fullimg.shape[1]

# print(fullimg.shape)
# if (w/h - 16/9) > 0.01:
# ww = h*16//9
# fullimg = fullimg[:,(w - ww)//2 :w - (ww-w)//2, :]
# w = h*16/9
BL = 0.49 * w
BT = 0.115 * h
BR = 0.71 * w
BB = 0.64 * h
# print(int(BT),int(BB), int(BL),int(BR))
bigimg = fullimg[int(BT):int(BB), int(BL):int(BR)]
# print(bigimg.shape)
# cv2.imshow("1", bigimg)
# cv2.waitKey()

BBL = 0.251 * w
BBT = 0.257 * h
picture = []
for j in range(0, 5, 4):
for i in range(0, 4):
L = BBL + j / 4 * 0.075 * w
T = BBT + i * 0.134 * h
R = L + 0.0545 * w
B = T + 0.095 * h
picture.append(fullimg[int(T):int(B), int(L):int(R)])
# for i in range(8):
# cv2.imshow("1", picture[i])
# cv2.waitKey()
return picture, bigimg


def threshold_demo(image):
frame = image
# print(frame.shape) # shape内包含三个元素:按顺序为高、宽、通道数
height = frame.shape[0]
weight = frame.shape[1]
channels = frame.shape[2]
# print("weight : %s, height : %s, channel : %s" %(weight, height, channels))
for row in range(height): # 遍历高
for col in range(weight): # 遍历宽
color = frame[row, col]
# print(color)
if color[2] > 150 and color[1] < 80 and color[0] < 80:
color[0] = 0
frame[row, col] = [0, 0, 0]
# for c in range(channels): #便利通道
# pv = frame[row, col, c]
# print(pv)
# frame[row, col, c] = 255 - pv
gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
h, w = gray.shape[:2]
m = np.reshape(gray, [1, w * h])
mean = m.sum() / (w * h)
mean = 15

ret, binary = cv2.threshold(gray, mean, 255, cv2.THRESH_BINARY)
binary = cv2.medianBlur(binary, 3)
binary = cv2.GaussianBlur(binary, (3, 3), 1)
return binary


def solvepicture(img):
img = threshold_demo(img)
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
return img


def findresult(temp, target, thor=0.3):
# cv2.imshow('objDetect1', target)

# find the match position
pos = ac.find_template(temp, target, threshold=thor)
if pos is None:
print("no find")
# cv2.imshow('objDetect', temp)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
return False
circle_center_pos = pos['rectangle']
logger.info(f"result={circle_center_pos}")
logger.info(f"confidenc={pos['confidence']}")

return True


def solveonepicture(temp, imobj):
x, y = imobj.shape[0:2]
bigval = 1.31
imobj = cv2.resize(imobj, (int(y * bigval), int(x * bigval)))
imobj = solvepicture(imobj)
thor = 0.6
return findresult(temp, imobj, thor)
19 changes: 19 additions & 0 deletions perico/dc/dc_keypress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from keyboardsim import press_str
from dc.dc_cv import getpic,solvepicture,solveonepicture
from logger import logger
def breakonce():
targets, imsrc = getpic()
imsrc = solvepicture(imsrc)
# logger.info(f"")
num = 0
for index, imgobj in enumerate(targets):
if solveonepicture(imsrc, imgobj):
num += 1
press_str("enter")
if index != 7:
press_str("down")
if index == 3:
press_str("right")
if num >= 4:
break
press_str('tab')
26 changes: 11 additions & 15 deletions perico/keyboardloop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from concurrent.futures import ThreadPoolExecutor, wait
RESOLUTION_PERSETS={
"1080p":[1920,1080],
"2k":[2560,1440],
"4k":[3840,2160]
}
RESOLUTION=RESOLUTION_PERSETS["4k"]

from argsolver import args
from logger import logger

Expand All @@ -14,7 +9,7 @@
import os
import time
from ai_solve import ai_solve

from dc.dc_keypress import breakonce
import threading

def get_key_name(key):
Expand Down Expand Up @@ -98,9 +93,10 @@ def presskey(key):
global threadPool
t = get_key_name(key)

if t==args.dc:
threadPool.submit(breakonce)


if t == args.tp:
elif t == args.tp:
#一键提高产量
threadPool.submit(tp_hack)

Expand All @@ -109,33 +105,33 @@ def presskey(key):
# img = get_gtav_image()
# import cv2
# cv2.imwrite("temp.png", img)
if t == args.perico:
elif t == args.perico:
# 指纹破解
# logging.warning("submit perico")
logger.info('perico start')
threadPool.submit(ai_solve)
# ai_solve()
if t == args.afk:
elif t == args.afk:
#自动挂机
logger.info("afk start")
threadPool.submit(afk)
if t ==args.stop:
elif t ==args.stop:
#停止当前的动作
logger.info("stop")
restart()
if t =="eeeee":
elif t =="eeeee":
#给深度学习构建数据集
# 采样 并切割图片 写入文件夹 创建label
from train_data_collect import collect_data
# threadPool.submit(collect_data)
collect_data()
if t == "eeeeeee":
elif t == "eeeeeee":
#调到都是0号指纹后自动破解
for i in range(8):
for j in range(i):
press_str("right")
press_str("down")
if t == args.allstop:
elif t == args.allstop:
#停止进程
stop()
exit(0)
Expand Down
2 changes: 1 addition & 1 deletion perico/keyboardsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"right": RIGHT,
'enter': ENTER,
"esc": 27,

'tab':9
}


Expand Down
1 change: 1 addition & 0 deletions perico/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ opencv-python==4.4.0.46
pyinstaller==4.1
pywin32==300
argparse
aircv==1.4.6
Binary file removed screen.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion ui/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"height":"2109","width":"3834","tp":"f8","perico":"f9","afk":"","stop":"backspace","mode":"window","cast":["0.317",0.885,0.226,0.4165],"keydelay":"0","allstop":"delete"}
{"height":"1440","width":"2560","tp":"f8","perico":"f9","afk":"","stop":"backspace","mode":"borderless","cast":["0.317",0.885,0.226,0.4165],"keydelay":"0","allstop":"delete","dc":"f10"}
5 changes: 0 additions & 5 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
"cross-env": "^7.0.2",
"electron": "^11.0.3",
"electron-builder": "^22.9.1",
"vite": "^1.0.0-rc.13"
"vite": "^1.0.0-rc.13",
"iconv-lite": "^0.6.2"
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"element-plus": "^1.0.1-beta.10",
"iconv-lite": "^0.6.2",
"vue": "^3.0.4"
}
}
7 changes: 6 additions & 1 deletion ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
佩里克指纹破解 :
<el-input placeholder="f9" v-model="config.perico"></el-input>
</div>
<div class="lineinput">
赌场指纹破解 :
<el-input placeholder="f10" v-model="config.dc"></el-input>
</div>
<div class="lineinput">
挂机 :
<el-input placeholder="null" v-model="config.afk"></el-input>
Expand Down Expand Up @@ -118,7 +122,8 @@ const loadconfig = () => {
mode: 'fullscreen',
cast: [0.317, 0.885, 0.226, 0.4165],
keydelay: 0,
allstop:'delete'
allstop:'delete',
dc:'f10'
}
const fs = require("fs")
try {
Expand Down
2 changes: 1 addition & 1 deletion ui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
"/@/": root,
},
rollupInputOptions: {
external: ["fs", "path", "stream", "electron"],
external: ["fs", "path", "stream", "electron","iconv-lite"],
},
rollupOutputOptions: {
format: "commonjs",
Expand Down

0 comments on commit 2021579

Please sign in to comment.