# HTB-Nuclear Sale

رايت اب جديد  🥳&#x20;

وصف التحدي:

Plutonium Labs is a private laboratory experimenting with plutonium products. A huge sale is going to take place and our intelligence agency is interested in learning more about it. We have managed to intercept the traffic of their mail server. Can you find anything interesting?

و حملت الملف طلع pcap file&#x20;

تصفحت الملف  وزي ما هو واضح قدامكم هو mail server

![](https://1018683601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgMOjn0eyQocnVEQnPMtO%2Fuploads%2FfRA4qdPYA2Jv5CaWcTWJ%2FScreen%20Shot%201443-12-20%20at%201.04.26%20AM.png?alt=media\&token=4e014e43-e301-4533-9ca7-87d1d05bd4b4)

* mail server نعرف انه يستخدم بروتوكول SMTP

SMTP: Simple Mail Transfer Protocol

نقاط مهمة لازم نعرفها عن البروتوكول

we know that SMTP easily readable by eavesdroppers.&#x20;

* سهل انه ينقرأ بحكم أنه يظهر كـ plain text and ASCII وهذا يسمح للمخترقين أن يتنصتون على الtraffic

STEP 1 :

المهم نبدأ الخطوة الأولى شفت البروتوكولز كلها SMTP فقلت أبد بسوي follow TCP stream و نشوف شالسالفة

![Hint: XOR](https://1018683601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgMOjn0eyQocnVEQnPMtO%2Fuploads%2FYnzQJKknWzXUHOBhJHTG%2FScreen%20Shot%201443-12-20%20at%201.10.25%20AM.png?alt=media\&token=a8775665-9d0b-4d08-ac5b-e8841d77efa7)

💡 hint ->

حلو طلع لنا في stream 1 دليل على أن العملية XOR

STEP 2: collect data &#x20;

Stream 2 و اعطانا في:&#x20;

He is a high profile individual. His ***information is encrypted below***:

6b65813f4fe991efe2042f79988a3b2f2559d358e55f2fa373e53b1965b5bb2b175cf039

<mark style="color:blue;">Message (XOR) key</mark> = C

Stream 3 و في:&#x20;

*<mark style="color:orange;">**ciphertext 1 (C1)**</mark>* encrypted with our key.

fd034c32294bfa6ab44a28892e75c4f24d8e71b41cfb9a81a634b90e6238443a813a3d34&#x20;

<mark style="background-color:yellow;">(</mark><mark style="background-color:yellow;"><mark style="color:blue;">Message (XOR) key<mark style="color:blue;"></mark><mark style="background-color:yellow;">) (XOR) key1(our key)</mark> = C1

Stream 4 و في:&#x20;

&#x20;*<mark style="color:orange;">**ِ**</mark>*&#x45;ncrypted with our key..

de328f76159108f7653a5883decb8dec06b0fd9bc8d0dd7dade1f04836b8a07da20bfe70

(<mark style="color:blue;">Message</mark>) (XOR) <mark style="color:green;">key1</mark>(our key) = C2

STEP 4: Analysis

بعد

two cipher encrypted with the same key? interesting&#x20;

تذكروا نظرية فيثاغورس .. عندنا متغيرين شلون نطلع الثالث 😜

* STEP 1:
* if we <mark style="background-color:yellow;">(</mark>~~<mark style="background-color:yellow;"><mark style="color:blue;">Message<mark style="color:blue;"></mark>~~ <mark style="background-color:yellow;"><mark style="color:blue;"> </mark><mark style="background-color:yellow;"><mark style="color:blue;">(XOR)<mark style="color:blue;"></mark> <mark style="background-color:yellow;"><mark style="color:blue;"> </mark>~~<mark style="background-color:yellow;"><mark style="color:blue;">key<mark style="color:blue;"></mark>~~<mark style="background-color:yellow;">) (XOR) key1(our key)</mark>(XOR) ~~<mark style="color:blue;">Message</mark>~~ <mark style="color:blue;"></mark><mark style="color:blue;">(XOR)</mark> <mark style="color:blue;"></mark>~~<mark style="color:blue;">key</mark>~~  since -> Message and key will be cancelled then the output will be -> <mark style="color:green;">key1</mark>&#x20;
* STEP 2:
* Then if  (<mark style="color:blue;">Message</mark>) (XOR) <mark style="color:green;">key1</mark>(our key) (XOR) with <mark style="color:green;">Key1</mark>(our key) \[output from STEP1] then -> Key 1 will be cancelled and the output will be -> <mark style="color:blue;">message</mark>.&#x20;

STEP 5: Coding phase

طيب لازم نبرمج استخدمت بايثون عشان نطلع المسج&#x20;

my code

{% tabs %}
{% tab title="code.py" %}

```
from binascii import unhexlify

# Convert hex to Bytes using unhexlify library
Message = unhexlify('6b65813f4fe991efe2042f79988a3b2f2559d358e55f2fa373e53b1965b5bb2b175cf039')
print(Message)

C1 =  unhexlify('fd034c32294bfa6ab44a28892e75c4f24d8e71b41cfb9a81a634b90e6238443a813a3d34')
print(C1)

C2 =  unhexlify('de328f76159108f7653a5883decb8dec06b0fd9bc8d0dd7dade1f04836b8a07da20bfe70')
print(C2)

STEP1 = []
FLAG = []
# STEP 1
for i in range(len(Message)):
	STEP1.append(Message[i] ^ C1[i])
print(bytes(STEP1))

# STEP 2
for i in range(len(Message)):
	FLAG.append(STEP1[i] ^ C2[i])

print("\n Final answer is: ")
print(bytes(FLAG))b'ke\x81?O\xe9\x91\xef\xe2\x04/y\x98\x8a;/%Y\xd3X\xe5_/\xa3s\xe5;\x19e\xb5\xbb+\x17\\xf09' b'\xfd\x03L2)K\xfaj\xb4J(\x89.u\xc4\xf2M\x8eq\xb4\x1c\xfb\x9a\x81\xa64\xb9\x0eb8D:\x81:=4' b'\xde2\x8fv\x15\x91\x08\xf7e:X\x83\xde\xcb\x8d\xec\x06\xb0\xfd\x9b\xc8\xd0\xdd}\xad\xe1\xf0H6\xb8\xa0}\xa2\x0b\xfep' b'\x96f\xcd\rf\xa2k\x85VN\x07\xf0\xb6\xff\xff\xddh\xd7\xa2\xec\xf9\xa4\xb5"\xd5\xd1\x82\x17\x07\x8d\xff\x11\x96f\xcd\r'
```

{% endtab %}

{% tab title="output" %}
b'ke\x81?O\xe9\x91\xef\xe2\x04/y\x98\x8a;/%Y\xd3X\xe5\_/\xa3s\xe5;\x19e\xb5\xbb+\x17\\\xf09' b'\xfd\x03L2)K\xfaj\xb4J(\x89.u\xc4\xf2M\x8eq\xb4\x1c\xfb\x9a\x81\xa64\xb9\x0eb8D:\x81:=4' b'\xde2\x8fv\x15\x91\x08\xf7e:X\x83\xde\xcb\x8d\xec\x06\xb0\xfd\x9b\xc8\xd0\xdd}\xad\xe1\xf0H6\xb8\xa0}\xa2\x0b\xfep' b'\x96f\xcd\rf\xa2k\x85VN\x07\xf0\xb6\xff\xff\xddh\xd7\xa2\xec\xf9\xa4\xb5"\xd5\xd1\x82\x17\x07\x8d\xff\x11\x96f\xcd\r'

`Final answer is: b'HTB{s3cr3t_*****************_l4m3}'`
{% endtab %}
{% endtabs %}

&#x20;أنا وضحت الخطوات أكيد فيه اختصارات و كود أسهل و ممكن تستخدمون cyberchef&#x20;

مهما تعددت الطرق الحل واحد اختاروا اللي تبونه مع الوقت أكيد بنتطور 👌🏻

&#x20;

استمتعت و أنا آحل بحكم أني استرجعت كم معلومة وقبل الختام نشكر قوقل 👍🏻&#x20;

![](https://thumbs.gfycat.com/CheapFeistyDassierat-size_restricted.gif)
