Writing binary files: a tutorial in C and Python (security@cambridge screencast)

preview_player
Показать описание
A tutorial on writing binary files in C and Python, as a complement to my security course.
While I hope it will be helpful, is not an official lecture in the course.

00:00 Introduction
04:21 exercise 0 (also discussing line endings, viewing binary files etc)
17:47 exercise 1 (in C, also discussing size of ints, little-endian and big-endian)
32:48 exercise 2 (in C)
38:32 exercise 3 (in C)
44:48 exercise 4 (in C)
50:45 self-test (in C)
1:05:18 exercise 1 (in Python)
1:11:01 exercise 2 (in Python)
1:13:42 exercise 3 (in Python)
1:16:02 exercise 4 (in Python)
1:22:20 self-test (in Python)
1:29:49 Python one-liners

This is a leisurely-paced tutorial on writing binary files. This is a basic skill that all of you should possess before attending my forthcoming Security course. If you are able to complete the self-test below without difficulty, then you don't need to watch this video. I'll be using C and Python but feel free use any other tool you like.

Exercise 0
Write the characters of the string "Hello world" to a file.

Exercise 1
Write 1984 to a binary file as a C short int, then as a regular int, and as long int.

Exercise 2
Write -1984 and 1984 to a binary file as short, int and long.

Exercise 3
Write to a binary file the numbers from -10 to 10, first as signed shorts and then as signed longs. How long will the file be?

Exercise 4
Write a 128-byte binary file containing
At offset 96: the dotted quad 192.168.0.1 as 4-byte big-endian
Everywhere else: the byte 42

Self-test
Write a 537-byte-long binary file, containing
At byte offset 192: little-endian 64-bit repr of 3735928559;
At every offset divisible by 128: big-endian 32-bit repr of 3735928559;
At every other offset i (in 0..536): the byte (i + 100) mod 256

My security course playlist: (forthcoming)
Рекомендации по теме
Комментарии
Автор

Great video Professor. This is a useful video. As I told I know C++ and want to learn this C++ purely, I want a video on C++.Can you make a video on that about more complex and other hard functions of C++?

aimaanaltahmid
Автор

Dr Frank, it would be really really helpful for all of your audiences who are prospective applicants to Cambridge BA Computer Science, IF you make a detailed video on A level subject choices for Computer Science at Cambridge.Cambridge websites have informations, but a video whould solve all things where you tell about selecting A level subjects for Computer Science at university.Because many students have many interests and wants to do many A levels but schools let only do 3 or 4 .So, if you make a video, it would be the most helpful thing because every year students have to select their A level subject choices after GCSEs for Computer Science at Uni. So, your guide would be the most helpful thing

natural-
Автор

Hi. Good work. I am intermediate in python. Would learning Java be a complementary skill to python for 2022? Please let me know.

univuniveral
Автор

Dr Frank, I have an important question.Why Do Not every Cambridge college use CSAT?Why only 4 or 5 college use CSAT for Computer Science admission? It should be used by all colleges for CompSci bcz CSAT is really the Best indication how great and talented an applicant is.Also CSAT is the best prediction of how great Computer Scientist an applicant would be.Would it be used by all colleges in future?

natural-