网络安全最全教你用Python实现自动扫雷,你就是最亮的仔~_python扫雷视频教程

else:
print(“未找到窗口”)


**2.锁定并抓取雷区图像**



#锁定雷区坐标
#去除周围功能按钮以及多余的界面
#具体的像素值是通过QQ的截图来判断的
left += 15
top += 101
right -= 15
bottom -= 42

#抓取雷区图像
rect = (left, top, right, bottom)
img = ImageGrab.grab().crop(rect)


**3.各图像的RGBA值**



#数字1-8 周围雷数
#0 未被打开
#ed 被打开 空白
#hongqi 红旗
#boom 普通雷
#boom_red 踩中的雷
rgba_ed = [(225, (192, 192, 192)), (31, (128, 128, 128))]
rgba_hongqi = [(54, (255, 255, 255)), (17, (255, 0, 0)), (109, (192, 192, 192)), (54, (128, 128, 128)), (22, (0, 0, 0))]
rgba_0 = [(54, (255, 255, 255)), (148, (192, 192, 192)), (54, (128, 128, 128))]
rgba_1 = [(185, (192, 192, 192)), (31, (128, 128, 128)), (40, (0, 0, 255))]
rgba_2 = [(160, (192, 192, 192)), (31, (128, 128, 128)), (65, (0, 128, 0))]
rgba_3 = [(62, (255, 0, 0)), (163, (192, 192, 192)), (31, (128, 128, 128))]
rgba_4 = [(169, (192, 192, 192)), (31, (128, 128, 128)), (56, (0, 0, 128))]
rgba_5 = [(70, (128, 0, 0)), (155, (192, 192, 192)), (31, (128, 128, 128))]
rgba_6 = [(153, (192, 192, 192)), (31, (128, 128, 128)), (72, (0, 128, 128))]
rgba_8 = [(149, (192, 192, 192)), (107, (128, 128, 128))]
rgba_boom = [(4, (255, 255, 255)), (144, (192, 192, 192)), (31, (128, 128, 128)), (77, (0, 0, 0))]
rgba_boom_red = [(4, (255, 255, 255)), (144, (255, 0, 0)), (31, (128, 128, 128)), (77, (0, 0, 0))]


**4.扫描雷区图像保存至一个二维数组map**



#扫描雷区图像
def showmap():
img = ImageGrab.grab().crop(rect)
for y in range(blocks_y):
for x in range(blocks_x):
this_image = img.crop((x * block_width, y * block_height, (x + 1) * block_width, (y + 1) * block_height))
if this_image.getcolors() == rgba_0:
map[y][x] = 0
elif this_image.getcolors() == rgba_1:
map[y][x] = 1
elif this_image.getcolors() == rgba_2:
map[y][x] = 2
elif this_image.getcolors() == rgba_3:
map[y][x] = 3
elif this_image.getcolors() == rgba_4:
map[y][x] = 4
elif this_image.getcolors() == rgba_5:
map[y][x] = 5
elif this_image.getcolors() == rgba_6:
map[y][x] = 6
elif this_image.getcolors() == rgba_8:
map[y][x] = 8
elif this_image.getcolors() == rgba_ed:
map[y][x] = -1
elif this_image.getcolors() == rgba_hongqi:
map[y][x] = -4
elif this_image.getcolors() == rgba_boom or this_image.getcolors() == rgba_boom_red:
global gameover
gameover = 1
break
#sys.exit(0)
else:
print(“无法识别图像”)
print(“坐标”)
print((y,x))
print(“颜色”)
print(this_image.getcolors())
sys.exit(0)
#print(map)


**5.扫雷算法**


这里采用的最基础的算法


1.首先点出一个点


2.扫描所有数字,如果周围空白+插旗==数字,则空白均有雷,右键点击空白插旗


3.扫描所有数字,如果周围插旗==数字,则空白均没有雷,左键点击空白


4.循环2、3,如果没有符合条件的,则随机点击一个白块



