Skip to main content

Write up KKSI PWN 1, pwn perjuangan (ง ͠° ͟ل͜ ͡°)ง (day 33)

 Image result for mantab meme
 

KKSI adalah ajang kompetesi CTF Indonesia yang bertujuan untuk menjalin Komunikasi sosial antara TNI, khususnya TNI AD dengan Masyarakat umum di era digital. Karena saya sekarang lagi tidak ada Indonesia untuk studi master S2, jadi ga bisa ikut perlombaannya yang menurut saya sayang sekali. Tapi untung ada temen yang coba bagi beberapa soal reverse engineering dan PWN untuk saya coba.

Oleh karena itu saya coba pingin bikin write up untuk dua kategori ini agar semua teman-teman yang belom berhasil mengerjakan soalnya bisa dapat pencerahan. Tapi dimulai dari yang mudah dulu yah !

Ayo! kita bahas soal PWN 1 yang dikasih binari pwn_perjuangan

Pertama-tama, kita masukan file binari nya ke GDB dan coba cek mekanisme keamanan apa yang ada di dalamnya.

Hmmm! kalau diliat dari hasilnya program nya cukup aman karena ada beberapa keamanan yang dipakai seperti

  • NX (non-executable) berarti kita ga bisa melakukan eksekusi kode di dalam stack dengan shellcode 
  •  PIE (Position Independent Executable) berarti alamat memori di dalam program selalu acak jadi makin sulit untuk membuat shellcode juga.
 


biar lebih ngerti dengan mekanisme kodenya coba dimasukin ke ghidra yang merupakan alat decompiler jadi kita bisa analisa source codenya.


setelah di analisa sama ghidra coba kita liat isi dari fungsi yang ada didalam program. Saat dicari ga ada fungsi main yang bisa dipakai untuk titik mulai analisa. Jadi gimana selanjutnya ?

tips nya jadi gini, kan kita pingin cari di bagian kode mana sih yang punya fungsi menarik yang memberikan petunjuk buat dapatin flagnya nih. Kalau kita analisa dari program setiap kali kita kontak dia selalu keluarin string "Give me the number" kan ?

pasti buat ngeluarin string nya kan pake fungsi "prinft" oleh karena itu kita coba "cross reference" function printf biar tahu ini function di panggil di function mana lagi sih.

caranya cross reference di ghidra gmana ?

klik kana function abis itu pilih "show reference to"


nah kita dapat nih fungsi yang punya petunjuk tentang flag nya (coba baca2 dulu function decompilenya)

oke coba kita telaah source code nya

jadi mekanisme programnya kan minta kita nebak nomor kan ? dan ternyata nomor yang kita harus tebak di buat dari nomor random






dan input kita dibandingkan dengan hasil penghitungan randomnya. Bisa dilihat kalau input kita itu dimasukin ke function atoi() yang berati input kita akan diubah ke tipe integer.

int atoi(const char *str); https://en.wikibooks.org/wiki/C_Programming/stdlib.h/atoi

dan input dibandingkan (ivar1 + ivar2) - ivar3 yang 3 variable ini dibuat dari random.




disaat ini saya bingung gimana caranya kita nebak angka acak, oke coba kita teliti bagian randomnya lagi


function srand() itu diisi parameter 1, function ini dipakai untuk "seeding" agar bisa melakukan inisialisai pseurandom angka acak tapi karena cuma diisi satu angka acak nya akan sama terus. Kelemahan ini adalah  Random Number Vulnerability disebabkan karena angka tidak diacak dengan benar kita dapat menebaknya.

link: http://www.tech-faq.com/random-number-vulnerability.html



oke saya coba bikin program yang mirip dengan source code binary yang dikasih kita dapat hasilnya 969527492


saya coba jalankan di mesin yang lain dan ternyata hasilnya sama, coba kita masukin nomonya di binarynya






oke mantab! dapat sekian write up dari saya :D


Comments

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th...

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct...

Easy Web Application Security Machine: CSharp VulnJSON ಠ_ಠ (day 101)

Hi everyone! Welcome back to another vulnhub machine walkthrough. In this post, we will try to solve the the Csharp VulnJSON machine, this particular machine are focus on introducing some key concept of known web application attacks. We will go through each of the vulnerability and we will see how we can elevate this into a working exploit. Background: Setting up this machine is easy, the author provide us with .ova file and all we have to do is just import the file then we good to go.     Information Gathering: first, we need to find out what is the machine ip address, to do this I used nmap to do ping sweep on my local network. from the result above we can see that the target machine is with 192.168.1.7. Now that we have our target IP address, let's proceed with scanning the open port on the machine. cool! so the machine only open port 80 and this will make it much more simple. If we go to the web server, we are welcomed with two forms: first is used for create a user and th...