2019_1_15
任务一、PE文件
PE文件种类有:EXE、SCR、DLL、OCX、CPL、DRV、SYS、VXD、OBJ
PE文件由许多结构体组成:
1、DOS头
在PE头最前面有一个DOS头,结构体的名字叫IMAGE_DOS_HEADER,大小是40字节,其中最重要的成员是e_magic和e_lfanew,前者表示DOS签名(MZ),后者表示NT头的偏移。
2、DOS存根
在DOS 头的下方,是个可选项,且大小不固定(即没有DOS存根也不影响正常运行)。DOS存根由代码和数据混合而成
40到4D是16位的汇编指令,在DOS环境下才会执行这些代码,32为的Windows中不会运行。
我看到了一篇博客,我想我讲的无法更好,放弃自己重述语言,直接将其作为教科书学习
http://www.cnblogs.com/tk091/archive/2012/09/01/2666995.html
任务二、python书写RSA加密算法
一、相关python资料
1、读取文件
f = open("data.txt","r") #设置文件对象
str = f.read() #将txt文件的所有内容读入到字符串str中
f.close() #将文件关闭
2、按行读取整个文件
#第一种方法
f = open("data.txt","r") #设置文件对象
line = f.readline()
line = line[:-1]
while line: #直到读取完文件
line = f.readline() #读取一行文件,包括换行符
line = line[:-1] #去掉换行符,也可以不去
f.close() #关闭文件
#第二种方法
data = []
for line in open("data.txt","r"): #设置文件对象并读取每一行文件
data.append(line) #将每一行文件加入到list中
#第三种方法
f = open("data.txt","r") #设置文件对象
data = f.readlines() #直接将文件中按行读到list里,效果与方法2一样
f.close() #关闭文件
3.将文件读入数组中
import numpy as np
data = np.loadtxt("data.txt") #将文件中数据加载到data数组里
1.简单的将字符串写入txt中
with open('data.txt','w') as f: #设置文件对象
f.write(str) #将字符串写入文件中
二、程序及其相关截图
n = 920139713
e = 19
for i in range(2,n):
if PD(i)==0:
continue
print(i)
for j in range(2,50000):
if PD(j)==0:
continue
if i*j%n==1:
p=i
q=j
print(p,q)
break
break
'''
'''
p=18443
q=49891
e=19
fn=(p-1)*(q-1)
for i in range(2,fn):
flag=e*i%fn
#print(i)
if flag==1:
d=i
print(i,q)
break
#计算结果为d=9684619 故密钥为(p,q,d)(18443,49891,96849619)
'''
n=920139713
d=96849619
a=""
f = open("cipher.txt","r") #设置文件对象
line = f.readline()
line = line[:-1]
line1=int(line)
line2=line1
for i in range(1,96849619):
#print(i,line)
line1=line1*line2%n
print(line,"的输出结果如下:",chr(line1))
a=a+line
while line: #直到读取完文件
line = f.readline() #读取一行文件,包括换行符
line1=int(line)
line2=line1
for i in range(1,96849619):
#print(i,line)
line1=line1*line2%n
print(line,"的输出结果如下:",chr(line1))
a=a+line
line = line[:-1] #去掉换行符,也可以不去
print("总的输出结果为:",a)
f.close() #关闭文件
总结如下:
flag{13212je2ue28fy71w8u87y31r78eu1e2}
任务三、栅栏加密
代码如下:
cipher="CrudreasrsheheanaulhfouCmhlaopiaeifltouermrtdpiyeCntpmafhnpbgmbaoagspeuteuwtecwokpetwutileolctnreoicottievhetepriogoseIretodaiithgottfeorhersnueualtebtfamtnseetehrnieipooilrshashyhsrmttmanariaictntgutdeeonmotaudeowuselctnfeoghrtsbaCrgarhtbprthcirarQktodbeatees"
str=''
def de(x):
str=''
for y in range(x):
tmp=y
for z in range(int(260/x+1)):
if(tmp<260):
str=str+cipher[tmp]
tmp=tmp+x
return str
for x in range(259):
str=de(x+1)
print(x+1,str)
第29条指令有效:
CppisahorriblelanguageItsmademorehorriblebythefactthatalotofsubstandardprogrammersuseittothepointwhereitsmuchmucheasiertogeneratetotalanduttercrapwithitQuitefranklyevenifthechoiceofCweretodonothingbutkeeptheCppprogrammersoutthatinitselfwouldbeahugereasontouseC
断句为:
Cpp is a horrible language Its made more horrible by the fact that a lot of substandard programmers use it to the point where its much much easier to generate total and utter crap with it Quite frankly even if the choice of C were to do nothing but keep the Cpp programmers out that in itself would be a huge reason to use C
任务四、阅读https://blog.csdn.net/cnhk1225/article/details/53568996
回答问题:What does this code do?
Optimizing csc .NET compiler from MSVS 2015 (/o switch), ildasm output:
.method public hidebysig static bool f(char a) cil managed
{
// Code size 26 (0x1a)
.maxstack 8
IL_0000: ldarg.0 //将索引为0的参数加载到计算堆上
IL_0001: ldc.i4.s 97 //把97作为int32(短格式)送到堆栈上
IL_0003: blt.s IL_000c //如果第一个值小于第二个,则将控制转移到目标指令
IL_0005: ldarg.0 //将索引为0的参数加载到计算堆上
IL_0006: ldc.i4.s 122 //把122作为int32(短格式)送到堆栈上
IL_0008: bgt.s IL_000c //如果第一个值大于第二个值,则将控制转移到目标指令
IL_000a: ldc.i4.1 //将整数值为1作为int32送到计算堆栈上
IL_000b: ret //返回指令,如果存在返回值,则返回值发送到堆栈上
IL_000c: ldarg.0 //将索引为0的参数加载到计算堆上
IL_000d: ldc.i4.s 65 //把65作为int32(短格式)送到堆栈上
IL_000f: blt.s IL_0018 //如果第一个值小于第二个值,跳转到目标地址
IL_0011: ldarg.0 //将索引为0的参数加载到计算堆上
IL_0012: ldc.i4.s 90 //把90作为int32(短格式)送到堆栈上
IL_0014: bgt.s IL_0018 //如果第一个数大于第二个数,跳转到目的地址
IL_0016: ldc.i4.1 //将整数值为1的值作为int32(短格式),发送到堆栈上
IL_0017: ret //返回指令,如果存在返回值,则返回值发送到堆栈上
IL_0018: ldc.i4.0 //将整数值为1作为int32发送到计算堆栈上
IL_0019: ret //返回指令,如果存在返回值,则返回值发送到堆栈上
} // end of method some_class::f
一样的代码,只不过换成了Java语言
Java 1.8 compiler:
public boolean f(char);
descriptor: (C)Z
flags: ACC_PUBLIC
Code:
stack=2, locals=2, args_size=2
0: iload_1
1: bipush 97
3: if_icmplt 14
6: iload_1
7: bipush 122
9: if_icmpgt 14
12: iconst_1
13: ireturn
14: iload_1
15: bipush 65
17: if_icmplt 28
20: iload_1
21: bipush 90
23: if_icmpgt 28
26: iconst_1
27: ireturn
28: iconst_0
29: ireturn