版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、Practice 1: ArrayStorage.cpp將字符數(shù)組a與b的首地址傳入Initialize ()方法后,對a中的各個元素進(jìn)行賦值,將字符數(shù)組a的0到8位賦值為字符數(shù)組“This is A”。又將a的首地址賦值給b的首地址,則在此時,b已經(jīng)變?yōu)橹赶蜃址麛?shù)組a的指針,與a等效。則b8 = B就是將“This is A”改為“This is B”,未對字符數(shù)組b進(jìn)行任何操作。所以當(dāng)Initialize ()方法運行結(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 個字符為止, 最后會加上NULL 作為字符串結(jié)束.Strchr();用來查找某字符在字符串中首次出現(xiàn)的位置,其原型為: char * strchr (const char *str, int c);【參數(shù)】str 為要查找的字符串,c 為要查找的字符。strchr() 將會找出 str 字符串中第一次出現(xiàn)的字符 c 的地址,然后將該地址返回。Strncmp();strncmp() 用來比較兩個字符串的前n個字符,區(qū)分大小寫,其原型為: int strncmp ( cons
3、t char * str1, const char * str2, size_t n );【參數(shù)】str1, str2 為需要比較的兩個字符串,n為要比較的字符的數(shù)目。字符串大小的比較是以ASCII 碼表上的順序來決定,此順序亦為字符的值。strncmp()首先將s1 第一個字符值減去s2 第一個字符值,若差值為0 則再繼續(xù)比較下個字符,直到字符結(jié)束標(biāo)志'0',若差值不為0,則將差值返回。例如字符串"Ac"和"ba"比較則會返回字符"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(第三個與第四個字節(jié)可以任取,在此為方便設(shè)為0)/*/Key1,Key2計算過程:通過以上兩條語句我們可以得知:start是取了dummy這個整形數(shù)字的第一個字節(jié)上的數(shù)字,stride是取了dummy這個整形數(shù)字的第二個字節(jié)上的數(shù)字。所以dummy前兩位字節(jié)是0x0309通過傳入的Key1,Key2,要使得dummy前兩位字節(jié)是0x0309。則key2的值是后兩位字節(jié)為0x0309的任意整形數(shù)字。
15、Key1 + *Key1 需要為dummy的地址:0x0012ff7c,key的地址為0x0012ff70。0與c相差3個字節(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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度金融機構(gòu)外匯借款合同綠色金融創(chuàng)新實踐
- 二零二五年度碼頭租賃項目環(huán)保驗收及服務(wù)合同4篇
- 二零二五年度錄音系統(tǒng)定制開發(fā)與實施合同3篇
- 2025年度蘋果水果產(chǎn)地直供直銷采購合同4篇
- 2025版木工模板租賃與園林景觀設(shè)計施工承包合同范本3篇
- 二零二五年度寵物醫(yī)院寵物食品研發(fā)與生產(chǎn)合作協(xié)議3篇
- 二零二五年度辦公家具銷售合同(含安裝)2篇
- 二零二五年度天使投資協(xié)議書:生物科技研發(fā)項目風(fēng)險投資合同
- 二零二五年度商標(biāo)授權(quán)及商標(biāo)市場推廣合同范本2篇
- 二零二五出租車公司股權(quán)轉(zhuǎn)讓與智能化改造協(xié)議4篇
- 2024-2030年中國招標(biāo)代理行業(yè)深度分析及發(fā)展前景與發(fā)展戰(zhàn)略研究報告
- 醫(yī)師定期考核 (公共衛(wèi)生)試題庫500題(含答案)
- 基因突變和基因重組(第1課時)高一下學(xué)期生物人教版(2019)必修2
- 內(nèi)科學(xué)(醫(yī)學(xué)高級):風(fēng)濕性疾病試題及答案(強化練習(xí))
- 音樂劇好看智慧樹知到期末考試答案2024年
- 辦公設(shè)備(電腦、一體機、投影機等)采購 投標(biāo)方案(技術(shù)方案)
- 案卷評查培訓(xùn)課件模板
- 2024年江蘇省樣卷五年級數(shù)學(xué)上冊期末試卷及答案
- 人教版初中英語七八九全部單詞(打印版)
- 波浪理論要點圖解完美版
- 金融交易數(shù)據(jù)分析與風(fēng)險評估項目環(huán)境敏感性分析
評論
0/150
提交評論