![系統(tǒng)級編程-lab4_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/efb321f1-c8a5-4f13-9257-b7ebf1fb1486/efb321f1-c8a5-4f13-9257-b7ebf1fb14861.gif)
![系統(tǒng)級編程-lab4_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/efb321f1-c8a5-4f13-9257-b7ebf1fb1486/efb321f1-c8a5-4f13-9257-b7ebf1fb14862.gif)
![系統(tǒng)級編程-lab4_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/efb321f1-c8a5-4f13-9257-b7ebf1fb1486/efb321f1-c8a5-4f13-9257-b7ebf1fb14863.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、 將字符數(shù)組a與b的首地址傳入Initialize()方法后,對a中的各個元素進展賦值,將字符數(shù)組 a的0到8位賦值為字符數(shù)組“ This is A。 又將a的首地址賦值給 b的首地址,如此在此時,b已經(jīng)變?yōu)橹赶蜃址麛?shù)組a的指針,與a等效。如此b8= 就是將“ This is A改為“ This is'B,未對字符數(shù)組 b進展任何操作。 所以當(dāng)Initialize()方法運行完畢后,字符數(shù)組a的內(nèi)容為“This is A,而字符數(shù)組b的內(nèi)容仍為空。Fgets();fgets()用來從參數(shù)stream所指的文件內(nèi)讀入字符并存到參數(shù)s所指的內(nèi)存空間,直到出現(xiàn)換行字符、讀到文件尾或是已讀了
2、size-1個字符為止,最后會加上NULL作為字符串完 畢Strchr();用來查找某字符在字符串中首次出現(xiàn)的位置,其原型為:char * strchr (const char *str, i nt c);【參數(shù)】str為要查找的字符串,c為要查找的字符。strchr()將會找出str字符串中第一次出現(xiàn)的字符c的地址,然后將該地址返回。Strncmp();strncmp()用來比擬兩個字符串的前n個字符,區(qū)分大小寫,其原型為:int strncmp ( const char * strl, const char * str2, size_t n );【參數(shù)】str1, str2為需要比擬的兩個
3、字符串,n為要比擬的字符的數(shù)目。字符串大小的比擬是以ASCII碼表上的順序來決定,此順序亦為字符的值。strncmp()首先將s1第一個字符值減去 s2第一個字符值,假如差值為0如此再繼續(xù)比擬下個字符,直到字符完畢標(biāo)志'0',假如差值不為0,如此將差值返回。例如字符串"Ac"和"ba"比擬如此會返回字符"A"(65)和'b'(98)的差值(-33)。Practice 3: Decoding Lab: Understandinga SecretMessageDecodi ng Lab (Part 1)Ob
4、jectives:For this exercise, you have to pile 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 -
5、 Exercise one.The details are as follows.Start the program:1)in voke the visual C+ and use new to start the workplace.2) Select the New Menu and click workpiaceThe n ame is called exercise 14)3) The project is exercise 1: Select Win 32 Con soleThe output after select ing the project is as follows.5)
6、Select the empty butt on un til you see the follow ing scree nEXercise 16) Now Select New aga in and the n Files, type the n ame of fileselect C+ source file.7) Click the fileview and the source files you will see exercise1.cpp is there, but is empty.8) Now you dow nl oad the secret file (secret.cpp
7、) from CTE web siteor get it from appe ndix.exercise!亠 M iciojoFl Visual C+-t- - eNeictiel.p0 File EM View Insert £ioject guild lools 辿indcv? Hefc>盲 耳啟廚 電唱 吒小 -T |畫網(wǎng) 0 笹|StarlThfead3 M_| Heariei Files _| Hesouice biles宜 exercisel filesA-已 Source Fites(GlnbaJil(All glnhal rn Frnhifir)J»i
8、nclude <stdio . h > #include <stdlib. h.>p 11iintpro lc»gu& = ;'Rw«rrifip1' 1 prnjfiil三匚 lassView I g FiteViewjx$EEL?920 ”0x6333”0x636363&3,UxZCJJ6573 , 0x7&6563SF, Dx20206F74, x594E2020Cw547S&F0A, 0x68046474 < 0x63636363.Cx63S36363,LH/420J4bE,0x20206
9、120, (1x74766565 * Cx206F776F0«6FfcF470A, 0h6F6976G1 . 0x72464663 , 0x7246-4663, 0xZUZlfeF74 , 0x6C616763, 0kS5617276, 0x79727574 .»2L643A6F, g2U£4GE69” 0x6F6DeF72, 0h6F6D6F72, Lix7ZfeE59b&” Ck74206C6F, 0x327274&3, 0z4563200Ais(&36363S3. x75G563t>F. x5920453i, x534E200
10、” X&F7 86F&B. 0x2C336573 ” 0x756562&F. 0x2D2D6F74. nxfeE6179?n x216874S7, Kt5702OfcF,0x63636363, 0x20206120 . Cx54756FnkH 0X2Q&F776K, Ox6E6963?3 ” Ox7420346E, Cx20206120 . 0x74766565, rx680A64d 0x63002065, 0x72747679 ,0x72464663, 0x6CGlC763 . 0X&F6F4704, 0x75727574 0s6C20e765, 0x
11、2UlbF74 , 0xSC61t7£3, 0x65617276, 0xSFS97i5i61 0x6CSC7S61. 0x7863176,Cix6FtD6F72, 0x74206匚呂R” 0x21643ASF, Q囂金. Os736C6S6B, 0k726F59G6,Oh74206C6F,0x32727463, fix2n6dE69. 0k787J207S, 0x00783174* J Build、Debug 、Find n Files 1X Find in Files qReady9) pile the program without any bug.Set a breakpo i
12、nt:Set a break point to force the program to break, press F9. A good programmer mustknow how to debug.1) Press F9 at the locatio n of int dummy un der main()2) Now Click Debug and choose start debug the n go, you will see the scree nIt means the program stops at this location. You can now dummy the
13、message to7 / 21an alysis the data.3) Right click your mouse and you will get a scree n as follows:4) Select quick watch and you will see a quick watch5) Type the data and write the addressAddress of data is:0x00424ab0(hi nt: in hex, ox .)6) In the address scree n: En ter the value of the address of
14、 data:0x00424ab0. You can see the value of on the right hand side.12il ,£ite E" 型附 ln&3if £rripct £?pbu口 丄ocw 應(yīng)和為丹 Halp卡 r.jiv |mn(iHrNome3 *rgvduxinvcodoocohF Frrcincinin-u b. ojalol t E T.-duT Goki d. I tlYotfo t udf-y6C54?n79b3 £F 2.0 4弓'77:22C6F7251-3i - A ii0042
15、21C4 QD422ICEi - i 匚皿203 cl F 5 血 2 “b h E ? r .3 F 7 3 -A o Jniul 5 -1 2- » -Z - 二 at .-r- Eg 一 .2020:iR Ha gJMEmjU inc膽心日4|人唔電A |記廖閉魯|gThd"HI MIfl| iGbbah)* |l|All icbd nr ent er s|二| . Bairn越屋!卻尅int stz-ide>i&t a. 3 .:for (1 = 0., j = Btar1>i:譏 char 1 * " W :m, J B wind)i
16、電11 * * ( t leJWT *:i datJ + j ) ) = 、(T .i-eturn 血匕站g.ini ffsin (mt M-gc. chiiT *M-g I )©iHt duruiv - 1.:lilt- stMt. .stride:: ml keyl, key2. key! , key4 cbar * nsrl * rot;k=3 云云 0.if (arro < 3 ll !| Enk: >jpcbuq Eir<l in Flee 乂 fnd nFios; mcLis礴CH>m.” 埔起0 WiE3ir”電piosjioar.S? u:l
17、*3*tfuvrii” | -qBuiij | 鈕CTE-隔”留EudMEF.劭Pwjtrwn | 圖IW-Write dow n the first 40 characters.cccccccccFFrromo: mFDetermi ne 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 t
18、hen guess how to10 / 21determine it.For example, 1234567890AStart:。and stride: 2, will produce 13579AStart:。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:ju clio a « if%i
19、f ke11 to exliMUft.£ y Co cuntlnu#Naw t he an<yGocidT dLVu Id,4 to Fo>-ce m call to &xtpact2 And二I匚刮刁二| 血|匪| rrfsStart value: in decimal in order to produce the above message is9Stride: length of next character (Hint: You have to refer to the program, the value is2, 3 or 4 on ly).Star
20、t = 9;Stride = 3;From: Friend To - Voli Coodt No dvcjild thePress anytry choosijng kers3 call to extiractlIkev to continue-121erciseint keylv kej2, hey3, key4; cf)dr * msgi, *;1) Write dow n the address of dummy名稱1值I呂 &durnm#0x0012ff7c,you have to set a break point beside keyl, F9 and Execute de
21、bug so that theprogram goes through the first few lin es. Use right click mouse and&dummy (&mea ns the address)Press F10 will adva nee the program.It is an in teger: It con sists of4bytes. You can determ ine by check ing thelocatio n of int start, you the n un dersta nd the size.Now dummy co
22、n sists of two parts: stride and start.Write dow n the value of keyl3: The differe nee betwee n dummy andkeyl,Key2: The first byte: startThe sec ond byte: strideThe third and fourth byte can be set to zero.Key2 : 0xstart + Oxstride : 777(第三個與第四個字節(jié)可以任取,在此為方便設(shè)為0)*Key1,Key2 計算過程:start = cLnt)(*(char
23、187;) durnrey); stride = tint>(»(f(char *>* 1);通過以上兩條語句我們可以得知:start是取了 dummy這個整形數(shù)字的第一個字節(jié)上的數(shù)字,stride是取了 dummy這個整形數(shù)字的第二個字節(jié)上的數(shù)字。所以dummy前兩位字節(jié)是0x0309void proces£_kep&12 (int * ke1, int # ke2) <*(int *) (key1 卄)= *key2;通過傳入的Key1,Key2,要使得dummy前兩位字節(jié)是0x0309。如此key2的值是后兩位字 節(jié)為0x0309的任意整形數(shù)
24、字。S ftkeyl0x0012ff7O田 &d u0»90l2fF7c田 &key20X0012fF6CKey1 + *Key1 需要為 dummy的地址:0x0012ff7c,key的地址為 0x0012ff70 。 0 與 c 相差 3個字節(jié),所以key為3.*2) Now select the project: sett ing, you will see the followi ng scree nEnter the value of key1 and key2 that you have determined and execute, you will g
25、et :Appe ndix:Please note that you don'n eed to modify any program, but to un dersta nd how to en ter the keys.You can extract and pile the program:#i nclude <stdio.h>#in clude <stdlib.h> int prologue = 0x5920453A, 0x54756F0A, 0x6F6F470A, 0x21643A6F,0x6E617920, 0x680A6474,0x6F697661,
26、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
27、 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, 0x756563
28、6F, 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,
29、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, 0x656
30、17276, 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,
31、 0x74206C6F, 0x2C336573, 0x7420346E,0x20216F74, 0x726F5966, 0x20206F74,0x74786565, 0x65617276, 0x32727463 ;char message100;void usage_a nd_exit(char * program, name) fprin tf(stderr, "USAGE: %s key1 key2 key3 key4n", program, name);exit(1);void process_keys12 (int * keyl, int * key2) *(i nt *) (key1 + *key1) = *key2;void process_keys34 (int * key3, int * key4) *(i nt *)& key3) + *key3) += *key4;char * extract_message1(i nt start, int stride) int i, j, k;int done = 0;for (i = 0, j = start + 1; ! don e; j+) for (k = 1; k < stride; k+, j+,
溫馨提示
- 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)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- R-YNT-3708-生命科學(xué)試劑-MCE-1793
- N-Butyl-Pentedrone-hydrochloride-生命科學(xué)試劑-MCE-8255
- Homarylamine-hydrochloride-生命科學(xué)試劑-MCE-8287
- 2025年度員工股份分配與業(yè)績考核協(xié)議
- 二零二五年度離婚財產(chǎn)協(xié)議-房產(chǎn)車輛資產(chǎn)分配
- 2025年度車輛外借責(zé)任免除及事故賠償協(xié)議
- 2025年度研學(xué)旅行文化體驗合同
- 二零二五年度炊事員餐飲業(yè)未來趨勢預(yù)測聘用合同
- 2025年度蛋糕店線上線下銷售渠道拓展合同
- 施工現(xiàn)場施工防生物災(zāi)害威脅制度
- 行政事業(yè)單位國有資產(chǎn)管理辦法
- 六年級口算訓(xùn)練每日100道
- 高一生物生物必修一全冊考試題帶答題紙答案
- 北師大版五年級上冊四則混合運算100道及答案
- 人教部編版道德與法治八年級下冊:6.3 《國家行政機關(guān)》說課稿1
- 2024山東能源集團中級人才庫選拔(高頻重點提升專題訓(xùn)練)共500題附帶答案詳解
- 鋼鐵是怎樣煉成的讀后感作文700字
- 武漢市江夏區(qū)2022-2023學(xué)年七年級上學(xué)期期末數(shù)學(xué)試卷【帶答案】-109
- 學(xué)校物業(yè)服務(wù)合同范本專業(yè)版
- SL 288-2014 水利工程施工監(jiān)理規(guī)范
- 部編版八年級語文上冊期末考試卷
評論
0/150
提交評論