Skip to content
RCE Write-up Intermediate

KSWEB for Android Remote Code Execution

The KSWEB Web Interface allows authenticated users to write arbitrary files via the configFile parameter, with no whitelist and unrestricted write permissions. An attacker with default credentials could write a PHP web shell to the web root and execute commands, potentially gaining full device control if KSWEB runs as root.

rastating.github.io

Published on rastating.github.io

KSWEB is an Android application used to allow an Android device to act as a web server. Bundled with this mobile application, are several management tools with one-click installers which are installed with predefined sets of credentials.

The author, on rastating.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The application fails to restrict which files can be written via the configFile parameter and does not enforce proper file permissions, allowing arbitrary file write.

Impact

An attacker could execute arbitrary commands on the Android device, and if KSWEB runs as root, gain full control of the device.

What the attacker needed

KSWEB Web Interface accessible; Valid credentials (default admin:admin); KSWEB running as root for full device control

The fix

Upgrade to version 3.94 or later.

How it was found

  1. Scan for the KSWEB Web Interface port (8000-8100) and identify it by the 401 response and Server header.
  2. Authenticate with default credentials (admin:admin) or provided credentials.
  3. Send a POST request to /includes/ajax/handler.php with act=save_config, configFile pointing to a PHP file in the web root, and config_text containing a web shell.
  4. Access the uploaded web shell via a GET request with a command parameter to execute commands.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

KSWEB is an Android app that turns a phone into a web server. Its web interface lets logged-in users edit configuration files, but it does not check which files can be edited. An attacker who knows the default login can save a malicious script that runs commands on the phone.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.