Kita akan menggunakan bantuan python untuk mengerjakan soal ini. Berikut script sederhana yang dapat kita gunakan. from Crypto.Cipher import AEScomputeRSA RSA encryption/decryption is based on a formula that anyone can find and use, as long as they know the values to plug in. Given the encrypted number 150815, d = 1941, and N = 435979, what is the decrypted number?
Write-up: Persamaan di hints tampaknya cukup sederhana, namun berikut ini adalah hasil yang didapat bila menggunakan kalkulator di sistem operasi Windows: Hasil di MS Excel: Persamaan enkripsi dan dekripsi algoritma RSA sebenarnya terbilang cukup sederhana. Problemnya adalah angka yang digunakan itu terlalu besar, sehingga akan sulit dilakukan perhitunganya apabila menggunakan teknik coba-coba misalnya (brute force). Dalam kasus RSA, kita memiliki pasangan kunci privat dan pasangan kunci publik.
Apabila kita hendak mengirimkan pesan rahasia ke X, maka kita akan mengunci pesan kita dengan kunci publik milik X. Kemudian hanya X saja yang memiliki kunci privat yang dapat membaca pesan tersebut. Kasus lain yang bisa digunakan oleh algoritma kunci asimetris seperti RSA ini adalah untuk proses tanda tangan digital. Skemanya adalah pesan kita kunci dengan kunci privat milik kita. Untuk membuka pesan ini, maka dibutuhkan kunci publik milik kita. Oleh karena itu, orang lain dapat memverifikasi bahwa pesan ini berasal dari kita dengan cara mendekripsi pesan ini dengan kunci publik milik kita. What will u do?? Try it in python! Kalau kita coba operasi pangkatnya saja dulu, begini hasilnya… Angka pada gambar diatas itu belum selesai ya, masih ada angka2 lagi dibawahnya :v Selanjutnya untuk menghitung nilai Plaintext kita bisa langsung menggunakan persamaan berikut di python: >>> P = pow (150815,1941)%435979 Hash101Prove your knowledge of hashes and claim a flag as your prize! Connect to the service at shell2017.picoctf.com:17428
Write-up: Untuk mengerjakan soal ini, kita bisa memanfaatkan netcat dengan webshell yang tersedia di website pico ctf. Some time ago, a dear friend of mine came up to me and asked about the Python module binascii – particularly about the methods 1 and 2. Since he asked for it, I’m going to share my answer publicly with you.First of all, I’m defining the used nomenclature:
First, let me quote the documentation:
I’ll begin with 1. As the documentation states, this method splits a string which consists of hex-tuples into distinct bytes.The ASCII character ‘A’ has 65L as numerical representation. To verify this in Python:
You might ask “Why is this even relevant to understand binascii?” Well, we don’t know anything about how ord() does its job. But with binascii we can re-calculate manually and verify.
Now we know that an ‘A’ – interpreted as binary data and shown in hex – resembles ’41’. But wait, ’41’ is a string and no hex value! That’s no biggy, 1 represents its result as string.To stay with the example, let’s convert 41 into a decimal number and check if it equals 65L.
Tada! It seems that ‘A’ = 41 = 65L. You might have known that already, but please, stay with me a minute longer. To make it look a little more complex:
Be aware that 5 converts a decimal number 6 into its hex representation. 7 naturally does the same thing as 1, but in reverse. It takes binary data and displays it in tuples of hex-values.I’ll start off with an example:
Here, 2 takes the numerical representation 65L from the ASCII character ‘A’
converts it into hex 41
and represents it as a 1-tuple (meaning dimension of one) of hex values. And now the conclusio – why might all of this be useful? Right now, I can think of at least four use cases:
Taking up the last example, I’ll show you how to visualize the Bell escape sequence (you know, that thing that keeps beeping in your terminal). Taken from the ASCII table, the numerical representation of the Bell is 7. Programmers might know it better as 0.
Presuming you read such a character in some kind of binary data – for example from a socket and you want to visualize this data with 1, you will not get any results – at least none visible. You might hear the Bell sound if you’re not on a silent terminal. |