-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add writeup forensic/2024/Urmia-CTF/catch-me-if-you-can * add writeup forensics/2024/Urmia-CTF/hidden-coordinates
- Loading branch information
1 parent
65808de
commit b84ae2f
Showing
13 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+235 KB
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can-files/1_many_arps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+235 KB
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can-files/2_http.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+704 KB
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can-files/3_follow_http.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+161 KB
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can-files/capture.zip
Binary file not shown.
Binary file added
BIN
+123 KB
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can-files/secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions
76
docs/forensic/writeups/2024/Urmia-CTF/catch-me-if-you-can.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
tags: | ||
- Urmia-CTF | ||
- Urmia-CTF-2024 | ||
- Forensics | ||
- pcap | ||
- cryptography | ||
- wireshark | ||
- HTTP | ||
--- | ||
|
||
|
||
!!! note "توضیحات چلنج" | ||
<div style="text-align: left"> | ||
In the bustling bazaars of ancient Persia, where merchants traded silk and spices, a secret message has been intercepted. Legend has it that this message holds the key to discovering the whereabouts of a hidden treasure deep within the ancient emperor of Persia. However, the message has been cunningly encrypted and is hidden within a sea of network traffic. Can you decode it before the secret slips through your fingers? | ||
</div> | ||
|
||
یک فایل [packet capture](https://en.wikipedia.org/wiki/Pcap) بهمون داده شده که باید فلگ رو از داخلش در بیاریم | ||
![wireshark screen of packet capture with some arp and ssh pdu's](catch-me-if-you-can-files/1_many_arps.png){ style="display: block; margin: 0 auto" } | ||
|
||
|
||
فایل رو اول که باز کردم با خودم گفتم این همه پیام [ARP](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) زیادیه برای یه شبکه، اونم پشت سر هم | ||
|
||
با این که مشکوک بود اول رفتم سراغ پیدا کردن پیام هایی که مخفی نشدن و اگه به جایی نرسیدم برگردم سر ARP | ||
|
||
همیشه اول فیلتر میزنم روی [فلگ پوش TCP](https://datatracker.ietf.org/doc/html/rfc9293#section-3.1-6.14.2.10.1) ببینم پیامی هست که رمز نگاری نشده باشه | ||
![wireshark screen of packet capture with some http and ssh pdu's](catch-me-if-you-can-files/2_http.png){ style="display: block; margin: 0 auto" } | ||
|
||
به نظر میاد چیزی پیدا کردیم | ||
|
||
[http](https://en.wikipedia.org/wiki/HTTP) | ||
نشونه خوبیه | ||
|
||
[follow http stream](https://www.wireshark.org/docs/wsug_html_chunked/ChAdvFollowStreamSection.html) | ||
کردم | ||
![wireshark screen of a reassembled http conversation](catch-me-if-you-can-files/3_follow_http.png){ style="display: block; margin: 0 auto" } | ||
|
||
|
||
به نظر میاد که فایل داخل ریسپانس هستش | ||
|
||
فایل رو که سیو کردم و روش کامند | ||
[file](https://www.man7.org/linux/man-pages/man1/file.1.html) | ||
روی زدم دیدم عکسه | ||
```bash | ||
$file a.png | ||
a.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced | ||
``` | ||
بازش کردم | ||
![a colorful image of vegetables in a bowl with an encrypted message written on the lower right of the iamge ](catch-me-if-you-can-files/secret.png){ width=80%; height: auto; style="display: block; margin: 0 auto" } | ||
|
||
پایین سمت راست عکس نوشته بی معنی میبینیم که اگه به الگوش دقت کنیم متوجه میشیم که احتمالا از [الگوریتم سزار](https://en.wikipedia.org/wiki/Caesar_cipher) استفاده شده برای رمز نگاری این متن | ||
|
||
چون | ||
|
||
۱.حرف اول کلمه ها بزرگه | ||
|
||
۲.شبیه متن عادی هستش که صرفا معنی نمیده به این مظور که چینش و تکرار حروف اشناس | ||
|
||
کلید از ۱ تا ۲۸ سزار رو تست کردم | ||
|
||
و با کلید ۲۲ به متن زیر رسیدم | ||
|
||
Tabriz_Grand_Bazaar | ||
|
||
داخل فرمت | ||
UCTF{} | ||
گذاشتم و قبول شد | ||
|
||
--- | ||
??? success "FLAG :triangular_flag_on_post:" | ||
<div>`UCTF{Tabriz_Grand_Bazaar}`</div> | ||
|
||
!!! نویسنده | ||
[Ali](https://github.com/AliGhaffarian) | ||
|
||
|
Binary file added
BIN
+615 KB
docs/forensic/writeups/2024/Urmia-CTF/hidden-coordinates-files/1_pcap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+588 KB
docs/forensic/writeups/2024/Urmia-CTF/hidden-coordinates-files/2_tcp_push_flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...rensic/writeups/2024/Urmia-CTF/hidden-coordinates-files/3_filter_on_not_tls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+588 KB
docs/forensic/writeups/2024/Urmia-CTF/hidden-coordinates-files/4_icmp_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+589 KB
...ps/2024/Urmia-CTF/hidden-coordinates-files/5_icmp_filtered_standard_payload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
181 changes: 181 additions & 0 deletions
181
docs/forensic/writeups/2024/Urmia-CTF/hidden-coordinates.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
--- | ||
tags: | ||
- Urmia-CTF | ||
- Urmia-CTF-2024 | ||
- Forensics | ||
- pcap | ||
- steganography | ||
- wireshark | ||
- scapy | ||
- ICMP | ||
--- | ||
|
||
|
||
|
||
!!! note "توضیحات چلنج" | ||
<div style="text-align: left"> | ||
Jack Sparrow may be searching for treasure, but he’ll never find the map if he can't decipher the signals. Buried within a seemingly ordinary pcap file are hidden details encoded in ICMP packets. Unearth the secrets concealed in these packets to reveal the flag. | ||
</div> | ||
یک فایل | ||
[packet capture](https://en.wikipedia.org/wiki/Pcap) | ||
بهمون داده شده که باید فلگ رو از داخلش در بیاریم | ||
|
||
![wireshark screen of packet capture with some tcp and mdns and quic and tls PDUs](hidden-coordinates-files/1_pcap.png){ style="display: block; margin: 0 auto" } | ||
|
||
طبق گفته چلنج احتمالا فلگ داخل پیام های | ||
[ICMP](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol) | ||
مخفی شده ،ولی بهتره به استراتژی همیشگی بچسبیم و اول ببینیم پیامی هست که رمز نگاری و مخفی نشده باشه | ||
|
||
مثل همیشه اول روی [فلگ پوش TCP](https://datatracker.ietf.org/doc/html/rfc9293#section-3.1-6.14.2.10.1) | ||
فیلتر میزاریم که ببینیم چی دستمون میاد | ||
|
||
![wireshark screen of tcp and tls PDUs](hidden-coordinates-files/2_tcp_push_flag.png){ style="display: block; margin: 0 auto" } | ||
|
||
کلی پیام [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) داریم میبینیم که فعلا استفاده ای برامون ندارن پس فیلترشون میکنیم که نبینیمشون | ||
|
||
![wireshark screen of tcp retransmissions](hidden-coordinates-files/3_filter_on_not_tls.png){ style="display: block; margin: 0 auto" } | ||
|
||
خب مثل اینکه از | ||
`TCP` | ||
چیزی در نمیاد فعلا | ||
|
||
خب بریم سر | ||
`ICMP` | ||
ببینیم چیزی دستمون رو میگیره یا نه | ||
|
||
![wireshark screen of icmp PDUs](hidden-coordinates-files/4_icmp_filter.png){ style="display: block; margin: 0 auto" } | ||
|
||
!!! info inline end "`ICMP payload`" | ||
یکی از قسمت هایی که خیلی خیلی مهمه | ||
`payload` | ||
داخل | ||
`ICMP` | ||
هست که برای | ||
[tunneling](https://en.wikipedia.org/wiki/ICMP_tunnel) | ||
و در کل انتقال دیتا استفاده استفاده میشه چون سادس | ||
|
||
خب ما که به پکت های | ||
`ICMP` | ||
نگاه میکنیم میبینیم کلا دو جور | ||
`payload` دارن این پیاما | ||
|
||
- `datadatadatadata` | ||
|
||
- `abcdefghijklmnopqrstuvwabcdefghi` | ||
|
||
برنامه هایی که | ||
پینگ | ||
میگیرن معمولا اگه ازشون بخوای که یسری دیتا هم بفرستن که پینگ کردن یکم سنگین تر شه میان به ترتیب حروف الفبای انگلیسی میچینن | ||
`payload` | ||
رو | ||
|
||
پس میتونیم با قاطعیت بگیم اونایی که | ||
`payload` | ||
دومی رو دارن متعلق به نرم افزار پینگ استانداردن | ||
|
||
با فیلتر کردن | ||
`ICMP` | ||
هایی که پیلود | ||
`abcdefghijklmnopqrstuvwabcdefghi` | ||
رو دارن رو حذف میکنیم | ||
|
||
![wireshark screen of icmp PDUs](hidden-coordinates-files/5_icmp_filtered_standard_payload.png){ style="display: block; margin: 0 auto" } | ||
|
||
خب اگه درست جلو اومده باشیم فلگ جاهای محدودی میتونه باشه | ||
|
||
باید بگردیم داخل فیلد های مختلف پکت که دیتا ممکنه داخلشون مخفی شده باشه | ||
|
||
!!! failure "" | ||
`ICMP sequence number` | ||
دیتایی نداشت | ||
|
||
!!! failure "" | ||
`ICMP checksum` | ||
هم نمیتونه مهم باشه چون مقدار درستی داره | ||
|
||
تصور اینکه اینقدر خوب پکت رو درست کرده باشن که از | ||
`checksum` | ||
فلگ در بیاد دور از انتظاره | ||
|
||
فیلد | ||
`ttl` | ||
از هدر | ||
`IP` | ||
داخل پیام هایی که از سمت 192.168.1.50 میاد خیلی مشکوکه | ||
|
||
ولی قبلش باید یه مقدمه بهتون بگم از `ttl` | ||
??? TTL | ||
`ttl` | ||
یک فیلد داخل | ||
[IPv4](https://en.wikipedia.org/wiki/IPv4) | ||
هست که نشون میده پکت حق داره جند بار توسط روتر | ||
[forward](https://www.educative.io/answers/what-is-the-difference-between-routing-and-forwarding) | ||
شه | ||
|
||
حواستون باشه این با | ||
[forward کردن توی سویچ های link layer](https://en.wikipedia.org/wiki/Multilayer_switch#Layer-2_switching) | ||
فرق داره | ||
|
||
و هر دفعه که | ||
`forward` | ||
میشه | ||
`router` | ||
یکی از ttl پکت کم میکنه | ||
|
||
وقتی به صفر برسه | ||
`router` | ||
اون پکت رو | ||
`drop` | ||
میکنه | ||
|
||
یسری | ||
`router` | ||
ها به دلایل امنیتی اینکار رو نمیکنن | ||
|
||
تقریبا همیشه دستگاه فرستنده این فیلد رو یکی از اینا ست میکنه | ||
|
||
64, 128, 255 | ||
|
||
|
||
دستگاه 192.168.1.50 مقدار ttl رو به صورت استاندارد ست نمیکنه | ||
|
||
از کجا میدونیم؟ | ||
|
||
چون پکت کپجر روی این دستگاه انجام شده و باید یکی از اعداد 255،128،64 رو میدیدیم داخل | ||
`ttl` | ||
|
||
از کجا میدونیم پکت کپچر روی 192.168.1.50 انجام شده؟ | ||
|
||
وقتی به پیام های عادی که از سمت 192.168.1.50 هستن نگاه میکنیم میبینیم که ttl=128 دارن یعنی هنوز یکبار هم | ||
`forward` | ||
نشدن | ||
|
||
پس ما 192.168.1.50 هستیم | ||
|
||
فرمت فلگ | ||
`uctf{}` | ||
هست و | ||
`ttl` | ||
پیام اول فیلتر شده 117 که مطابق کد اسکی u هست که میشه کاراکتر اول فلگ | ||
|
||
پیام هایی که فیلتر کردیم رو با وایرشارک | ||
`export` میکنیم و با این برنامه فلگ رو به درست میاریم | ||
|
||
```python | ||
from scapy.all import * | ||
pcap = rdpcap("icmp.pcapng") | ||
for packet in pcap: | ||
#if is not icmp echo request, skip the packet | ||
if packet[ICMP].type != 8: | ||
continue | ||
#print ttl of IP layer | ||
print(chr(packet[IP].ttl), end='') | ||
``` | ||
|
||
??? success "FLAG :triangular_flag_on_post:" | ||
<div>`uctf{Iran_K4run_River}`</div> | ||
|
||
!!! نویسنده | ||
[Ali](https://github.com/AliGhaffarian) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters