首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP 3334代做、代写Python语言编程
项目预算:
开发周期:
发布时间:
要求地区:
The Hong Kong Polytechnic University
COMP 3334 – Computer Systems Security (Semester 2, 2024)
Assignment
This is an individual assignment. You may use the course material and Internet resources to answer
the questions. However, you should not post the questions online and ask for help. Discussion
among your peers is encouraged; however, you must produce answers by yourself and in your own
words. Any suspicion of plagiarism will be thoroughly investigated. Copying answers from GenAI
tools into your assignment is a form of plagiarism. This assignment is due on Sunday, 17 March
2024, 23:59.
Late submissions will be subjected to a 15% penalty per day, starting at 00:01.
Total: 100 points. Course weight: 10%.
Submission requirements
Submit on Blackboard a single ZIP file containing:
1. A PDF file named as comp3334-studentid.pdf for your written answers. Change “studentid” with
your actual student ID. The file must also include your name and student ID on the first page.
2. The three Python files as requested in the exercises below: exercise{1,3,4}.py.
Double check your submission. Any incorrect submission format may result in a zero mark for this
assignment.
Exercise 1: Misusing AES [30 pts]
A website authenticates its users by asking for a login/password, and sends them a cookie C, valid
for one minute, to keep track of their authentication status. The cookie C is formed such as C =
Enc("user=username,tmstmp=timestamp"), with username = "anonymous" for unauthenticated users,
or the name of the user when authenticated; and timestamp is a Unix-formated timestamp1
representing
the time up to which the user is authenticated (current time plus one minute). Enc(·) designates the
AES256 encryption in OFB-mode using iv as a random IV and k as a random key; both k and iv are
unknown to us. The OFB mode of operation for encryption is described in Figure 1.
In this exercise, we consider cookies delivered on February 1st, 2024 at 00:00am UTC. At that time,
an unauthenticated user coming to the website will receive a cookie:
CU = AES256-OFBk,iv("user=anonymous,tmstmp=1706745660")
The value 1706745660 corresponds to 00:01am on February 1st. We denote by PU the plaintext version
of the cookie.
a) Give the plaintext cookie, denoted PA, that corresponds to the authenticated admin user if he
logged in at the same time. Compare the length of PA and PU . [3 pts]
b) Describe how to modify the cookie CU into CA = AES256-OFBk,iv(PA) without knowing k nor
iv. You may rethink about the value of PA so that PU and PA have the same length. Note that
the cookie may authenticate the user admin for as long as you want (but at least the original one
minute duration). [7 pts]
c) Implement in Python the attack that would turn CU into a valid CA for at least the original duration.
Prepare a single Python file named exercise1.py that contains a function modifycookie() that
takes as argument a base64-encoded cookie and returns the base64-encoded modified cookie. Your
attack should work for different timestamps. You will get full marks if, given an encrypted cookie
1https://www.epochconverter.com/
1
block cipher
encryption Key
Ciphertext
Initialization Vector (IV)
block cipher
encryption Key
Ciphertext
block cipher
encryption Key
Ciphertext
Plaintext Plaintext Plaintext
Figure 1: Output Feedback (OFB) mode of operation (during encryption)
issued at any later date than February 1st this year, you are able to turn this cookie into a valid
admin cookie for at least the original duration. Make sure your code uses meaningful variable
names, consistent indenting scheme, and comments. [20 pts]
Exercise 2: Lan Manager hash [20 pts]
Back in the days, up to Windows XP, Windows account passwords were hashed using Microsoft’s LAN
Manager (LM) hash function, which works as follows:
Step 1 The password is converted into upper case, null-padded to 14 characters (or truncated to
14 characters), and split into two 7-character halves.
Step 2 Each half is separately converted into a DES key. This key is used to encrypt the ASCII
string “KGS!@#$%”, producing an 8-byte value.
Step 3 The two 8-byte values are concatenated, resulting in a 16-byte hash.
1. Suppose the attacker obtains a file with N hashed passwords. How much work would he need to do,
at most, to crack these passwords by brute-force search? Show your calculations. Express the result
in scientific notation (m × 10n, m ∈ R < 10, n ∈ N), and round it to two decimals. Assume that
users could type any of the 95 printable characters found on a US keyboard i.e., letters, numbers,
symbols, and punctuation marks, which are represented by codes 32 to 126 in the ASCII table.
Passwords could be any length. [15 pts]
2. Knowing that a single modern NVIDIA GeForce RTX 4090 GPU can perform 151.1 GH/s for LM,2
how long would it take an attacker with one such GPU to crack these N hashes? Assume that the
overhead of matching a 64-bit string in a list of 2N 64-bit strings is negligible. [5 pts]
Exercise 3: PKCS#7 padding [20 pts]
The PKCS#7 padding scheme is commonly used to pad irregularly-sized plaintext messages to a specific
block length before encryption, and is described in RFC5652. The algorithm simply consists in appending
the required number of bytes up to nearest multiple of the block length. The value of each appended byte
is equal to the number of bytes added. The maximum length of the pad is therefore 255. If the plaintext
size is already a multiple of the block length, padding is still required. In this case, an entire block
of padding bytes will be used. To remove the padding after decryption, the last byte of the decrypted
ciphertext is read, which indicates how many bytes (of the same value) should be stripped from the end.
For this exercise, do NOT use any library/package in your code.
1. Write a function pkcs(plaintext, length) in Python that takes a plaintext (plaintext) and a
desired block length (length) as input and applies the PKCS#7 padding scheme. The function
should return the padded input. An exception should be thrown if the block length is greater than
the maximum pad length, using: raise Exception("Invalid block size")
For instance, for the message "YELLOW SUBMARINE" and a block size of 20, the output should be
"YELLOW SUBMARINE\x04\x04\x04\x04". [5 pts]
2See Hashcat benchmark here: https://gist.github.com/Chick3nman/32e662a5bb63bc4f51b847bb422222fd
2
2. Write a function validate pkcs(plaintext, length) in Python that verifies the validity of the
padding, and returns an unpadded string. The function should throw exceptions using raise
Exception("Invalid padding") when: 1) the length of the plaintext indicates that no padding
has been used; 2) the value for the pad length is incompatible with the block length; 3) the value
of the padding bytes is incorrect. [15 pts]
Prepare a single Python file named exercise3.py that contains both functions.
Make sure to use the exact exception messages given above throughout this exercise;
otherwise, your function will not be evaluated properly for assessment.
Exercise 4: Near collisions [30 pts]
Referring to the exercise given in Lecture 4 (slide 23), find a “near collision” on SHA-256 by hashing
values that must contain your student ID. A near collision is defined as a pair of inputs which hash to
values that share the same first n bits. We define n = 34 for this exercise.
One method of finding such collisions is to hash an increasing counter (concatenated to your student
ID) and keep n-bit prefixes in a dictionary. If you encounter a prefix you have already seen, you found a
near collision.
1. Provide a function find near collisions(studentid) that takes as input your student ID as a
string in the format 12345678 (without letter) and outputs a tuple of binary strings (val1, val2) that
are near collisions, and studentid is a substring of each value. Your program should terminate
within one minute on a reasonably modern laptop and with a correct output. [20 pts]
2. Provide a function get values() that returns a tuple of binary strings (val1, val2) that you have
previously computed and that satisfy the above criteria. Simply hardcode those values and return
them. [10 pts]
Example of correct outputs for student ID=12345678: (b‘12345678288576’, b‘12345678335737’).
Prepare a single Python file named exercise4.py that contains both functions.
Questions?
If you need a clarification about an exercise requirements, you can contact the following TA:
Bowen CUI: bowen.cui@connect.polyu.hk
TAs will not tell you whether your approach is correct or not, whether you got the right answer, etc.
3
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!