




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Practice 1: ArrayStorage.cpp將字符數(shù)組a與b的首地址傳入Initialize ()方法后,對(duì)a中的各個(gè)元素進(jìn)行賦值,將字符數(shù)組a的0到8位賦值為字符數(shù)組“This is A”。又將a的首地址賦值給b的首地址,則在此時(shí),b已經(jīng)變?yōu)橹赶蜃址麛?shù)組a的指針,與a等效。則b8 = B就是將“This is A”改為“This is B”,未對(duì)字符數(shù)組b進(jìn)行任何操作。所以當(dāng)Initialize ()方法運(yùn)行結(jié)束后,字符數(shù)組a的內(nèi)容為“This is A”,而字符數(shù)組b的內(nèi)容仍為空。Practice 2: strchr.cppFgets();fgets()用來
2、從參數(shù)stream 所指的文件內(nèi)讀入字符并存到參數(shù)s 所指的內(nèi)存空間, 直到出現(xiàn)換行字符、讀到文件尾或是已讀了size-1 個(gè)字符為止, 最后會(huì)加上NULL 作為字符串結(jié)束.Strchr();用來查找某字符在字符串中首次出現(xiàn)的位置,其原型為: char * strchr (const char *str, int c);【參數(shù)】str 為要查找的字符串,c 為要查找的字符。strchr() 將會(huì)找出 str 字符串中第一次出現(xiàn)的字符 c 的地址,然后將該地址返回。Strncmp();strncmp() 用來比較兩個(gè)字符串的前n個(gè)字符,區(qū)分大小寫,其原型為: int strncmp ( cons
3、t char * str1, const char * str2, size_t n );【參數(shù)】str1, str2 為需要比較的兩個(gè)字符串,n為要比較的字符的數(shù)目。字符串大小的比較是以ASCII 碼表上的順序來決定,此順序亦為字符的值。strncmp()首先將s1 第一個(gè)字符值減去s2 第一個(gè)字符值,若差值為0 則再繼續(xù)比較下個(gè)字符,直到字符結(jié)束標(biāo)志'0',若差值不為0,則將差值返回。例如字符串"Ac"和"ba"比較則會(huì)返回字符"A"(65)和'b'(98)的差值(-33)。Practice 3:
4、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 yo
5、u 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 W
6、in32 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.cp
7、p 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 locatio
8、n 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
9、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
10、: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:
11、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 t
12、o 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 adv
13、ance 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
14、 second byte: stride The third and fourth byte can be set to zero.Key2 : 0 x start + 0 x stride :777(第三個(gè)與第四個(gè)字節(jié)可以任取,在此為方便設(shè)為0)/*/Key1,Key2計(jì)算過程:通過以上兩條語句我們可以得知:start是取了dummy這個(gè)整形數(shù)字的第一個(gè)字節(jié)上的數(shù)字,stride是取了dummy這個(gè)整形數(shù)字的第二個(gè)字節(jié)上的數(shù)字。所以dummy前兩位字節(jié)是0x0309通過傳入的Key1,Key2,要使得dummy前兩位字節(jié)是0x0309。則key2的值是后兩位字節(jié)為0x0309的任意整形數(shù)字。
15、Key1 + *Key1 需要為dummy的地址:0x0012ff7c,key的地址為0x0012ff70。0與c相差3個(gè)字節(jié),所以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 u
16、nderstand how to enter the keys.You can extract and compile the program:#include <stdio.h>#include <stdlib.h>int prologue = 0x5920453A, 0x54756F0A, 0x6F6F470A, 0x21643A6F,0x6E617920, 0x680A6474, 0x6F697661, 0x20646E69,0x63636363, 0x63636363, 0x72464663, 0x6F6D6F72,0x63636363, 0x63636363,
17、 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, 0x6C
18、616763, 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
19、,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,0x59
20、4E2020, 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
21、, 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, 0
22、x65617276, 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
23、) + *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);messagei = '0'return message;char * extract_message2(int start, int stride) int i, j;for (i = 0, j = start; *(char *) data) + j) != '0' i+, j += stride) messagei =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司財(cái)務(wù)臺(tái)賬管理制度
- 生產(chǎn)實(shí)習(xí)年度工作報(bào)告總結(jié)(16篇)
- 行政組織行為分析及其意義試題及答案
- 網(wǎng)絡(luò)自動(dòng)化運(yùn)維工具介紹試題及答案
- 愛崗敬業(yè)的演講稿題目(20篇)
- 網(wǎng)絡(luò)流量監(jiān)測(cè)工具試題及答案
- 2025借款抵押合同(16篇)
- 房產(chǎn)銷售代理及傭金結(jié)算合同
- 假想的奇幻世界探險(xiǎn)經(jīng)歷想象作文14篇
- 優(yōu)美現(xiàn)代詩歌朗誦(18篇)
- 藥用菊花規(guī)范化種植及深加工項(xiàng)目可研報(bào)告
- 文字圖形創(chuàng)意課件
- (完整版)普外科出科考試試題
- 殘疾青少年與扶持課件
- 冠脈造影術(shù)前術(shù)后的護(hù)理課件
- 2023年云南省腫瘤醫(yī)院醫(yī)護(hù)人員招聘筆試題庫及答案解析
- 2022年市場(chǎng)-飼料銷售技巧培訓(xùn)
- 護(hù)理風(fēng)險(xiǎn)評(píng)估及填寫要求
- 微邦生物技術(shù)生活污水處理中的應(yīng)用
- 《港口裝卸工藝學(xué)》課程設(shè)計(jì)
- 《潔凈工程項(xiàng)目定額》(征求意見稿)
評(píng)論
0/150
提交評(píng)論