#插旗
def banner():
showmap()
for y in range(blocks_y):
for x in range(blocks_x):
if 1 <= map[y][x] and map[y][x] <= 5:
boom_number = map[y][x]
block_white = 0
block_qi = 0
for yy in range(y-1,y+2):
for xx in range(x-1,x+2):
if 0 <= yy and 0 <= xx and yy < blocks_y and xx < blocks_x:
if not (yy == y and xx == x):if map[yy][xx] == 0:
block_white += 1
elif map[yy][xx] == -4:
block_qi += 1if boom_number == block_white + block_qi:for yy in range(y - 1, y + 2):
for xx in range(x - 1, x + 2):
if 0 <= yy and 0 <= xx and yy < blocks_y and xx < blocks_x:
if not (yy == y and xx == x):
if map[yy][xx] == 0:
win32api.SetCursorPos([left+xxblock_width, top+yyblock_height])
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
showmap()

#点击白块
def dig():
showmap()
iscluck = 0
for y in range(blocks_y):
for x in range(blocks_x):
if 1 <= map[y][x] and map[y][x] <= 5:
boom_number = map[y][x]
block_white = 0
block_qi = 0
for yy in range(y - 1, y + 2):
for xx in range(x - 1, x + 2):
if 0 <= yy and 0 <= xx and yy < blocks_y and xx < blocks_x:
if not (yy == y and xx == x):
if map[yy][xx] == 0:
block_white += 1
elif map[yy][xx] == -4:
block_qi += 1if boom_number == block_qi and block_white > 0:for yy in range(y - 1, y + 2):
for xx in range(x - 1, x + 2):
if 0 <= yy and 0 <= xx and yy < blocks_y and xx < blocks_x:
if not(yy == y and xx == x):
if map[yy][xx] == 0:
win32api.SetCursorPos([left + xx * block_width, top + yy * block_height])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
iscluck = 1
if iscluck == 0:
luck()

#随机点击
def luck():
fl = 1
while(fl):
random_x = random.randint(0, blocks_x - 1)
random_y = random.randint(0, blocks_y - 1)
if(map[random_y][random_x] == 0):
win32api.SetCursorPos([left + random_x * block_width, top + random_y * block_height])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
fl = 0

def gogo():
win32api.SetCursorPos([left, top])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
showmap()
global gameover
while(1):
if(gameover == 0):
banner()
banner()
dig()
else:
gameover = 0
win32api.keybd_event(113, 0, 0, 0)
win32api.SetCursorPos([left, top])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
showmap()


这个算法在初级和中级通过率都不错,但是在高级成功率惨不忍睹。


主要是没有考虑逻辑组合以及白块是雷的概率问题,可以对这两个点进行改进,提高成功率。


