python一线开发 [2021]手撸机器学习入门之jaya算法 总所周知,所谓机器学习就是一个解方程给x求y的过程罢了. 这是一篇入门的算法代码,又叫做jaya算法(不是java!!!),网上没什么资料,以下是自己python写的. ```python import math import random import matplotlib.pyplot as plt import numpy as np g_group_size = 5000 g_var_weight = 2 g_max_iteration = 100 g_array_f = [0 for i in range(0, g_group_size)] g_array_best = [0 for i in range(0, g_group_size)] g_array_worst = [0 for i in range(0, g_group_size)] g_array_pop_new = [[0 for i in range(0, g_var_weight)] for i in range(0, g_group_size)] #g_number_a = -2 * math.pi #g_number_b = 2 * math.pi #g_number_a = -5.12 #g_number_b = 5.12 g_number_a = -100 g_number_b = 100 g_result = [] array_pop = [[0 for i in range(0, g_var_weight)] for i in range(0, g_group_size)] def fn_objective(pArray): result = 0 for i in range(0, g_var_weight): # result += pArray[i] * pArray[i] # result += math.sin(pArray[i]) * math.pow(math.e, math.pow(1 - math.cos(result), 2)) + math.cos(result) * math.pow(math.e, math.pow(1 - math.sin(pArray[i]), 2)) + math.pow(pArray[i] - result, 2) # result += -(1 + math.cos(12 * math.sqrt(math.pow(pArray[i], 2) + math.pow(result, 2)))) / (0.5 * (math.pow(pArray[i], 2) + math.pow(result, 2)) + 2) result += math.pow(pArray[i], 2) + 2 * math.pow(result, 2) - 0.3 * math.cos(3 * math.pi * pArray[i]) - 0.4 * math.cos(4 * math.pi * result) + 0.7 return result def fn_clean_array(pArray): for i in range(0, g_group_size): for z in range(0, g_var_weight): if pArray[i][z] < g_number_a: pArray[i][z] = g_number_a if pArray[i][z] > g_number_b: pArray[i][z] = g_number_b return pArray for i in range(0, len(array_pop)): for z in range(0, len(array_pop[i])): array_pop[i][z] = random.uniform(g_number_a, g_number_b) g_array_f[i] = fn_objective(array_pop[i]) print("array_pop: ") print(array_pop) print("g_array_f: ") print(g_array_f) iter_num = 1 min_index = 0 max_index = 0 while iter_num <= g_max_iteration: min_value = min(g_array_f) min_index = g_array_f.index(min_value) - 1 g_array_best = array_pop[min_index] max_value = max(g_array_f) max_index = g_array_f.index(max_value) - 1 g_array_worst = array_pop[max_index] for i in range(0, g_group_size): for z in range(0, g_var_weight): wrost_number = g_array_worst[z] - math.fabs(array_pop[i][z]) best_number = g_array_best[z] - math.fabs(array_pop[i][z]) g_array_pop_new[i][z] = array_pop[i][z] + \ random.random() * best_number - wrost_number g_array_pop_new = fn_clean_array(g_array_pop_new) f_new = 0 for i in range(0, len(g_array_pop_new)): f_new = fn_objective(g_array_pop_new[i]) if f_new < g_array_f[i]: g_array_f[i] = f_new for z in range(g_var_weight): array_pop[i][z] = g_array_pop_new[i][z] min_value = min(g_array_f) min_index = g_array_f.index(min_value) g_array_best = array_pop[min_index] print("min number {} ".format(g_array_f[min_index])) print("x=") print(g_array_best) #g_result.insert(0, g_array_f[min_index]) g_result.append(g_array_f[min_index]) iter_num += 1 x = np.arange(0, len(g_result)) y = np.array(g_result) plt.title("jaya") plt.xlabel("min number") plt.ylabel("y") plt.plot(x, y) plt.show() ``` 请注意有一些公式需要很大的族群范围才能收敛 论文里面的收敛图: ![](https://key08.com/usr/uploads/2021/05/2290756614.png) 这边的: ![](https://key08.com/usr/uploads/2021/05/3846208643.png) 阅读全文 2021-05-24 huoji 0 条评论
二进制安全C/C++汇编Shellcode [2021]微软存在的一处内存泄露 在做EFI驱动的时候,会发现有疑似内存泄露,但不知道为什么.经过很久的调试,发现并不是EFI的代码的问题.而是微软自己的问题! 微软自己存在一处内存泄露.只不过EFI驱动多次调用这个API进行通讯导致从不明显的泄露成了明显的泄露 阅读全文 2021-05-21 huoji 0 条评论
[2021]Shellcodes Are for the 99% [Shellcodes are for the 99% - Bing Sun, Stanley Zhu, and Chong Xu, McAfee and Didi Chuxing.pdf](https://key08.com/usr/uploads/2021/05/1974096874.pdf) 阅读全文 2021-05-13 huoji 0 条评论
系统安全C/C++汇编Shellcode [2021]微软如何检测到hypervisor以及如何预防 微软挺奇怪的,什么事都要管一腿.总所周知 win 1809后hypervisor的一些功能比如msr hook(通过替换msr_lstar寄存器)的方案已经无了.怎么无的呢?除了kva shadow的问题,还有如下几个问题: 翻开微软的内核,有如下函数 KiErrata361Present KiErrataSkx55Present KiErrata704Present ... 这些函数有如下特点: 1. 名字莫名其妙 2. 调用者也莫名其妙,比如KiErrata361Present在一个IDA分析都要半个小时的函数里面调用. 3. 大部分都是微软检测虚拟机的函数 KiErrata704Present: 他长这样: 阅读全文 2021-05-13 huoji 1 条评论
二进制安全C/C++汇编一线开发Shellcode [2021]基于hypervisor的HIPS架构 从0到1 三 (进入虚拟化方式总结) 这部分是我在2021年的某场信息安全作品赛时候时候所写的。考虑到以后可能这个东西比赛完就没价值了.于是放在这里做备份吧. 阅读全文 2021-05-13 huoji 0 条评论
web安全二进制安全C/C++汇编Shellcode [2021]windows 2021H奇怪的安全机制导致堆栈回溯出现问题 今天发现的,我syscall hook了zwcreatefile这个API做了堆栈回溯: ![](https://key08.com/usr/uploads/2021/04/1314842216.png) 结果各种bug,详细看: ![](https://key08.com/usr/uploads/2021/04/2583737094.png) ![](https://key08.com/usr/uploads/2021/04/1983365686.png) 似乎windows 2021H先申请了一个read only内存,然后给这个read only内存设置了excute属性,设置完毕后再执行系统代码.执行完毕后再设置为noaccess 因此堆栈回溯会看到大部分都在private属性里面,如果异步回溯则看到noaccess 挺奇怪的机制.目前不确定为什么.暂时没空逆向,如果有知道的tx可以在评论区留言 阅读全文 2021-04-25 huoji 1 条评论
二进制安全C/C++汇编 [2021]syscall、sysret研究 https://events.static.linuxfound.org/sites/events/files/slides/entry-lce.pdf 备份: [entry-lce.pdf](https://key08.com/usr/uploads/2021/04/37404595.pdf) 阅读全文 2021-04-20 huoji 0 条评论