已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Practice 1: ArrayStorage.cpp将字符数组a与b的首地址传入Initialize()方法后,对a中的各个元素进行赋值,将字符数组a的0到8位赋值为字符数组“This is A”。又将a的首地址赋值给b的首地址,则在此时,b已经变为指向字符数组a的指针,与a等效。则b8 = B就是将“This is A”改为“This is B”,未对字符数组b进行任何操作。所以当Initialize()方法运行结束后,字符数组a的内容为“This is A”,而字符数组b的内容仍为空。Practice 2: strchr.cppFgets();fgets()用来从参数stream 所指的文件内读入字符并存到参数s 所指的内存空间, 直到出现换行字符、读到文件尾或是已读了size-1 个字符为止, 最后会加上NULL 作为字符串结束.Strchr();用来查找某字符在字符串中首次出现的位置,其原型为: char * strchr (const char *str, int c);【参数】str 为要查找的字符串,c 为要查找的字符。strchr() 将会找出 str 字符串中第一次出现的字符 c 的地址,然后将该地址返回。Strncmp();strncmp() 用来比较两个字符串的前n个字符,区分大小写,其原型为: int strncmp ( const char * str1, const char * str2, size_t n );【参数】str1, str2 为需要比较的两个字符串,n为要比较的字符的数目。字符串大小的比较是以ASCII 码表上的顺序来决定,此顺序亦为字符的值。strncmp()首先将s1 第一个字符值减去s2 第一个字符值,若差值为0 则再继续比较下个字符,直到字符结束标志0,若差值不为0,则将差值返回。例如字符串Ac和ba比较则会返回字符A(65)和b(98)的差值(-33)。Practice 3: Decoding Lab: Understanding a Secret MessageDecoding Lab (Part 1)Objectives: For this exercise, you have to compile a program as attached and supply four secret keys to determine the contents. In this laboratory, you have to supply the first two. The remaining will be done next week. I will guide you to solve the problem. This exercise is extracted from the CTE, SSD6 Exercise one.The details are as follows.Start the program:1) invoke the visual C+ and use new to start the workplace.2) Select the New Menu and click “workplace”. The name is called exercise 13) The project is exercise 1: Select Win32 Console4) The output after selecting the project is as follows. 5) Select the empty button until you see the following screen6) Now Select New again and then Files, type the name of file “Exercise 1” and select C+ source file. 7) Click the fileview and the source files you will see exercise1.cpp is there, but is empty.8) Now you download the secret file (secret.cpp) from CTE web site or get it from appendix.9) Compile the program without any bug. Set a breakpoint: Set a break point to force the program to break, press F9. A good programmer must know how to debug.1) Press F9 at the location of int dummy under main()2) Now Click Debug and choose start debug then go, you will see the screenIt means the program stops at this location, You can now dummy the message to analysis the data.3) Right click your mouse and you will get a screen as follows: 4) Select quick watch and you will see a quick watch 5) Type the data and write the addressAddress of data is: _ 0x00424ab0_ (hint: in hex, ox.)6) In the address screen: Enter the value of the address of data: 0x00424ab0_. You can see the value of on the right hand side. Write down the first 40 characters.cccccccccFFrromo: mFr:ie ndC.TTo:E Y.ouTDetermine the value of start and stride:Hint Now you find that if you can extract the message, pick the start message and then the stride (after how many characters for the next), you can then guess how to determine it. For example, 1234567890AStart:0 and stride: 2, will produce 13579AStart:0 and stride: 3, will produce 1245780AStart:0 and stride: 4, will produce 12356790AStart:1 and stride: 3, will produce 235689AIf you choose the value properly, you will get:Start value: in decimal in order to produce the above message is _9_Stride: length of next character (Hint: You have to refer to the program, the value is 2, 3 or 4 only).Start = 9;Stride = 3;1) Write down the address of dummy _, you have to set a break point beside key1, F9 and Execute debug so that the program goes through the first few lines. Use right click mouse and &dummy (&means the address)Press F10 will advance the program.It is an integer: It consists of _4_ bytes. You can determine by checking the location of int start, you then understand the size.Now dummy consists of two parts: stride and start.Write down the value of key1_3_: The difference between dummy and key1, Key2: The first byte: start The second byte: stride The third and fourth byte can be set to zero.Key2 : 0 x start + 0 x stride :777(第三个与第四个字节可以任取,在此为方便设为0)/*/Key1,Key2计算过程:通过以上两条语句我们可以得知:start是取了dummy这个整形数字的第一个字节上的数字,stride是取了dummy这个整形数字的第二个字节上的数字。所以dummy前两位字节是0x0309通过传入的Key1,Key2,要使得dummy前两位字节是0x0309。则key2的值是后两位字节为0x0309的任意整形数字。Key1 + *Key1 需要为dummy的地址:0x0012ff7c,key的地址为0x0012ff70。0与c相差3个字节,所以key为3./*/2) Now select the project: setting, you will see the following screenEnter the value of key1 and key2 that you have determined and execute, you will get :Appendix:Please note that you dont need to modify any program, but to understand how to enter the keys.You can extract and compile the program:#include #include int prologue = 0x5920453A, 0x54756F0A, 0x6F6F470A, 0x21643A6F,0x6E617920, 0x680A6474, 0x6F697661, 0x20646E69,0x63636363, 0x63636363, 0x72464663, 0x6F6D6F72,0x63636363, 0x63636363, 0x72464663, 0x6F6D6F72,0x2C336573, 0x7420346E, 0x20216F74, 0x726F5966,0x7565636F, 0x20206120, 0x6C616763, 0x74206C6F,0x20206F74, 0x74786565, 0x65617276, 0x32727463,0x594E2020, 0x206F776F, 0x79727574, 0x4563200A;/*int data = 0x63636363, 0x63636363, 0x72464663, 0x6F6D6F72,0x7565636F, 0x20206120, 0x6C616763, 0x74206C6F,0x5920453A, 0x54756F0A, 0x6F6F470A, 0x21643A6F,0x594E2020, 0x206F776F, 0x79727574, 0x4563200A,0x6F786F68, 0x6E696373, 0x6C206765, 0x796C656B,0x2C336573, 0x7420346E, 0x20216F74, 0x726F5966,0x7565636F, 0x20206120, 0x6C616763, 0x74206C6F,0x20206F74, 0x74786565, 0x65617276, 0x32727463,0x6E617920, 0x680A6474, 0x6F697661, 0x20646E69,0x21687467, 0x63002065, 0x6C6C7861, 0x78742078,0x6578206F, 0x72747878, 0x78636178, 0x00783174;*/int data = 0x63636363, 0x63636363, 0x72464663, 0x6F6D6F72,0x466D203A, 0x65693A72, 0x43646E20, 0x6F54540A,0x5920453A, 0x54756F0A, 0x6F6F470A, 0x21643A6F,0x594E2020, 0x206F776F, 0x79727574, 0x4563200A,0x6F786F68, 0x6E696373, 0x6C206765, 0x796C656B,0x2C336573, 0x7420346E, 0x20216F74, 0x726F5966,0x7565636F, 0x20206120, 0x6C616763, 0x74206C6F,0x20206F74, 0x74786565, 0x65617276, 0x32727463,0x6E617920, 0x680A6474, 0x6F697661, 0x20646E69,0x21687467, 0x63002065, 0x6C6C7861, 0x78742078,0x6578206F, 0x72747878, 0x78636178, 0x00783174;int epilogue = 0x594E2020, 0x206F776F, 0x79727574, 0x4563200A,0x6E617920, 0x680A6474, 0x6F697661, 0x20646E69,0x7565636F, 0x20206120, 0x6C616763, 0x74206C6F,0x2C336573, 0x7420346E, 0x20216F74, 0x726F5966,0x20206F74, 0x74786565, 0x65617276, 0x32727463;char message100;void usage_and_exit(char * program_name) fprintf(stderr, USAGE: %s key1 key2 key3 key4n, program_name);exit(1);void process_keys12 (int * key1, int * key2) *(int *) (key1 + *key1) = *key2;void process_keys34 (int * key3, int * key4) *(int *)&key3) + *key3) += *key4;char * extract_message1(int start, int stride) int i, j, k;int done = 0;for (i = 0, j = start + 1; ! done; j+) for (k = 1; k stride; k+, j+, i+) if (*(char *) data) + j) = 0) done = 1;break; messagei = *(char *) data) + j);mes
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年房地产项目新能源应用管理岗位晋升考核试卷
- 19.2025年医疗行业AI辅助骨肿瘤化疗耐药性分析医疗大数据能力考核试卷
- 2025年航空运输行业航空运输智能化解决方案研究报告及未来发展趋势预测
- 2025年教师工作量调研合规考核试卷
- 2025浙江绍兴市中心血站招聘编外人员1人考试笔试备考题库及答案解析
- 2025年南平邵武市金塘工业园区专职消防队招聘专职消防队员18人笔试考试参考题库及答案解析
- 2025云南楚雄永仁县统计局城镇公益性岗位人员招聘1人笔试考试备考题库及答案解析
- 2025广东惠州市博罗县自然资源局招聘编外人员76人笔试考试参考试题及答案解析
- 财务策略:驱动增长-以业绩和竞争力为导向
- 2025浙江嘉兴市体育彩票管理服务中心招聘编外人员4人笔试考试备考题库及答案解析
- JCT2460-2018 预制钢筋混凝土化粪池
- 芯片开发职业生涯规划与管理
- 认知行为疗法(CBT)实操讲座
- GB/T 3683-2023橡胶软管及软管组合件油基或水基流体适用的钢丝编织增强液压型规范
- 重说二十年前的作品亮出你的舌苔或空空荡荡
- 身份证前六位与省市县区对照表可直接存入数据库
- 内分泌专业临床路径大全
- 党建知识题库附答案
- 竖井施工方案
- 初中化学渗透“德育”教案
- 制梁场制存梁台座检测方案
评论
0/150
提交评论