**需要更多教程,微信扫码即可**


 ![](https://img-blog.csdnimg.cn/6ade99f981cd4927b9ee5bd0aa40fd14.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5Y2D6ZSL5pWZ6IKy5a6Y5pa55Y2a5a6i,size_8,color_FFFFFF,t_70,g_se,x_16)


👆👆👆


****别忘了扫码领资料哦【******高清Java学习路线图******】****


****和****【各学科**********全套学习视频及配套资料********】******


 


### 如何自学黑客&网络安全


#### 黑客零基础入门学习路线&规划


**初级黑客**  
 **1、网络安全理论知识(2天)**  
 ①了解行业相关背景,前景,确定发展方向。  
 ②学习网络安全相关法律法规。  
 ③网络安全运营的概念。  
 ④等保简介、等保规定、流程和规范。(非常重要)


**2、渗透测试基础(一周)**  
 ①渗透测试的流程、分类、标准  
 ②信息收集技术:主动/被动信息搜集、Nmap工具、Google Hacking  
 ③漏洞扫描、漏洞利用、原理,利用方法、工具(MSF)、绕过IDS和反病毒侦察  
 ④主机攻防演练:MS17-010、MS08-067、MS10-046、MS12-20等


**3、操作系统基础(一周)**  
 ①Windows系统常见功能和命令  
 ②Kali Linux系统常见功能和命令  
 ③操作系统安全(系统入侵排查/系统加固基础)


**4、计算机网络基础(一周)**  
 ①计算机网络基础、协议和架构  
 ②网络通信原理、OSI模型、数据转发流程  
 ③常见协议解析(HTTP、TCP/IP、ARP等)  
 ④网络攻击技术与网络安全防御技术  
 ⑤Web漏洞原理与防御:主动/被动攻击、DDOS攻击、CVE漏洞复现


**5、数据库基础操作(2天)**  
 ①数据库基础  
 ②SQL语言基础  
 ③数据库安全加固


**6、Web渗透(1周)**  
 ①HTML、CSS和JavaScript简介  
 ②OWASP Top10  
 ③Web漏洞扫描工具  
 ④Web渗透工具:Nmap、BurpSuite、SQLMap、其他(菜刀、漏扫等)  
 恭喜你,如果学到这里,你基本可以从事一份网络安全相关的工作,比如渗透测试、Web 渗透、安全服务、安全分析等岗位;如果等保模块学的好,还可以从事等保工程师。薪资区间6k-15k


到此为止,大概1个月的时间。你已经成为了一名“脚本小子”。那么你还想往下探索吗?


如果你想要入坑黑客&网络安全,笔者给大家准备了一份:282G全网最全的网络安全资料包评论区留言即可领取!


**7、脚本编程(初级/中级/高级)**  
 在网络安全领域。是否具备编程能力是“脚本小子”和真正黑客的本质区别。在实际的渗透测试过程中,面对复杂多变的网络环境,当常用工具不能满足实际需求的时候,往往需要对现有工具进行扩展,或者编写符合我们要求的工具、自动化脚本,这个时候就需要具备一定的编程能力。在分秒必争的CTF竞赛中,想要高效地使用自制的脚本工具来实现各种目的,更是需要拥有编程能力.


如果你零基础入门,笔者建议选择脚本语言Python/PHP/Go/Java中的一种,对常用库进行编程学习;搭建开发环境和选择IDE,PHP环境推荐Wamp和XAMPP, IDE强烈推荐Sublime;·Python编程学习,学习内容包含:语法、正则、文件、 网络、多线程等常用库,推荐《Python核心编程》,不要看完;·用Python编写漏洞的exp,然后写一个简单的网络爬虫;·PHP基本语法学习并书写一个简单的博客系统;熟悉MVC架构,并试着学习一个PHP框架或者Python框架 (可选);·了解Bootstrap的布局或者CSS。

**8、超级黑客**  
 这部分内容对零基础的同学来说还比较遥远,就不展开细说了,附上学习路线。  
 ![img](https://img-blog.csdnimg.cn/img_convert/3fd39c2ba8ec22649979f245f4221608.webp?x-oss-process=image/format,png)


#### 网络安全工程师企业级学习路线


![img](https://img-blog.csdnimg.cn/img_convert/931ac5ac21a22d230645ccf767358997.webp?x-oss-process=image/format,png)  
 如图片过大被平台压缩导致看不清的话,评论区点赞和评论区留言获取吧。我都会回复的


视频配套资料&国内外网安书籍、文档&工具


当然除了有配套的视频,同时也为大家整理了各种文档和书籍资料&工具,并且已经帮大家分好类了。

![img](https://img-blog.csdnimg.cn/img_convert/153b2778a3fe5198265bed9635d63469.webp?x-oss-process=image/format,png)  
 一些笔者自己买的、其他平台白嫖不到的视频教程。  
 ![img](https://img-blog.csdnimg.cn/img_convert/32eb4b22aa740233c5198d3c161b37e8.webp?x-oss-process=image/format,png)



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以点击这里获取](https://bbs.csdn.net/topics/618540462)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值