'< l<E 6WEEK·EXAM

advertisement
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
6WEEK·EXAM
l<E '<
NAME:
ALPHA:
This is individual work
1.
2.
3.
4.
SHOW ALL WORK!
Write legibly to receive credit.
Turn in your equation sheet.
ASCII Table for Printable Characters
Dec Hex Char
32
33
34
35
36
37
38
39
40
41
42
20
21
22
23
24
2S
2G
27
28
29
2a
.
!
f
$
\
•
(
.
)
Dec Hex Char
43
44
45
46
47
48
49
Zb
2c
2d
2e
2f
30
31
32
33
34
35
so
51
52
53
+
I
0
1
2
3
4
5
Dec Hex Char
54
55
5G
S7
S8
59
60
Gl
62
63
64
3G
37
38
39
3a
3b
3c
3d
3e
3f
40
6
7
8
9
'
;
<
Dec Hex Char
G5
GG
67
68
69
70
71
=
72
>
73
74
75
?
@
41
42
43
44
45
46
47
48
49
4a
4b
A
B
c
D
E
E'
G
H
I
J
"
Dec Hex Char
7G 4c L
4d M
77
78
4e N
79
4£ 0
80 50 p
Bl
51 Q
82 S2
R
83 53 s
84
S4 T
85 55 u
86 56 v
Dec Hex Char
B7
BB
89
90
91
92
93
94
95
96
97
57
5B
S9
Sa
Sb
Sc
Sd
Se
Sf
60
61
"x
y
z
[
\
)
"
7
a
Dec f!ex Char
9B
62 b
99 G3 c
100 64 d
101
6S e
102 66 £
103
G7 g
104
GB h
105
GS i
106
Ga
j
107 6b k
108 6c l
Dec Hex Char
109
Gd m
110
111
112
113
114
115
116
117
118
115
Ge
6f
70
71
72
73
74
7S
76
77
n
0
p
.
q
r
t
u
Dec Hex Char
120
121
122
123
124
125
126
7B
79
7a
7b
7c
7d
7e
x
y
z
(
I
)
-
v
.,
7
8
9
a
b
c
d
e
f
hex digit 0
1
2
3
4
5
6
4-bit pattern 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Question
Points
2
17
2
10
2
18
4
2
11
4
19
2
4
2
12
4
20
2
5
3
13
4
21
2
6
6
14
2
22
4
7
13
15
6
8
2
16
4
Total
76
Question
Points
1
Score
Question
Points
2
9
2
2
3
Score
Score
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
Lesson 1- Computer System Review
1. ( 2pts) The address Ox080483ac is written in _____ notation and represents
_ _ _ _ _ _bits.
a. Binary, 8
b. Decimal, 8
c. Decimal, 32
d. Hexadecimal, 8
Hexadecimal, 32
@
2.
(2ptsJ Looking for characters, you type the command x/xb Ox08048a9b and it returns
Ox56. If the memory located at the address Ox08048a9b is in fact a character, what
character does it represent?
V
3. (2pts) Registers are located in a computer's
a. main memory
lli) CPU
c. hard disk drive.
d. power supply
4. (2pts)Draw the schematic symbol for a transistor and a diode.
Transistor
Diode
Lesson 2: C Programming; Digital Logic
5. ( 3 pts) Fill in the table below with the amount of memory each data type requires. Express
your answers in terms of both bytes and bits.
Data Type
An integer variable (int)
A floating point variable (float)
A character variable (char)
Number of Bytes
Number of Bits
L'f
:, 2.
li
-s l.
\
Cb
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
6.
(6pts) Complete the truth table for the given logic circuit. X and Y represent two intermediate
values and Z represents the output of the circuit.
A
B
C
z
--A..
z
A
0
B
0
c
x
y
0
0
0
0
0
0
1
0
b
b
\
0
1
0
\
0
\
\
0
1
1
\
l
\
\)
1
0
0
b
0
0
0
1
0
1
\)
()
0
0
1
1
0
0
()
0
u
1
1
1
Q
\
l
\
7.
Circuit Truth Table
(13pts)Match the term on the left with its appropriate description on the right:
lo =
~ the format string for an integer value
~ high level language
V.
£ seanf
.C. program which allows the debug of machine code
_I gee
;Y. translates assembly language into machine language
J..
tt:
.
machine language
the C assignment operator
allows the use of functions from various header files
d
assembler
e..
#include <.. >
Y. allows the program to receive keyboard input
y. the C escape sequence for a new line
Ir. the C programming language
assembly language
%.' program that converts source code to object code
%d
j.
_J_ nano
M
°"
~
printf
~ \n
~ gdb
a UNIX text editor, can be used to write C programs
X. function which displays text to the monitor
.J: instructions expressed as bits, also called object code
Jl'l. English-like words that represent machine code
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
Lesson 3 - Registers and Memory
8. (2pts)
eip is a
a.
b.
c.
d.
e.
([)
9. (2pts)
a.
b.
c.
@
e.
f.
10. (2pts)
a.
b.
c.
d.
Q
f.
that points to the _ _ _ _ _ _.
location in RAM, top of the stack
location in RAM, bottom of the stack
location in RAM, next instruction to be executed
register, top of the stack
register, bottom of the stack
register, next instruction to be executed
esp is a
that points to the _ _ _ _ __
location in RAM, top of the stack
location in RAM, bottom of the stack
location in RAM, next instruction to be executed
register, top of the. stack
register, bottom of the stack
register, next instruction to be executed
ebp is a
that points to the _ _ _ _ __
location in RAM, top of the stack
location in RAM, bottom of the stack
location in RAM, next instruction to be executed
register, top of the stack
register, bottom of the stack
register, next instruction to be executed
0x080483b4
0x080483b5
0x080483b7
0x080483ba
Ox080483bd
0x080483c2
Ox080483c4
Ox080483cc
Ox080483cf
Ox080483d2
Ox080483d7
Ox080483da
Ox080483dd
Ox080483e2
Ox080483e3
<main+O>:
<main+l>:
<main+3>:
<main+6>:
<main+9>:
<main+l4>:
<main+l6>:
<main+24>:
<main+27>:
<main+30>:
<main+35>:
<main+38>
<main+41>
<main+46>
<main+47>
push
mov
sub
and
mov
sub
mov
lea
mov
call
lea
mov
call
leave
ret
ebp
ebp,esp
esp,0x38
esp, Oxfffffff0
eax,0x0
esp,eax
DWORD PTR [esp+4],0x80484c4
eax,[ebp-40]
D\'/ORD PTR [esp],eax
Ox80482c4 <strcpy@plt>
eax, [ ebp- 40]
DWORD PTR [esp],eax
Ox80482d4 <printf@plt>
11.(4pts)
a. (2 pts)What type oflanguage is depicted in the screenshot above?
4s s~b\y
'-ct""~"'-°'~ e.
b. (2 pts)Describe what the line of code at address Ox080483c4 accomplishes .
.::cEfz::
l t)-\o
lo 'f
,NtO <./
t-Vte..-
~j
+"'- Q_
M.~o ry
[e_sp +~]
-
v
D\. l l.\.e!_
loc..c,,t1',:11
0 '{. cg 0 'i ~ '1
~0<·11.t~d
fo
c.. ~
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
12. (4 pts )Recall that in RAM you have stored the object code for your program as well as
additional memory allocated for your variables within the program.
You type into the debugger the command i r ebp and get the result Oxbffff7e8.
Upon further review of the assembly code you determine that a string is stored in
memory [ebp-12]. What is the string?
() \ d
String: _ _ _ _ _ _ _ _ __
8xbffft7c0:
Oxbffff7cB:
0xbffH7dG:
Ox ft
Ox ff
Ox77
Oxbt
Ox bf
Ox20
Ox20
Ox20
0x4f
Oxb7
Ox9c
Oxf:S
Ox41
Oxfcl
Ox ff
Ox ff
€1x00
OX0'0
Ox.Ge
Oxf8
OxG0
OxH
Ox00
0xd0
0xd8
0xf7
O:>tf7
Ox4e
8x6S
Ox00
Ox20
£1x5f
Ox.bffff7d8:
0xbHH7e0:
ox2e
Oxbffft7~6;
0>\08
0>:Mftf7f0:
8xbffff7f8:
8xMfff800:
Ox!bffff80B:
Ox00
Oxe0
8x68
exbffff810:
,,.....
OxOl
Dxb0
oxoe
O;<bt
8xb7
0x00
Ox.Ml
0xbf
exeo
Oxc4
Ox84
Ox04
Ox91
Ox20
tlx82
Ox04
ex0a
exw
flx2e
ex.20
0x6c
0xf8
0x64
Ox GO
OxH
e~:Sf
Oxf d
0xl:.rf
Oxb7
Ox80
Ox84
0xf 4
0x5f
Oxf 4
OxOO
Ox84
Oi<bC
Oxee
flx04
E:ixfd
0x04
0xea
Ox94
OxfS
Ox ff
0x08
0x08
0xbJ
0x08
Oxb7
ex bf
Lesson 4 - Arrays
13. (4 pts) Use the array declaration to answer the questions.
float voltages[6]={ 0.4, 0.75, 1.23, 2.1, 3.1, 4.2};
l{
'f
b
a.(2 pts) How many bytes are allocated for this array?
J~
b.(2 pts) What value is stored in voltages [ 5]?
L-/,~
Lesson 5 - Strings and Pointers
14. (2pts)Given the following declarations, what would be the C statement to assign ptr_Data
the address of integer Data? (Circle the correct answer)
int
int
Data;
*ptr_Data;
a) *ptr_Data = &Data;
b) &ptr Data = &Data;
(§})ptr_Data = &Data;
d) ptr_Data = Data;
e) &ptr Data = *Data;
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
Lesson 6 - Functions and the Stack
15. (6pts)Given the following C statements and memory map below, what would be the result
of the printf statement?
int a = 11;
int b[2] = {20,12};
printf("The address of array bis %x \n", b);
Address
Data
Address
(continued)
Data
OxBFFFF8FO
OxBFFFF8F1
OxBFFFF8F2
OxBFFFF8F3
OxBFFFF8F4
OxBFFFF8FS
OxBFFFF8F6
OxBFFFF8F7
OxBFFFF8F8
OxBFFFF8F9
aO
OxBFFFF8FA
OxBFFFFSFB
OxBFFFF8FC
OxBFFFFSFD
OxBFFFFSFE
OxBFFFFSFF
OxBFFFF900
OxBFFFF901
OxBFFFF902
OxBFFFF903
00
00
Oc
00
00
00
eO
Oc
00
b8
84
04
08
f8
f8
ff
bf
14
00
16. (4pts) Will the following C source code compile without error? If not, explain why. If so,
describe what output the program will produce.
#include<stdio.h>
void sum( int x, int y ,int z)
{
int total;
total = x + y + z;
printf("\nThe total of the numbers is: %d\n\n",total);
}
int main()
{
int num1=7, num2=1, num3=9;
sum( num2 ,num3 );
}
b ~C.G\.<"-..Se..
.\-wo
·t"S
1
+"e.
'l r
eq_
~ '1""' ~ t'""\ t .J
If
A<L-.f,·ri,·+.~,,.
f-o
W
f~,'?.({ ;~:, 5 "'""
~/ l c..
~
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
Lesson 7 - Buffer Overflow Introduction
17. (2pts)What feature of the C language makes a buffer overflow attack possible?
a. C has a garbage collector
b. C performs automatic bounds checking
(E) C does not perform automatic bounds checking
d. C allows you to access registers
18. (4pts )When the printout function is called in main from the following code sample, the
stack pictured below is created.
#include<stdio.h>
void printout()
int j;
char input_string[lO];
printf ("Input a string: ");
scanf ("%s", input_string);
for(j=O; j < 10; j=j+l)
{
printf ("%s\n",input_string);
int main ()
printout ()
}
Assume there is no padding (i.e. extra bytes in
between variables) when the frame is created.
What is the largest number of characters the
user can enter without overwriting any portion
of the return address?
Show all assumptions and work
l i - l Jor "-"'-'\ \
4-... 11
c;;\,,...r .. clef5
c..""-1\ra.c. \-u
]
EC312: Cyberphsical Engineering- Host section
Exam #1; Monday 02/10/2014
19. (2pts)Supposeausertypes./a.out "Go Navy" 6 "cyber2"atthecommandline.
What will be the value of argc?.
a. 3
(94
5
d. None of the above.
c.
Lesson 8 - File I/O and Permissions
20. (2pt)In which direction does the heap grow?
a. From the bottom (larger memory address) up (to a smaller memory address).
@From the top (smaller memory address) down (to a larger memory address).
c. It depends on the corresponding number and types of variables currently
allocated on the stack.
d. It depends on the prolonged effects of solar and liquescent additives combined
with the chemical makeup of the heap.
21. (2pt) Suppose we run a program that allocates 10 bytes ofram and assigns it to a pointer
using the command shown
ptr=(char *) malloc ( 10 );
What is a possible value for ptr after executing the command given the value of the instruction
pointer and stack pointer are:
eip=Ox0804848a
esp=Oxbffff7c0
a. Ox08048000
Ox0804fff0
c. Oxbffff7d0
d. none of the above
(§)
Lesson 9 - Privilege Management
22. (4pts)Looking at the long listing of the files below.
! -rw-r--r-- 1 root
root
0 2014-02-07
-rw------- 1 instructor midshipman 166 2014-02-05
drwx------ 2 midshipman midshipman 4096 2014-02-05
-rwsr-xr-x 1 root
midshipman
95 2014-02-07
a. ( 2pts) Who is the owner of the notes file?
10:27
17:26
17:27
10:28
northside
notes
orbit-midshipman
providence.exe
t I\ s-t ru. c..-to r
b.
( 2pts) What permissions do other users have for the notes file?
Download